-1

Attempting to compile the following in order to read a 5 byte char from stdin:

.bss
    num resb 5

.text
.global _start
_start:
        mov r0, $1
        mov r1, num
        mov r2, $5
        mov r7, #3
        swi $0

Via the following

as -o readstdin.o readstdin.s

But I get the assembly error:

readstdin.s: Assembler messages:
readstdin.s:2: Error: bad instruction `num resb 5'
readstdin.s:8: Error: immediate expression requires a # prefix -- `mov r1,num'

I am running this on an ARM11 Raspberry Pi Zero.

Jester
  • 56,577
  • 4
  • 81
  • 125
Jacob Clark
  • 3,317
  • 5
  • 32
  • 61

1 Answers1

1

gnu assembler does not use resb. Try .lcomm num, 5 instead. As for mov r1, num I guess you really wanted to say ldr r1, =num. You might want to consult the manual.

Jester
  • 56,577
  • 4
  • 81
  • 125