Skip Navigation

arm Information

Friday 19 July 2024Switch theme

Below is a list of random arm (Advanced RISC Machines) information for my reference.

Random arm Information

Click on a subject below to reveal its details

001 How to compile assembly language on linux
  • as -o object.o source.asm
  • ld -s -o program object.o

You run the program using: ./program

002 helloworld in arm64 assembly

Source: hello.asm

.globl _start
.section .text

    // Get address of counter
    adr x15, counter

    // Get the value at address counter
    ldrb w15, [x15]

    // Print Hello, World!
    bl print_hello
    sub w15, w15, #1
    cmp w15, #0
    beq endpgm
    b loop

    mov x0, _stdout
    adr x1, msg
    mov x2, msglen
    mov w8, _write
    svc #0

    mov x0, #0
    mov w8, _exit
    svc #0

.section .data

    // Constants
    .equ   _stdout,  1
    .equ   _write,  64
    .equ   _exit,   93

// Variables in memory
    .ascii "Hello, World!\n"
    msglen = . - msg   // Length of msg
    .byte 3

003 Simple makefile for helloworld

To run the make file use the "make" command, the make command can have a label as a parameter, so "make clean" will run the "clean" section in the makefile

hello: hello.o
    ld -s -o hello hello.o
hello.o: hello.asm
    as -o hello.o hello.asm
    rm *.o hello