Quantcast
Viewing all articles
Browse latest Browse all 5986

How to use stack in arm64 assembly

I was trying to write a nested loop and print a 10x10 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.dataDOT: .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.


Viewing all articles
Browse latest Browse all 5986

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>