我上了一个汇编类,结果发现我不能运行他们提供的汇编程序,因为它是兼容Windows 95的x.x
我正在运行Rasperry PI,可以通过以下方式轻松运行ARM代码的程序集
http://thinkingeek.com/2013/01/09/arm-assembler-raspberry-pi-chapter-1/
/* -- first.s */
/* This is a comment */
.global main /* 'main' is our entry point and must be global */
.func main /* 'main' is a function */
main: /* This is main */
mov r0, #2 /* Put a 2 inside the register r0 */
bx lr /* Return from main */
$ as -o first.o first.s
$ gcc -o first first.o
$ ./first ; echo $?
2但这是标准的ARM 32位设置,需要编译并运行thumb-2设置,例如:
AREA PrintText, CODE, READONLY
SWI_WriteC EQU &0 ;output character in r0
SWI_Exit EQU &11 ;finish program
ENTRY
BL Print ;call print subroutine
= "Text to print",&0a,&0d,0
ALIGN
SWI SWI_Exit ;finish
Print LDRB r0,[r14], #1 ;get a character
CMP r0, #0 ;end mark NUL?
SWINE SWI_WriteC ;if not, print
BNE Print
ADD r14, r14, #3 ; pass next word boundary
BIC r14, r14, #3 ; round back to boundary
MOV pc, r14 ;return
END有人知道我需要在Pi中做什么才能运行这个拇指风格吗?编辑:
对于上面的命令,我尝试添加-mthumb,但我不认为这是正确的,因为我没有看到任何变化。
作为-mthumb -o test.o test.s
发布于 2013-10-01 03:46:15
看看你的汇编程序是否会采用下面这一行:
AREA PrintText, CODE, READONLY, THUMB发布于 2013-10-01 07:42:28
.code 32 @ stuff after this line is arm code
.globl hello_arm
hello_arm: @an arm function
.thumb @stuff after this line is thumb
.thumb_func @the next function is a thumb function and called properly
.globl hello
hello: @ a thumb functionhttps://stackoverflow.com/questions/19100992
复制相似问题