tiny_os/root/root.S
2024-07-03 22:51:21 +08:00

27 lines
519 B
ArmAsm

.macro syscall msg ptr
li a0, \msg
li a1, \ptr
ecall
.endm
.text
.global _start
_start:
la t0, msg
.loop:
lb a2, 0(t0)
beqz a2, .yield
# msg: label = DebugPutChar(1), length = 3
# ptr: self-referential to cspace, just to create a valid cptr
syscall (1<<12 | 3), 0x0202020202020202
addi t0, t0, 1
j .loop
.yield:
# msg: label = Yield(2), length = 2
# ptr: self-referential to cspace, just to create a valid cptr
syscall (2<<12 | 2), 0x0202020202020202
j _start
.data
msg : .string "Hello, world!\n\0"