I was trying to write a nested loop and print a 10×10 grid of dots. And the assembler throws error when I am trying to use PUSH and POP commands in _print subroutine. Is this the right way to do it or am I doing something wrong. Please Help
.equ WIDTH, 10
.equ HEIGHT, 10
.data
DOT: .ascii "."
BLOCK: .ascii "$"
NEW_LINE: .ascii "n"
.text
.global _start
_start:
_renderFrame:
mov x0, HEIGHT
mov x1, WIDTH
bl _height
_height:
cmp x0, 0
beq _exit
sub x0, x0, 1
bl _width
ldr x3, =NEW_LINE
bl _print
bl _height
_width:
cmp x1, 0
beq _height
sub x1, x1, 1
ldr x3, =DOT
bl _print
bl _width
_print:
push {x0, x1, x2}
mov x8, 0x40
mov x0, 1
mov x1, x3
mov x2, 1
svc 0
pop {x0, x1, x2}
ret
_exit:
mov x8, 0x5d
mov x0, 0
svc 0
The error is as below
main.asm: Assembler messages:
main.asm:35: Error: unknown mnemonic `push' -- `push {x0,x1,x2}'
main.asm:41: Error: unknown mnemonic `pop' -- `pop {x0,x1,x2}'
Note: Before I tried to run assembly in macOS but it seems there is not much support articles online regarding macOS. So I am running this code in a Ubuntu Docker container with inbuilt assembler and linker. And the print and exit system calls are working fine.