Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Assembly 十六进制输出_Assembly_Hex_Mips - Fatal编程技术网

Assembly 十六进制输出

Assembly 十六进制输出,assembly,hex,mips,Assembly,Hex,Mips,我想知道是否有一种方法可以编写带有.s扩展名的MIPS汇编语言文件(只是非常简单的测试文件),就像PCSpim模拟器使用的那样,然后让它实际编译代码并生成带有十六进制输出的文件,就好像我要将它加载到实际的MIPS芯片上一样 SPIM或其他类似软件可以做到这一点吗?你能再解释一下从MIPS汇编到微控制器使用的实际可执行文件的汇编过程吗 谢谢 编辑:所以我在安装了gcc的ubuntu linux上运行。我有一个mips文件mipsTest.s,如下所示 .text add $7, $0, $0

我想知道是否有一种方法可以编写带有.s扩展名的MIPS汇编语言文件(只是非常简单的测试文件),就像PCSpim模拟器使用的那样,然后让它实际编译代码并生成带有十六进制输出的文件,就好像我要将它加载到实际的MIPS芯片上一样

SPIM或其他类似软件可以做到这一点吗?你能再解释一下从MIPS汇编到微控制器使用的实际可执行文件的汇编过程吗

谢谢


编辑:所以我在安装了gcc的ubuntu linux上运行。我有一个mips文件mipsTest.s,如下所示

 .text
 add $7, $0, $0
现在在命令行输入

gcc -c -o mipsy.o mipsTest.s
我得到的错误是

mipsTest.s: Assembler messages:
mipsTest.s:2: Error: at most 2 immediate operands are allowed.
所以对我来说,这意味着汇编程序没有读取mips语言,它可能假设我的汇编文件是x86格式的?如何获得交叉编译器设置,以便gcc能够识别MIPS汇编语言而不是x86?(或者不管它如何解释我的mipsTest.s文件)谢谢

编辑2:所以我在谷歌上搜索了“mips交叉汇编程序”,发现了一些东西。看起来最有希望的是sourceforge上的umps交叉汇编程序项目。所以我下载了umps2.0,它应该是一个稳定的版本。我按照自述文件中的说明,在运行“/configure”时将其取消标记。然后我的控制台给了我以下错误,使我无法运行make命令

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.
是否有更好的选择,我应该尝试或任何人可以提供我的错误输入

编辑3:下载Libelf后,我现在可以进一步了解ump的配置脚本。下面是从最新成功的elf_版本行开始的输出

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.
所以我运行了一个快速的sudo apt get install sigc++-2.0,但找不到包。。。建议

编辑4:以下是我尝试使用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
除其他外,您可以使用交叉编译或汇编MIPS汇编语言源代码。就流程而言,汇编语言助记符和机器指令之间存在一对一的映射。汇编程序只是帮你翻译


编辑:您没有使用交叉汇编程序,而是使用系统自己的gcc。该工具链的目标可能是英特尔处理器,它没有3操作数
add
指令。您需要为MIPS使用交叉汇编程序。下载并安装一个二进制软件,或者自己构建一个工具链。然后,您将拥有一个交叉编译器(可能称为mips gcc或类似的东西),您可以使用它来组装mips源文件。

谢谢,介意详细介绍一下如何在交叉编译过程中使用gcc吗?有点像是一个C环境的noob……好吧,去买一个MIPS工具链(或者自己构建一个),然后使用`gcc-omyappsourcefile.s“应该就这样了。你可能需要做一些更复杂的事情,这取决于你芯片上的环境。我不希望我的芯片运行内核或类似的东西。它应该只是一个执行十六进制指令的状态机,十六进制指令是您在回答中描述的sourceFile.s一对一映射的结果。肯定有一个程序可以为我做一对一的翻译吗?我不想建立一个C库或任何东西。只要直接从MIPS汇编程序转到MIPS机器代码,汇编程序就会这样做。组装源代码后,您可以使用
objcopy
从对象文件中获取平面二进制文件。这是GNU汇编程序吗?我很抱歉,但是你给我的关键词没有显示任何直接有用的网站。我想标记你的答案是正确的,因为我相信你知道你在说什么,但除非你能提供一个步骤列表或一个更直接有用的链接,否则我将不得不修改这个问题并再次提问。请详细说明获取.s文件和检索任何MIPS汇编程序生成的目标文件所需的步骤。谢谢,我有一些关于如何构建您自己的交叉编译器/工具以及您可以下载的交叉编译器/工具的示例和说明。谢谢dwelch,那么对于MIPS交叉汇编器,我需要下载哪些文件?从您的自述文件来看,如果我计划使用gcc作为mips.s文件的前端,那么我所需要的只是binutils包?binutils就是您所需要的。现在spim可能有特定于spim的语法,gnu汇编程序可能支持,也可能不支持,因此您可能需要对代码进行调整,以便从现在的位置转到gas喜欢的位置。请将blinker01示例视为一个简单的汇编到机器代码示例。@dwelch好的,谢谢,我将在一分钟内尝试。是的,SPIM支持一些只作为宏实现的伪指令,但我不希望汇编程序处理这些指令。出于我的目的,我只需要实际的MIPS 1指令。@dwelch ok,所以我下载了binutils并将其解压。然后,我进行了配置制作和制作安装。我现在需要做什么,以便gcc能够识别mips指令?