This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# CRAP3a for Darwin-i386-MachO | |
# Copyright (C) 2013, Dan Glastonbury <[email protected]> | |
# | |
# Labels are 4 chars. Labels are stores in a symbol table stored in | |
# BSS section. The labels form a list of 32-bit label name and address | |
# pairs. | |
# | |
# Errors are signaled by return code: | |
# 1: Syntax Error |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# CRAP2b for Darwin-i386-MachO | |
# Copyright (C) 2013, Dan Glastonbury <[email protected]> | |
# | |
# Uses BSS section for data storage and labels for call & jmp targets | |
# | |
# Based on: | |
# HEX2b and HEX2c for Linux-i386-ELF | |
# Copyright (C) 2001, Edmund GRIMLEY EVANS <[email protected]> | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# CRAP2a for Darwin-i386-MachO | |
# Copyright (C) 2013, Dan Glastonbury <[email protected]> | |
# | |
# Uses BSS section for data storage. | |
# | |
# Based on: | |
# HEX2a for Linux-i386-ELF | |
# Copyright (C) 2001, Edmund GRIMLEY EVANS <[email protected]> | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# CRAP1 for Darwin-i386-MachO | |
# Copyright (C) 2013, Dan Glastonbury <[email protected]> | |
# | |
# Based on: | |
# HEX1 for Linux-i386-ELF | |
# Copyright (C) 2001, Edmund GRIMLEY EVANS <[email protected]> | |
# | |
# _mach_header: # struct mach_header |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%define STDIN_FILENO 0 | |
%define STDOUT_FILENO 1 | |
%define SYS_EXIT 1 | |
%define SYS_READ 3 | |
%define SYS_WRITE 4 | |
USE32 | |
ORG 0x1000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
drop: | |
pop %ebx | |
pop %eax | |
jmp *%ebx | |
swap: | |
pop %ebx | |
pop %eax | |
pop %ecx | |
push %eax |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ryg's version | |
# getchar: | |
31 C0 # xor eax, eax | |
50 # push eax | |
89 E1 # mov ecx, esp | |
50 # push eax | |
51 # push ecx | |
50 # push eax | |
50 # push eax | |
B0 03 # mov al, 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# getchar: # read a byte from stdin | |
6a 00 # push 0 | |
89 e0 # mov eax, esp | |
6a 01 # push 1 | |
50 # push eax | |
6a 00 # push STDIN_FILENO | |
6a 03 # push SYS_READ | |
58 # pop eax | |
50 # push eax | |
cd 80 # int 80h |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; ryg's version | |
getchar: ;read a byte from stdin | |
xor eax, eax | |
push eax | |
mov ecx, esp | |
push eax | |
push ecx | |
push eax | |
push eax | |
mov al, SYS_READ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getchar: ; read a byte from stdin | |
push 0 | |
mov eax, esp | |
push 1 | |
push eax | |
push STDIN_FILENO | |
push SYS_READ | |
pop eax | |
push eax | |
int 80h |