Skip to content

Commit

Permalink
macros: save, unsave, zero
Browse files Browse the repository at this point in the history
  • Loading branch information
davidad committed Apr 30, 2014
1 parent a6f9a4a commit dfb0d13
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
11 changes: 11 additions & 0 deletions macros.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
macro save [reg] {
forward push qword reg
common macro unsave \{
reverse pop qword reg
common purge unsave
\}
}

macro zero [reg] {
forward xor reg, reg
}
26 changes: 26 additions & 0 deletions save_unsave_test.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
format ELF64
include "syscalls.inc"
include "macros.inc"
public start

start:
mov edx,msg_size-1
lea rsi,[msg]
@@:

zero edi
save rdi
mov edi, 1
save rdi, rdx, rsi
zero di, edx, rsi
unsave
add rsi, rdi
mov eax, SYSCALL_WRITE
syscall
unsave

mov eax, SYSCALL_EXIT
syscall

msg db '0123456789',0xA
msg_size = $-msg

0 comments on commit dfb0d13

Please sign in to comment.