...
This commit is contained in:
@@ -1,19 +1,47 @@
|
||||
.intel_syntax noprefix
|
||||
|
||||
.section .data
|
||||
.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_out_of_bounds:
|
||||
array_oob_msg:
|
||||
.ascii "Index is out of bounds of array\n"
|
||||
|
||||
.section .text
|
||||
.global nub_panic_array_oob
|
||||
nub_panic_array_oob:
|
||||
mov rax, 1 # syscall = sys_write
|
||||
mov rdi, 2 # fd = stderr
|
||||
lea rsi, [rip + array_out_of_bounds] # message
|
||||
mov rdx, 32 # message length
|
||||
.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
|
||||
|
||||
mov rax, 60 # sys_exit
|
||||
mov rdi, 101 # exit code
|
||||
.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
|
||||
|
||||
Reference in New Issue
Block a user