Data update

This commit is contained in:
Ingy döt Net 2025-06-11 20:16:52 -04:00
parent 72eb4943cb
commit 4d5544505c
2347 changed files with 62432 additions and 16731 deletions

View file

@ -0,0 +1,16 @@
.global _start
.text
_start:
mov x8, #64 //64 is write
mov x0, #1 //1 is stdout
adr x1, msg //mov address of msg into x1
mov x2, #(msgend - msg) //msgend minus msg is the length of message
svc #0 //system call
mov x8, #93 //93 is exit
mov x0, xzr //0 is the exit code. xzr is the zero register
svc #0 //system call
msg:
.ascii "Hello world!\n"
msgend:

View file

@ -0,0 +1,21 @@
.global _start
.text
_start:
adr x0, msg // load x0 with address of message
bl writez // call the function that writes null-terminated string to stdout
mov x8, #93 // 93 is syscall exit
mov x0, xzr // exit code = 0. Exit normal.
svc #0 // syscall
// If using as a function in C declare it as
writez: // extern long writez(char *str);
mov x1, x0 // address of str needs to be in x1 for syscall
sub x0, x0, #1 // decrement x0, because the next statement increments it.
0: ldrb w2, [x0, #1]! // increment x0, load byte value at x0 in w2
cbnz w2, 0b // if w2 is not zero jump back to 0: label
sub x2, x0, x1 // subtract x1 from x0, load into x2. length of str
mov x0, #1 // mov into x0 1. stdout
mov x8, #64 // mov into x8 64. write
svc #0 // syscall
ret // return from function.
// return value (x0) is number of characters written.
msg: .asciz "Hello world!\n" // .asciz means null-terminated string. Assembler adds the 0