-
Notifications
You must be signed in to change notification settings - Fork 20
/
0x00.asm
40 lines (38 loc) · 1.04 KB
/
0x00.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
;
; $Id: 0x00.asm,v 1.1.1.1 2016/03/27 08:40:12 raptor Exp $
;
; 0x00 explanation - from xchg rax,rax by [email protected]
; Copyright (c) 2016 Marco Ivaldi <[email protected]>
;
; This is the snippet #0: it sets registers to 0 in different ways.
;
; Example:
; uncomment the added lines
; $ nasm -f elf64 0x00.asm
; $ gcc 0x00.o -o 0x00
; $ gdb 0x00
; (gdb) b debug
; (gdb) r
; (gdb) i r
; rax 0x0 0
; rbx 0x0 0
; rcx 0x0 0
; rdx 0x0 0
; rsi 0x0 0
; rdi 0x0 0
; rbp 0x0 0x0
; [...]
;
BITS 64
SECTION .text
global main
main:
xor eax,eax ; set rax to 0 by xor'ing it with itself
lea rbx,[0] ; set rbx to 0 by loading the value 0 into it
;mov ecx,10 ; added to make the following loop faster
loop $ ; set rcx to 0 by decrementing it via loop
mov rdx,0 ; set rdx to 0 using the mov instruction
and esi,0 ; set rsi to 0 by and'ing it with 0
sub edi,edi ; set rdi to 0 by subtracting its current value
push 0
pop rbp ; set rbp to 0 using push and pop instructions