I am attempting to write my first ARM program and getting this error when I try to run "as -o labl1.o lab1.s"
lab1.s:3: Error: junk at end of line, first unrecognized character is `s'
I am very unsure about what I am doing wrong here, as the only times I use s is in my 2 strings, and very puzzled on where in the code I went wrong.
@Data
.data
string1: .asciz
string2: .asciz
@Code
.text
.global main
.extern printf
main:
push {ip, lr}
push {r0, r1, r2}
ldr r0, =string1
mov r1, #34
mov r2, #56
bl printf
pop {r0,r1,r2}
push {r0}
ldr r0, =string2
bl printf
pop {r0}
pop {ip, pc}
Links to helpful documents or help debugging would be greatly appreciated, thank you!
You may be confusing the address of your strings and the values you want to assign them: As specified in GNU as documentation, the .asciz
directive does require a string argument - a slightly modified version of your code does assemble correctly:
.data
string1: .asciz "string1"
string2: .asciz "string2"
string1
is now the label for the address where bytes "string1\x00
" are located, and string2
is the label for the address where bytes "string2\x00"
are.