我正在尝试在Assembly(ARM arch)中编写一个代码,该代码将数组的内容打印到控制台。我写了以下代码:
.data
.balign 4
a: .skip 12 //define an array of (4bytes * 3)
.text
.global main
main:
mov r0, #1 //for stdout
ldr r1, addr_a //load the address of the array
mov r2, #4 //the length of an integer 4 bytes
mov r3, sp //puts into r3 the address that points the SP
str r3, [r1] //store the address into the first position of the array
str r3, [r1, #+4] //same at the second position
mov r7, #4 //make the sys_call write
swi 0 //software interrupt
mov r7, #1
swi 0
addr_a: .word a
编译代码时,我没有收到任何错误。然而,这会在控制台上打印一些原始数据,如无意义的字符。 有人可以帮我解决这个问题吗?
由于