From a39d4ce01d07032e98a128c9f9df72a3fdd23972 Mon Sep 17 00:00:00 2001 From: Dylan Lloyd Date: Sun, 14 Oct 2012 16:36:02 -0400 Subject: [PATCH] added 64bit equivalent --- hello.asm => hello32.asm | 2 +- hello64.asm | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) rename hello.asm => hello32.asm (99%) create mode 100644 hello64.asm diff --git a/hello.asm b/hello32.asm similarity index 99% rename from hello.asm rename to hello32.asm index 7e5d8c1..b6178a0 100644 --- a/hello.asm +++ b/hello32.asm @@ -12,7 +12,7 @@ _start: jg myFirstASMLabel ; Jump if greater than to myFirstASMLabel mov byte [done], 1 - + mov eax,4 ; Put magic # for system call sys_write into eax mov ebx,1 ; Prepare arg 1 of sys_write, 1 - file descriptor of stdo mov ecx,hello ; Prepare arg 2, reference to string hello diff --git a/hello64.asm b/hello64.asm new file mode 100644 index 0000000..32296f5 --- /dev/null +++ b/hello64.asm @@ -0,0 +1,27 @@ +section .data + hello: db 'Hello, world.',10 ; declare initialized string with linefeed char + helloLen: equ $-hello ; declare and init. constant + done: db 0 + +section .text + global _start + +_start: + movzx rax, byte [done] ; Pad value of done to one byte and put in rax + cmp rax,1 ; Compare rax with 1 + jg myFirstASMLabel ; Jump if greater than to myFirstASMLabel + + mov byte [done], 1 + + mov rax,1 ; Put magic # for system call sys_write into rax + mov rdi,1 ; Prepare arg 1 of sys_write, 1 - file descriptor of stdo + mov rsi,hello ; Prepare arg 2, reference to string hello + mov rdx,helloLen ; Prepare arg 3, string length, no deref. b/c constant + syscall ; Call the kernel +; + +myFirstASMLabel: + mov rax,60 ; The system call for exit (sys_exit) + mov rdi,0 ; Exit with return code of 0 (no error) + syscall + -- 2.30.2