| | |
Can someone help me undestand these codes?
Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Feb 2008
Posts: 1
Reputation:
Solved Threads: 0
Can someone help me undestand each line of code.
I used emu8086 for this program..
Any help will be appreciated!
Title Fibonacci series
; Fibonacci series
;
; Write a program that generates the first 15 integers
; of the Fibonacci series {1,2,3,5,8,...}. Beginning with
; the third element, each number is the sum of the previous
; two numbers. Store the numbers in an array.
.model small
.stack 100h
.data
fArray dw 15 dup(?)
.code
main proc
mov ax,@data
mov ds,ax
; Store the first fibonacci numbers in the array...
mov bx, offset fArray
mov dx, 0001
mov [bx], dx
; Store the first fibonacci numbers in the array...
add bx, 2
mov dx, 0002
mov [bx], dx
; Store the remaining fibonacci numbers in the array...
mov cx, 13
Fibonacci:
; Add the last two fibonacci numbers
mov dx, [bx-2]
add dx, [bx] ; The sum of the numbers is on dx
add bx, 2 ; increment the array index
mov [bx], dx ; Append the new fibonacci number on the array
loop Fibonacci
;return control to DOS...
mov ah,4Ch
int 21h
main endp
end main
I just don't get these codes.. I tried my very best to understand these codes but I think I just lack experience on this language..
Can someone please explain these codes to me?
Thanks in advance!
=)
Fibonacci:
mov dx, [bx-2]
add dx, [bx]
add bx, 2
mov [bx], dx
loop Fibonacci
I used emu8086 for this program..
Any help will be appreciated!
Title Fibonacci series
; Fibonacci series
;
; Write a program that generates the first 15 integers
; of the Fibonacci series {1,2,3,5,8,...}. Beginning with
; the third element, each number is the sum of the previous
; two numbers. Store the numbers in an array.
.model small
.stack 100h
.data
fArray dw 15 dup(?)
.code
main proc
mov ax,@data
mov ds,ax
; Store the first fibonacci numbers in the array...
mov bx, offset fArray
mov dx, 0001
mov [bx], dx
; Store the first fibonacci numbers in the array...
add bx, 2
mov dx, 0002
mov [bx], dx
; Store the remaining fibonacci numbers in the array...
mov cx, 13
Fibonacci:
; Add the last two fibonacci numbers
mov dx, [bx-2]
add dx, [bx] ; The sum of the numbers is on dx
add bx, 2 ; increment the array index
mov [bx], dx ; Append the new fibonacci number on the array
loop Fibonacci
;return control to DOS...
mov ah,4Ch
int 21h
main endp
end main
I just don't get these codes.. I tried my very best to understand these codes but I think I just lack experience on this language..
Can someone please explain these codes to me?
Thanks in advance!
=)
Fibonacci:
mov dx, [bx-2]
add dx, [bx]
add bx, 2
mov [bx], dx
loop Fibonacci
Last edited by acidpaul; Feb 29th, 2008 at 12:23 pm.
![]() |
Similar Threads
Other Threads in the Assembly Forum
- Previous Thread: C to Mips translation help!
- Next Thread: Need Some Help In Debugging
Views: 976 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for Assembly
3d 68hc11 6811 80386 :( adress array asm assembler assembly boot bootloader buffer compression cursor debug directory division docs dos draw emulator endtask error exceptions file int10h integer intel interrupt interrupts language loop newbie nohau osdevelopment print program range read remainder shape string text theory tsr x86





