diff options
author | Matt Turner <mattst88@gmail.com> | 2008-01-02 03:55:22 +0000 |
---|---|---|
committer | Matt Turner <mattst88@gmail.com> | 2008-01-02 03:55:22 +0000 |
commit | afda6f12adf869ca9b35eae215b2aa83b87de39a (patch) | |
tree | 038c98253ec35dc56aed1d5ab7abde8deb99833e /abs.asm |
Initial import.
git-svn-id: svn://mattst88.com/svn/x86_64-assembly/trunk@1 a323887f-d61c-418c-83a5-2e06a2a01087
Diffstat (limited to 'abs.asm')
-rw-r--r-- | abs.asm | 44 |
1 files changed, 44 insertions, 0 deletions
@@ -0,0 +1,44 @@ +format ELF64 + +extrn printf +extrn puts +extrn scanf +public main + +section '.text' executable + +main: + push rbp + mov rbp,rsp + + mov edi,prompt + call puts + + sub rsp,16 + + mov rsi,rsp + mov edi,readint + xor eax,eax + call scanf + + mov rax,[rsp] + + add rsp,16 + + cqo + xor rax,rdx + sub rax,rdx + + mov rsi,rax + mov edi,msg + xor eax,eax + call printf + + leave + ret + +section '.data' writable align 16 + +msg db "Absolute value is %lu",0xA,0 +prompt db "Enter a negative integer.",0 +readint db "%ld",0 |