-
Notifications
You must be signed in to change notification settings - Fork 20
/
0x01.asm
45 lines (43 loc) · 885 Bytes
/
0x01.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
41
42
43
44
45
;
; $Id: 0x01.asm,v 1.1.1.1 2016/03/27 08:40:12 raptor Exp $
;
; 0x01 explanation - from xchg rax,rax by [email protected]
; Copyright (c) 2016 Marco Ivaldi <[email protected]>
;
; This snippet demonstrates an elegant way to generate the
; Fibonacci Sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...
;
; Example:
; uncomment the added lines
; $ nasm -f elf64 0x01.asm
; $ gcc 0x01.o -o 0x01
; $ gdb 0x01
; (gdb) b main.loop
; (gdb) r
; (gdb) i r rax
; rax 0x0 0
; (gdb) c
; (gdb) i r rax
; rax 0x1 1
; (gdb) c
; (gdb) i r rax
; rax 0x1 1
; (gdb) c
; (gdb) i r rax
; rax 0x2 2
; (gdb) c
; (gdb) i r rax
; rax 0x3 3
; (gdb) c
; (gdb) i r rax
; rax 0x5 5
;
BITS 64
SECTION .text
global main
main:
;mov rax,0 ; initialize the rax register
;mov rdx,1 ; initialize the rdx register
.loop:
xadd rax,rdx
loop .loop