Skip to content

Instantly share code, notes, and snippets.

@mouseroot
Created August 13, 2013 23:40
Show Gist options
  • Select an option

  • Save mouseroot/6226770 to your computer and use it in GitHub Desktop.

Select an option

Save mouseroot/6226770 to your computer and use it in GitHub Desktop.
Asm stuffs
#!/bin/bash
app="load"
rm *.o
nasm -f elf $app.asm
gcc -o $app $app.o
extern printf
extern scanf
global main
%macro restore 1
add esp, 4 * %1
%endmacro
section .data
hi: db "Hello world",10,0
buffer: dw 0
scanstr: db "%s\n",0
section .text
main:
push dword hi
call printf
push dword buffer
push dword scanstr
call scanf
push dword hi
call printf
;Restore the stack
restore 4
;add esp,4 * 4
mov eax,0
ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment