MIPS十六进制输出 [英] MIPS Hex Output

查看:1197
本文介绍了MIPS十六进制输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道是否有同一个扩展名为.s像与仿真PCSpim使用MIPS写汇编语言文件(只是很简单的测试文件)的方式,然后有它实际编译code和生产用十六进制输出文件,好像我是将其装载到一个实际的MIPS芯片。

能否SPIM或一些其他类似的软件做到这一点?你能解释一下有关从MIPS组装装配过程中,该微控制器使用实际的可执行?

感谢


编辑:所以我在Ubuntu Linux上安装GCC运行。我有一个MIPS文件mipsTest.s是以下

 的.text
 加$ 7,$ 0 $ 0个

现在在命令行中I型

 的gcc -o -c mipsy.o mipsTest.s

和我得到的错误说:

  mipsTest.s:汇编的消息:
mipsTest.s:2:错误:最多2立即操作数是允许的。

所以对我来说这意味着汇编未读MIPS的语言,这大概是我的假设汇编文件是在86?我如何获得一个交叉编译器设置,使gcc会认识到MIPS汇编语言,而不是86? (或任何其跨preting我mipsTest.s文件作为现在)谢谢!

编辑2:所以,我用Google搜索MIPS交叉汇编,发现了一些东西。似乎最有希望的一次是在SourceForge上UMPS交叉汇编项目。于是我下载了这应该是一个稳定的版本umps2.0。我untarballed任何跑了的./configure作为自述文件中的指示。然后我的控制台给了我下面的错误,prevents我从运行make命令...

 乔纳森@小heiretic:〜/文档/交叉编译/ UMPS-2.0 $的./configure
检查建设系统类型... i686的-PC-Linux的GNU
检查主机系统类型... i686的-PC-Linux的GNU
检查目标系统类型... i686的-PC-Linux的GNU
检查GCC海湾合作委员会...
检查C编译器是否工作......是的
检查C编译器默认的输出文件名的a.out ...
检查可执行文件后缀...
检查我们是否交叉编译...没有
检查对象文件后缀... O
检查我们是否使用GNU C编译器......是的
海湾合作委员会检查是否接受-g ......是的
gcc的选项检查接受ISO C89 ...没有必要
检查如何运行C preprocessor ​​... gcc的-E
检查grep的处理排长和-e ... /斌/ grep的
检查egrep的... /斌/ grep的-E
检查的ANSI C头文件...是的
检查SYS / types.h中......是的
检查SYS / stat.h ...是的
检查文件stdlib.h ...是的
检查string.h中...是的
检查memory.h ...是的
检查strings.h ...是的
检查inttypes.h ...是的
检查stdint.h ...是的
检查unistd.h中...是的
检查字节顺序是否为bigEndian ...没有
检查一个BSD兼容安装...在/ usr /斌/安装-c
检查编译环境是否健全......是的
检查一个线程安全的mkdir -p ... /斌/的mkdir -p
检查GAWK ... GAWK
检查是否化妆套$(MAKE)......是的
检查包括使用的化妆风格... GNU
检查GCC的依赖风格...的gcc3
检查G ++ ... G ++
检查我们是否使用GNU C ++编译器......是的
检查G ++是否接受-g ......是的
G ++ ...的gcc3的检查依赖性风格
检查的gcc ...(缓存)海湾合作委员会
检查我们是否使用GNU C编译器...(缓存)是
海湾合作委员会检查是否接受-g ...(缓存)是
gcc的选项检查接受ISO C89 ...(缓存)无必要
检查如何运行C preprocessor ​​... gcc的-E
检查是否LN -s作品......是的
检查如何打印字符串的printf ...
检查一个sed不截断输出... /斌/ sed的
检查fgrep一样... /斌/ grep的-F
检查GCC使用LD ...的/ usr / bin中/ LD
检查是否连接(在/ usr /斌/ LD)是GNU LD ......是的
检查BSD-或MS-兼容名称利斯特(NM)...在/ usr /斌/纳米-B
检查名称李斯特(在/ usr /斌/纳米-B)接口... BSD纳米
检查命令行参数的最大长度... 1572864
检查外壳是否理解一些XSI结构......是的
检查外壳是否理解+ =...是的
检查如何的i686-Linux PC的GNU的文件名转换为i686的-PC-Linux的GNU格式... func_convert_file_noop
检查如何的i686-Linux PC的GNU的文件名转换为工具链格式... func_convert_file_noop
检查的/ usr / bin中/ LD选项重新加载目标文件-r ...
检查objdump的objdump的...
检查如何识别依赖库... pass_all
检查dlltool ...没有
检查如何运行库和链接库相关联的printf ...%S \\ n
检查AR AR ...
检查归档@FILE支持... // @
检查带带...
检查ranlib处理... ranlib处理
检查命令解析在/ usr /斌/纳米-B从GCC对象输出... OK
检查SYSROOT ...没有
检查MT ...吨
检查是否是MT清单工具...没有
检查dlfcn.h中...是的
检查objdir ...的.libs
检查是否GCC支持-fno-RTTI -fno-例外...没有
检查GCC选项生成PIC ... -fPIC -DPIC
检查是否gcc的PIC标志-fPIC -DPIC工作......是的
检查是否GCC静态标志-static工作......是的
检查是否GCC支持-c -o file.o ......是的
检查是否GCC支持-c -o file.o ...(缓存)是
检查连接器GCC(在/ usr /斌/ LD)是否支持共享库......是的
检查是否-lc应该明确地联系在一起......不
检查动态连接器的特性......的GNU / Linux ld.so
检查如何辛苦code库的路径到程序中...立即
检查是否剥离库可能......是的
检查是否libtool的支持共享库......是的
检查是否建立共享库......是的
检查是否建立静态库......是的
检查如何运行C ++ preprocessor ​​... G ++ -E
检查用g ++ ...的/ usr / bin中/ LD LD使用
检查是否连接(在/ usr /斌/ LD)是GNU LD ......是的
检查G ++链接(在/ usr /斌/ LD)是否支持共享库......是的
检查G ++选项生成PIC ... -fPIC -DPIC
检查,如果G ++ PIC标志-fPIC -DPIC工作......是的
检查,如果G ++静态标志-static工作......是的
检查,如果G ++支持-c -o file.o ......是的
检查,如果G ++支持-c -o file.o ...(缓存)是
检查G ++链接(在/ usr /斌/ LD)是否支持共享库......是的
检查动态链接特性...(缓存)的GNU / Linux ld.so
检查如何辛苦code库的路径到程序中...立即
检查GCC的依赖风格...的gcc3
检查GCC使用LD ...(缓存)的/ usr / bin中/ LD
检查是否连接(在/ usr /斌/ LD)是GNU LD ...(缓存)是
检查中-lelf elf_version ...没有
配置:错误:***未libelf的发现。指定一个不同的路径,或者安装。 --help的信息。

是否有更好的选择,我应该尝试或任何人都可以在我的错误提供输入?

修改3:下载后libelf的,我现在就可以得到一点点进一步在UMPS的配置脚本。下面是输出从新成功elf_version行开始

 在-lelf检查elf_version ...是的
检查中-ldl的dlopen ...是的
检查pkg配置...的/ usr / bin中/ pkg配置
检查pkg配置至少是0.9.0版本......是的
检查SIGCPP ...没有
配置:错误:包装要求(sigc ++ - 2.0)没有得到满足:没有包'sigc ++ - 2.0找到试想,如果你调整PKG_CONFIG_PATH环境变量
在非标准preFIX安装的软件。或者,您可以设置环境变量SIGCPP_CFLAGS
和SIGCPP_LIBS避免需要调用pkg配置。
有关详细信息,请参见pkg配置手册页。

所以我跑了快命令和apt-get安装sigc ++ - 2.0,但找不到包......建议

修改4:这是我得到的错误,当我尝试使用的Makefile

<$p$p><$c$c>jonathan@mini-heiretic:~/Documents/cross-compiler/dwelch67-pic32_samples-f34fb22/blinker01$使
MIPS-SDE-精灵作为-EL -G0 --warn --fatal-警告blinker01.s -o blinker01.o
令:MIPS-SDE-精灵为:命令未找到
使:*** [blinker01.o]错误127


解决方案

您可以使用 GCC 等等,交叉编译或汇编MIPS汇编语言源代码。至于过程中,有汇编语言助记符和机器指令之间的一对一的映射。汇编器只是做翻译给你。

编辑:你没有使用交叉汇编,你用系统自带的GCC。这工具链presumably针对英特尔处理器,它不具有3操作数添加指令。您需要使用交叉汇编程序的MIPS。下载并安装一个二进制,或者自己建立一个工具链。然后,你将有一个交叉编译器(可能称为MIPS-GCC或类似的东西),您可以用它来组装您的MIPS源文件。

I'm wondering if there is a way to write MIPS assembly language file (just really simple test file) with a .s extension like is used with the PCSpim simulator and then have it actually compile the code and produce a file with the hex output as if I were to load it onto an actual MIPS chip.

Can SPIM or some other similar software do this? Can you explain a little more about the assembly process from MIPS assembly to the actual executable that the microcontroller uses?

Thanks


EDIT: So I'm running on ubuntu linux with gcc installed. I have a mips file mipsTest.s that is the following

 .text
 add $7, $0, $0

Now at the command line I type

gcc -c -o mipsy.o mipsTest.s

And the error that I get says

mipsTest.s: Assembler messages:
mipsTest.s:2: Error: at most 2 immediate operands are allowed.

So to me that means that the assembler is not reading the mips language, it is probably assuming my assembly file is in x86? How do I get a cross compiler setup so that gcc will recognize the MIPS assembly language instead of x86? (or whatever its interpreting my mipsTest.s file as right now) Thanks!

EDIT 2: So I googled "mips cross-assembler" and found a few things. The one that seemed most promising was the umps cross-assembler project on sourceforge. So I downloaded umps2.0 which is supposed to be a stable version. I untarballed it any ran the "./configure" as instructed in the readme file. Then my console gave me the following error which prevents me from running the make command...

jonathan@mini-heiretic:~/Documents/cross-compiler/umps-2.0$ ./configure
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking whether byte ordering is bigendian... no
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking how to run the C preprocessor... gcc -E
checking whether ln -s works... yes
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert i686-pc-linux-gnu file names to i686-pc-linux-gnu format... func_convert_file_noop
checking how to convert i686-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for mt... mt
checking if mt is a manifest tool... no
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking how to run the C++ preprocessor... g++ -E
checking for ld used by g++... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC -DPIC
checking if g++ PIC flag -fPIC -DPIC works... yes
checking if g++ static flag -static works... yes
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... (cached) GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking dependency style of gcc... gcc3
checking for ld used by gcc... (cached) /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... (cached) yes
checking for elf_version in -lelf... no
configure: error: *** Libelf not found. Specify a different path or install it. --help for info.

Are there any better options I should try or can anyone provide input on my error?

EDIT 3: After downloading Libelf, I can now get a little further in the configure script for umps. Here is the output starting from the newly successful elf_version line

checking for elf_version in -lelf... yes
checking for dlopen in -ldl... yes
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for SIGCPP... no
configure: error: Package requirements (sigc++-2.0) were not met:

No package 'sigc++-2.0' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables SIGCPP_CFLAGS
and SIGCPP_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

So I ran a quick sudo apt-get install sigc++-2.0 but couldn't find the package... suggestions?

EDIT 4: Here's the error I get when I try to use the Makefile

jonathan@mini-heiretic:~/Documents/cross-compiler/dwelch67-pic32_samples-f34fb22/blinker01$ make
mips-sde-elf-as -EL -G0 --warn --fatal-warnings blinker01.s -o blinker01.o
make: mips-sde-elf-as: Command not found
make: *** [blinker01.o] Error 127

解决方案

You can use gcc, among others, to cross-compile or assemble MIPS assembly language source. As far as the process, there is a one-to-one mapping between assembly language mnemonics and machine instructions. The assembler just does the translation for you.

Edit: You're not using a cross-assembler, you're using the system's own gcc. That toolchain is presumably targeting Intel processors, which don't have a 3-operand add instruction. You need to use a cross-assembler for MIPS. Download and install a binary one, or build a toolchain yourself. Then you'll have a cross compiler (maybe called mips-gcc or something like that) that you can use to assemble your MIPS source files.

这篇关于MIPS十六进制输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆