Created
March 16, 2015 20:53
-
-
Save giuscri/329042eb515da55316dc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; ada_sum.asm | |
segment .text | |
global ada_sum | |
ada_sum: | |
;; Make room for the local variable sum ... | |
enter 4, 0 | |
;; Push ebx on the stack, following C calling convention ... | |
push ebx | |
;; Initialize the value of sum [ebp-4] to 0 ... | |
mov dword [ebp-4], 0 | |
;; Add the value of a [ebp+12] to the value of sum [ebp-4] ... | |
mov ebx, [ebp+12] | |
add [ebp-4], ebx | |
;; Add the value of b [ebp+8] to the value of sum [ebp-4] ... | |
mov ebx, [ebp+8] | |
add [ebp-4], ebx | |
;; Move the value of sum [ebp-4] into eax ... | |
mov eax, [ebp-4] | |
;; Pop ebx out of the stack ... | |
pop ebx | |
;; Pop sum out of the stack ... | |
leave | |
;; Then return to the caller ... | |
ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment