Created
August 17, 2016 05:59
-
-
Save alanduan/6a494dc24b1016ac244db8bd1062014c 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
; yasm -o %:r.o % -f elf32 -g stabs | |
; ld -m elf_i386 %:r.o -o %:r -lc --dynamic-linker /lib/ld-linux.so.2 | |
section .data | |
dividend dq 0xdeadbeef12 | |
divisor dd 0x100 | |
quotient dd 0 | |
remainder dd 0 | |
section .text | |
extern printf | |
extern exit | |
global _start | |
_start: | |
mov eax, dword [dividend] | |
mov edx, dword [dividend + 4] | |
div dword [divisor] | |
mov dword [quotient], eax | |
mov dword [remainder], edx | |
push dword [remainder] | |
push dword [quotient] | |
push msg | |
call printf | |
push 0 | |
call exit | |
section .rodata | |
msg db "quotient = %x, remainder = %x",10,0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment