COAL Chapter No 5 (Week 7)
COAL Chapter No 5 (Week 7)
Computer Organization
& Assembly Language
INSTRUCTOR
OUTLINE
•Stack Operations
• New values are added to the top of the stack, and existing
values are removed from the top.
Parameters help to make procedures flexible because parameter values can change
at runtime
;---------------------------------------------------------
SumOf PROC
;
; Calculates and returns the sum of three 32-bit integers.
; Receives: EAX, EBX, ECX, the three integers. May be
; signed or unsigned.
; Returns: EAX = sum, and the status flags (Carry,
; Overflow, etc.) are changed.
; Requires: nothing
;---------------------------------------------------------
add eax,ebx
add eax,ecx
ret
SumOf ENDP
NESTED PROCEDURE CALLS
main PROC
.
. By the time Sub3
is called, the
call Sub1
exit
main ENDP stack contains all
Sub1 PROC three return
.
. addresses:
call Sub2
ret
Sub1 ENDP