calculator/tests/tohex.s

33 lines
739 B
ArmAsm
Raw Normal View History

# Test for btohex
.org 0
# Provide program starting address to linker
.global _start
.extern tohex
/* newlib system calls */
.set SYSEXIT, 93
.set SYSWRITE, 64
.section .bss
buf: .skip 9
.text
_start:
2025-02-13 10:32:18 +00:00
li a0, '\n'
la a1, buf
sb a0, 8(a1) # append newline to buf
li a0, 0xCAFEFEED
jal tohex
li t0, SYSWRITE # "write" syscall
li a0, 1 # 1 = standard output (stdout)
la a1, buf # load address of output string
li a2, 9 # length of output string
ecall # invoke syscall to print the string
li t0, SYSEXIT # "exit" syscall
la a0, 0 # Use 0 return code
ecall # invoke syscall to terminate the program