Difference between revisions of "CSC231 ComputeFib7.asm"
(New page: <code><pre> ;;; computeFib7.asm ;;; D. Thiebaut ;;; ;;; computes first 7 fibonacci terms ;;; ------------------------------------------------------------------- EXIT equ 1...) |
|||
Line 36: | Line 36: | ||
mov eax, dword[Fib0] ; get Fib0 | mov eax, dword[Fib0] ; get Fib0 | ||
add eax, dword[Fib1] ; add it to Fib1 | add eax, dword[Fib1] ; add it to Fib1 | ||
− | mov dword[Fib2],eax | + | mov dword[Fib2],eax ; store it in Fib2 |
add eax, dword[Fib1] ; etc... | add eax, dword[Fib1] ; etc... | ||
mov dword[Fib3],eax | mov dword[Fib3],eax |
Latest revision as of 10:35, 15 September 2008
;;; 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