Skip to content

Instantly share code, notes, and snippets.

@nekodjin
Created October 27, 2021 22:52
Show Gist options
  • Save nekodjin/80933ea89e55489604c79e118b393da3 to your computer and use it in GitHub Desktop.
Save nekodjin/80933ea89e55489604c79e118b393da3 to your computer and use it in GitHub Desktop.
Stash
global ys_stash
%include "macros.asm"
ys_stash:
pop rbx
cmp r14, r15
jne no_allocate
getbrk
mov rbp, rax
add rax, 0x1000
setbrk rax
cmp rax, rbp
je overflow
mov r15, rax
no_allocate:
popb al
mov [r14], al
lea r14, [r14+1]
push rbx
ret
overflow:
mov rdx, err_len
mov rsi, err_msg
mov rdi, 1
mov rax, 1
syscall
mov rdi, 3
mov rax, 60
syscall
segment .data
err_msg db 0x0a, "Error: Secondary Stack Overflowed (OOM)", 0x0a
err_len equ $ - err_msg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment