From 9a74d202d3b0ffe860b9e765548aea9643aeb84b Mon Sep 17 00:00:00 2001 From: Dylan Lloyd Date: Sun, 14 Oct 2012 14:14:05 -0400 Subject: [PATCH 1/1] init --- hello.asm | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 hello.asm diff --git a/hello.asm b/hello.asm new file mode 100644 index 0000000..7e5d8c1 --- /dev/null +++ b/hello.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 eax, byte [done] ; Pad value of done to one byte and put in eax + cmp eax,1 ; Compare eax with 1 + 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 + mov edx,helloLen ; Prepare arg 3, string length, no deref. b/c constant + int 80h ; Call the kernel +; + +myFirstASMLabel: + mov eax,1 ; The system call for exit (sys_exit) + mov ebx,0 ; Exit with return code of 0 (no error) + int 80h + -- 2.30.2