Created
March 16, 2015 22:23
-
-
Save giuscri/43d44085c6b299682ead 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
;; lovelace.asm | |
segment .data | |
prompt db "Type in your name: ", 0 | |
buffer times 42 dd 0 | |
printerformat db "Hello %s", 10, 0 | |
scannerformat db "%s", 0 | |
segment .text | |
global main | |
extern printf | |
extern scanf | |
main: | |
;; Make room for local variables ... | |
enter 4, 0 | |
;; Push ebx on the stack, following C calling conventions ... | |
push dword ebx | |
;; Initialize ptr [ebp-4] as the address of buffer ... | |
mov dword [ebp-4], buffer | |
;; Call printf prompting the user for her name ... | |
push dword prompt | |
call printf | |
add esp, 4 | |
;; Call scanf such to get her name ... | |
push dword [ebp-4] | |
push dword scannerformat | |
call scanf | |
add esp, 8 | |
;; Call printf saying hello to her ... | |
push dword [ebp-4] | |
push dword printerformat | |
call printf | |
add esp, 8 | |
;; Restore the value of ebx ... | |
pop ebx | |
;; Free the room made 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