Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sed \
- `#########################################################` \
- `###### Rename statements to their Nasm equivalents ######` \
- -e 's|\.string|db|g' `# .string lines are essentially combination bytes ` \
- -e 's|\.byte|db|g' `# .byte data is just... a byte ` \
- -e 's|\.long|dd|g' `# .long data is double ` \
- -e 's|\.zero|resb|g' `# gcc puts .zero lines where a byte should be reserved - not sure ` \
- -e 's|\.align|align|g' `# align works the same way in gcc and nasm ` \
- -e 's|\.L|L|g' `# Labels in gcc,s intel syntax start with .L - remove the dot for simplicity ` \
- -e 's|main|_start|g' `# If we are going to use ld for linking, _start should be the entry point ` \
- `###################################`\
- `###### Pointer modifications ######`\
- -e 's|PTR ||g' `# Pointers in nasm dont need the word PTR` \
- -e 's|OFFSET FLAT:|dword |g' `# Nasm doesnt understand flat pointers. They are same as double ptrs` \
- `# Pointers in Nasm require [] around them `\
- `# For example, convert `\
- `# ....QWORD player+40 `\
- `# to `\
- `# ....QWORD [player+40] `\
- -e 's|BYTE \([a-zA-Z][a-zA-Z0-9+\._]*\)|BYTE \[\1\]|g' \
- -e 's|QWORD \([a-zA-Z][a-zA-Z0-9+\._]*\)|QWORD \[\1\]|g' \
- -e 's|DWORD \([a-zA-Z][a-zA-Z0-9+\._]*\)|DWORD \[\1\]|g' \
- `###############################################################`\
- `###### Remove lines which contain the following patterns ######`\
- -e '/^\t\.cfi/d' \
- -e '/^\t\.local/d' \
- -e '/^\t\.file/d' \
- -e '/^\t\.intel_syntax/d' \
- -e '/^\t\.globl/d' \
- -e '/^\t\.size/d' \
- -e '/^\t\.type/d' \
- -e '/^\t\.ident/d' \
- -e '/^LFE/d' `# Labels starting with LFE and LFB are not used anywhere in the file. Why bother?`\
- -e '/^LFB/d' \
- -e '/\.note/d' \
- `############################################################` \
- `###### Rename st* registers to their Nasm equivalents ######` \
- -e 's|st(0)|st0|g' \
- -e 's|st(1)|st1|g' \
- -e 's|st(2)|st2|g' \
- -e 's|st(3)|st3|g' \
- -e 's|st(4)|st4|g' \
- -e 's|st(5)|st5|g' \
- -e 's|st(6)|st6|g' \
- -e 's|st,|st0,|g' \
- -e 's|st$|st0|g' \
- `#############################################################`\
- `###### Rename .comm lines to their nasm equivalent ######`\
- `###### For example, convert ######`\
- `###### .comm time_old.15416,8,8 ######`\
- `###### to ######`\
- `###### common ret_val.15417 8:8 ######`\
- -e 's|^\t.comm\(.*\),\([0-9]\),\([0-9]\)|\tcommon \1 \2:\3|g' \
- main.intel-gcc.s > main.nasm
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement