我正在上汇编课,结果我无法运行他们提供的汇编程序,因为它符合 Windows 95 xx
我正在运行 Rasperry PI,并且可以通过以下方式轻松运行 Assembly for 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 但不认为它是正确的,因为我没有看到任何变化。
as -mthumb -o test.o test.s