Current location: Hot Scripts Forums » Programming Languages » Other Languages » Help with Assembly program


Help with Assembly program

Reply
  #1 (permalink)  
Old 10-10-08, 01:52 AM
buffcubby buffcubby is offline
New Member
 
Join Date: Oct 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Help with Assembly program

I'm trying to do the Fibonacci sequence by using a stack here and I don't think its actually writing to the stack because when I comment the push out it still displays numbers ...any suggestions would be greatly appreciated



Code:
.data 
count DWORD 12			; Number of loops to perform
val1 DWORD ?
string byte (" "),0		; use for the space between numbers

.code
main PROC
mov ecx, count			; loop counter
mov eax, 0
mov val1, 1


ADDLOOP: ; First time loop:
mov ebx, val1
mov val1, eax ; save current eax for our next addition
add eax, ebx
push eax

; below here works
call DisplaySum
loop ADDLOOP			; If not done, perform loop again (ecx is automatically decremented)
exit
main ENDP

DisplaySum PROC
call WriteInt			; Display number
mov edx, OFFSET string	; add space between the numbers
call WriteString
ret
DisplaySum ENDP
 
END main

Last edited by Nico; 10-10-08 at 02:27 AM. Reason: Wrappers.
Reply With Quote
  #2 (permalink)  
Old 12-26-08, 03:19 PM
Phattytatty Phattytatty is offline
New Member
 
Join Date: Dec 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
well its not that its not working. When you push the eax register on the stack it does go on the stack but you dont step on the eax register. so you will see the same numbers when u comment the push line out try this... try pushing eax on the register then sub eax,eax (clear the register) and you will see the number will disapear then after you test that out after clearing the register pop eax off teh stack and you will see the info was saved on the stack. Just becauase you push something on the stack it dont mean it will clear the register the reason for pushing something on the stack is to sorta save the info and then you use the register for other stuff then pop eax off teh stack to restore the info from before...

(it looks like your using an irvine library so me thinking that try this code....)

push eax
call dumpregs (you will see that eax is still the same)
sub eax,eax
call dumpregs (you will see that eax is 0)
pop eax
call dumpregs (you will see that eax is returned to the same before.)

If this dont work or you dont have the irvine library leave another message and ill answer asap
Reply With Quote
  #3 (permalink)  
Old 03-11-09, 02:58 AM
furthersorion furthersorion is offline
Newbie Coder
 
Join Date: Mar 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
That's an interesting experiment you're doing buff, could you tell me how it goes?
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Assembly - restarting a program ICE16 Other Languages 2 12-26-08 03:29 PM
what is the assembly program of multiplication table? theakrista Other Languages 1 10-01-08 08:34 AM
need advice on how i should go about writing this program burning_red_phoenix Everything Java 0 11-06-05 05:46 PM


All times are GMT -5. The time now is 03:44 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.