Skip to content

Instantly share code, notes, and snippets.

@giuscri
Created March 16, 2015 20:53
Show Gist options
  • Save giuscri/329042eb515da55316dc to your computer and use it in GitHub Desktop.
Save giuscri/329042eb515da55316dc to your computer and use it in GitHub Desktop.
;; 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