Files
nub-lang/src/CLI/Runtime/nub_panic.s
nub31 6d3c241368 ...
2025-06-15 00:50:31 +02:00

48 lines
729 B
ArmAsm

.intel_syntax noprefix
.equ NUB_PANIC_ERROR_CODE, 101
.equ SYS_WRITE, 1
.equ SYS_EXIT, 60
.equ FD_STDIN, 0
.equ FD_STDOUT, 1
.equ FD_STDERR, 2
.data
.align 8
array_oob_msg:
.ascii "Index is out of bounds of array\n"
.data
.align 8
oom_msg:
.ascii "Out of memory\n"
.text
.globl nub_panic
nub_panic:
mov rax, SYS_EXIT
mov rdi, NUB_PANIC_ERROR_CODE
syscall
.text
.globl nub_panic_array_oob
nub_panic_array_oob:
mov rax, SYS_WRITE
mov rdi, FD_STDERR
lea rsi, [rip + array_oob_msg]
mov rdx, 32
syscall
call nub_panic
.text
.globl nub_panic_oom
nub_panic_oom:
mov rax, SYS_WRITE
mov rdi, FD_STDERR
lea rsi, [rip + oom_msg]
mov rdx, 14
syscall
call nub_panic