Last active
August 29, 2015 14:17
-
-
Save giuscri/44a2b002133972d173a1 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.asm | |
segment .data | |
format db "%d + %d = %d", 10, 0 | |
segment .text | |
global main | |
extern printf | |
main: | |
;; Make room for three local variables ... | |
enter 12, 0 | |
;; Push ebx on the stack, following C calling conventions ... | |
push ebx | |
;; Inizialize a [ebp-4] to 42 ... | |
mov dword [ebp-4], 42 | |
;; Initialize b [ebp-8] to 24 ... | |
mov dword [ebp-8], 24 | |
;; Initalize c [ebp-12] to 0 ... | |
mov dword [ebp-12], 0 | |
;; Increment the value of c [ebp-12] to a [ebp-4] ... | |
mov ebx, [ebp-4] | |
add [ebp-12], ebx | |
;; Increment the value of c [ebp-12] to b [ebp-8] ... | |
mov ebx, [ebp-8] | |
add [ebp-12], ebx | |
;; Print out the result of the computation, using the format above ... | |
push dword [ebp-12] | |
push dword [ebp-8] | |
push dword [ebp-4] | |
push dword format | |
call printf | |
add esp, 16 | |
;; Restore the value of ebx ... | |
pop ebx | |
;; Free room for the local variables ... | |
leave | |
;; Return back ... | |
ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment