Created
October 27, 2021 22:52
-
-
Save nekodjin/80933ea89e55489604c79e118b393da3 to your computer and use it in GitHub Desktop.
Stash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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