;;; computeFib7.asm
;;; D. Thiebaut
;;;
;;; computes first 7 fibonacci terms
;;; -------------------------------------------------------------------
EXIT equ 1
WRITE equ 4
STDOUT equ 1
;; ------------------------------------------------------------
;; data areas
;; ------------------------------------------------------------
section .data
Fib dd 1, 1, 0, 0, 0, 0, 0
Fib0 equ Fib ; create 7 labels
Fib1 equ Fib+4
Fib2 equ Fib+8
Fib3 equ Fib+12
Fib4 equ Fib+16
Fib5 equ Fib+20
Fib6 equ Fib+24
;; ------------------------------------------------------------
;; code area
;; ------------------------------------------------------------
section .text
global _start
_start:
nop
nop
mov eax, dword[Fib0] ; get Fib0
add eax, dword[Fib1] ; add it to Fib1
mov dword[Fib2],eax ; store it in Fib2
add eax, dword[Fib1] ; etc...
mov dword[Fib3],eax
add eax,dword[Fib2]
mov dword[Fib4],eax
add eax,dword[Fib3]
mov dword[Fib5],eax
add eax,dword[Fib4]
mov dword[Fib6],eax
;; exit()
mov eax,EXIT
mov ebx,0
int 0x80 ; final system call