Skip to content

Instantly share code, notes, and snippets.

@ncatlin
Created September 24, 2016 11:50
Show Gist options
  • Save ncatlin/b839012c3a364deaec08d6af401fe7b0 to your computer and use it in GitHub Desktop.
Save ncatlin/b839012c3a364deaec08d6af401fe7b0 to your computer and use it in GitHub Desktop.
hello world assembly code used for graph layout illustration
global _main
extern _GetStdHandle@4
extern _WriteFile@20
extern _ExitProcess@4
section .text
_main:
; DWORD bytes;
mov ebp, esp
sub esp, 4
jmp stuff
writestd:
; hStdOut = GetstdHandle( STD_OUTPUT_HANDLE)
push -11
call _GetStdHandle@4
mov ebx, eax
; WriteFile( hstdOut, message, length(message), &bytes, 0);
push 0
lea eax, [ebp-4]
push eax
push (message_end - message)
push message
push ebx
call _WriteFile@20
ret
stuff:
call writestd
call writestd
; ExitProcess(0)
push 0
call _ExitProcess@4
; never here
hlt
message:
db 'Hello, World', 10
message_end:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment