CSC231 No-no! and Be-Careful! situations

From dftwiki3
Revision as of 08:15, 10 November 2010 by Thiebaut (talk | contribs) (Created page with '--~~~~ ---- =What's wrong with the following code?= <code><pre> ;------------------------------------------------------------------ ; function that pushes several results in t…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

--D. Thiebaut 13:15, 10 November 2010 (UTC)


What's wrong with the following code?


;------------------------------------------------------------------
; function that pushes several results in the stack
;------------------------------------------------------------------
compute:	
        pushad
        mov	ecx, N		;loop some number of times                                                              
        mov	eax, data1	;get some data                                                                          
        mov	ebx, data2
.for:   call	doSomething	;operate on eax and ebx                                                                 
                                ; on return, eax contains                                                               
                                ; result we're interested in                                                            
        push	eax		;save result in stack                                                                   
        loop	.for

;;; we're done                                                                                                          
        popad
        ret

What's tricky about the following code?