我正在参加汇编课程,但由于符合Windows 95 x.x,我无法运行他们提供的汇编程序
我正在运行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
答案 0 :(得分:0)
看看你的汇编程序是否采用以下行:
AREA PrintText, CODE, READONLY, THUMB
答案 1 :(得分:0)
.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 function