943,827 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Unsolved
  • Views: 1472
  • Assembly RSS
Feb 29th, 2008
0

Can someone help me undestand these codes?

Expand Post »
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
Last edited by acidpaul; Feb 29th, 2008 at 12:23 pm.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
acidpaul is offline Offline
1 posts
since Feb 2008
Mar 1st, 2008
0

Re: Can someone help me undestand these codes?

Visualization is probably one of the best methods to comprehension. Invoke DEBUG and then step through the program one instruction at a time and just observe what's going on. OLLYBUG is even better as it lets you visualize registers memory and opcodes in a cleaner fashion
Reputation Points: 47
Solved Threads: 17
Posting Whiz in Training
Tight_Coder_Ex is offline Offline
215 posts
since Feb 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Assembly Forum Timeline: C to Mips translation help!
Next Thread in Assembly Forum Timeline: Need Some Help In Debugging





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC