osx/hello.asm
changeset 171 c6e0af68825a
parent 168 dfb60716880c
child 172 43ae72f88d06
equal deleted inserted replaced
170:5a11538e7bc8 171:c6e0af68825a
       
     1 global _entryPoint
       
     2 
       
     3 %define  SYSCALL_EXIT 0x1
       
     4 %define SYSCALL_WRITE 0x4
       
     5 
     1 section .data
     6 section .data
     2     msg db "Hello World!", 0x0a ; Die Nachricht
     7     msg db "Hello World!", 0x0a ; Die Nachricht
     3     len equ $-msg
     8     len equ $-msg
     4 
     9 
     5 section .text
    10 section .text
     6 global entryPoint
       
     7 
    11 
     8 call entryPoint
    12 call _entryPoint
     9 jmp asm_exit
    13 jmp asm_exit
    10 
    14 
    11 entryPoint:
    15 _entryPoint:
    12     push dword len      ;; Länge des Texts
    16     push dword len      ;; Länge des Texts
    13     push dword msg      ;; Der Text
    17     push dword msg      ;; Der Text
    14     push dword 1        ;; stdout
    18     push dword 1        ;; stdout
    15 
    19 
    16 	;; call write
    20 	;; call write
    17     mov eax, 0x4
    21     mov eax, SYSCALL_WRITE
    18     sub esp, 4
    22     sub esp, 4
    19     int 0x80
    23     int 0x80
    20 
    24 
    21     ;; clean up 3 pushes
    25     ;; clean up 3 pushes
    22     add esp, 16
    26     add esp, 16
    23 
       
    24 	ret
       
    25 	
    27 	
    26 asm_exit:	
    28 asm_exit:
    27     mov eax, 0x1
    29 	push dword 0
       
    30     mov eax, SYSCALL_EXIT
    28 	sub esp, 4
    31 	sub esp, 4
    29     int 0x80
    32     int 0x80
    30 
       
    31 	add esp, 4