osx/hello.asm
author Markus Bröker<broeker.markus@googlemail.com>
Sat, 21 Oct 2017 13:45:05 +0200
changeset 171 c6e0af68825a
parent 168 dfb60716880c
child 172 43ae72f88d06
permissions -rw-r--r--
Entrypoint and RET fixed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
171
c6e0af68825a Entrypoint and RET fixed
Markus Bröker<broeker.markus@googlemail.com>
parents: 168
diff changeset
     1
global _entryPoint
c6e0af68825a Entrypoint and RET fixed
Markus Bröker<broeker.markus@googlemail.com>
parents: 168
diff changeset
     2
c6e0af68825a Entrypoint and RET fixed
Markus Bröker<broeker.markus@googlemail.com>
parents: 168
diff changeset
     3
%define  SYSCALL_EXIT 0x1
c6e0af68825a Entrypoint and RET fixed
Markus Bröker<broeker.markus@googlemail.com>
parents: 168
diff changeset
     4
%define SYSCALL_WRITE 0x4
c6e0af68825a Entrypoint and RET fixed
Markus Bröker<broeker.markus@googlemail.com>
parents: 168
diff changeset
     5
168
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
     6
section .data
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
     7
    msg db "Hello World!", 0x0a ; Die Nachricht
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
     8
    len equ $-msg
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
     9
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    10
section .text
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    11
171
c6e0af68825a Entrypoint and RET fixed
Markus Bröker<broeker.markus@googlemail.com>
parents: 168
diff changeset
    12
call _entryPoint
168
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    13
jmp asm_exit
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    14
171
c6e0af68825a Entrypoint and RET fixed
Markus Bröker<broeker.markus@googlemail.com>
parents: 168
diff changeset
    15
_entryPoint:
168
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    16
    push dword len      ;; Länge des Texts
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    17
    push dword msg      ;; Der Text
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    18
    push dword 1        ;; stdout
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    19
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    20
	;; call write
171
c6e0af68825a Entrypoint and RET fixed
Markus Bröker<broeker.markus@googlemail.com>
parents: 168
diff changeset
    21
    mov eax, SYSCALL_WRITE
168
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    22
    sub esp, 4
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    23
    int 0x80
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    24
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    25
    ;; clean up 3 pushes
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    26
    add esp, 16
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    27
	
171
c6e0af68825a Entrypoint and RET fixed
Markus Bröker<broeker.markus@googlemail.com>
parents: 168
diff changeset
    28
asm_exit:
c6e0af68825a Entrypoint and RET fixed
Markus Bröker<broeker.markus@googlemail.com>
parents: 168
diff changeset
    29
	push dword 0
c6e0af68825a Entrypoint and RET fixed
Markus Bröker<broeker.markus@googlemail.com>
parents: 168
diff changeset
    30
    mov eax, SYSCALL_EXIT
168
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    31
	sub esp, 4
dfb60716880c Broken OSX Demo added
Markus Bröker<broeker.markus@googlemail.com>
parents:
diff changeset
    32
    int 0x80