2
0
Fork 0

Added files

This commit is contained in:
Willem Cazander 2020-12-23 17:23:19 +01:00
parent 4c491648e0
commit 490137aa33
3 changed files with 113 additions and 1 deletions

38
.gitignore vendored Normal file
View file

@ -0,0 +1,38 @@
syntax: glob
# Project ignores
bin
bin/**
# Makefile ignores
Makelocal.mk
# File ignores
*.log
*.bak
*.zip
*.tar.gz
# Ignore some eclipse files
.settings
.project
# Ignore visual studio files
.vs/
# Ignore intellij files
*.iml
.idea
# Ignore netbeans directory
nbproject
# Ignore mac finder files
.DS_Store
# Ignore windows files.
Thumbs.db
Desktop.ini
# Ignore kde dolphin files
.directory

View file

@ -1,3 +1,5 @@
# convasm
Collection of regex's to convert old asm to sdcc asm.
Collection of regex's to convert old asm to sdcc asm.
Warning it still convert a few cases wrongly, sorry.

72
convasm.sh Executable file
View file

@ -0,0 +1,72 @@
#!/bin/bash
#
# NOTE: this is not 100% done
# maybe better as single script with buildin tests for all cases.
#
#TODO FIX
# LD L,(IX+2) -> LD L,2(IX) but was LD L,(IX)
# COLOR_PRESENTS:
# .db #0x00,
# Start with useless cat and lots of perl kittens to print with.
cat $1 |\
# fix org
perl -ne 's/(?<=\s)ORG(?=\s)/; org/gi; print;' |\
# fix equ
perl -ne 's/(?<=\s)EQU(?=\s)/.equ/gi; print;' |\
perl -ne 's/(?<=\w):(?=\s*.equ)/ /gi; print;' |\
# fix include
perl -ne 's/(?<=\s)INCLUDE(?=\s)/.include/gi; print;' |\
perl -ne 's/(?<=\.include\s\s)\w+.\w+/\L"$&"/gi; print;' |\
perl -ne 's/(?<=\.include\s\s\")(\w+.)xsm(?=\")/$1asm/gi; print;' |\
# fix data types
perl -ne 's/(?<=[\s|:])DB|DEFB(?=\s)/.db/gi; print;' |\
perl -ne 's/(?<=[\s|:])DW|DEFW(?=\s)/.dw/gi; print;' |\
perl -ne 's/(?<=[\s|:])DS|DEFS(?=\s)/.ds/gi; print;' |\
perl -ne 's/(?<=[\s|:])DEFM(?=\s+")/.str/gi; print;' |\
perl -ne 's/(?<=\.)DB(?=\s+")/str/gi; print;' |\
# LD (IX+#09),5 of SET 4,(IX+#0B)
perl -ne 's/(\(\s?I[XY]\s?\+\s?)\#(?=[\d\w]+)/$1&H/gi; print;' |\
# fix data notation
perl -ne 's/&H(?=[\d\w])/0x/gi; print;' |\
perl -ne 's/&B(?=\d)/0b/gi; print;' |\
# TXT_Z80: DB "Z80",&H0A,&H0D,&H1D
perl -ne 's/(?<=\")\s*,\s*(?=[\s\d])/\n\t\t.db\t\t/gi; print;' |\
# LD HL,0FCCAh
perl -ne 's/0([\w\d]{2,4})h/0x$1/gi; print;' |\
# AND 03h
perl -ne 's/(?<=AND\s)([\w\d]{2,4})h/0x$1/gi; print;' |\
# Fix missing : after labels note: igm!!
perl -ne 's/(^\w+)($|\s)(?!.*equ)/$1:\t/igm; print;' |\
# Add constant prefix
perl -ne 's/(?<=CP\s)[-\d\"]/#$&/gi; print;' |\
perl -ne 's/(?<=AND\s)[-\d\"]/#$&/gi; print;' |\
perl -ne 's/(?<=OR\s)[-\d\"]/#$&/gi; print;' |\
perl -ne 's/(?<=ADD\s)[-\d\"]/#$&/gi; print;' |\
perl -ne 's/(?<=SUB\s)[-\d\"]/#$&/gi; print;' |\
perl -ne 's/(?<=ADD\s\w,)[-\d\"]/#$&/gi; print;' |\
perl -ne 's/(?<=ADC\s\w,)[-\d\"]/#$&/gi; print;' |\
perl -ne 's/(?<=LD\s\w,)[-\d\"]/#$&/gi; print;' |\
perl -ne 's/(?<=LD\s\w\w,)[-\d\"]/#$&/gi; print;' |\
perl -ne 's/(?<=LD\s\w,)0x\d/#$&/gi; print;' |\
perl -ne 's/(?<=LD\s\w\w,)0x\d/#$&/gi; print;' |\
perl -ne 's/(?<=LD\s\w,)0b\d/#$&/gi; print;' |\
perl -ne 's/(?<=LD\s\w\w,)0b\d/#$&/gi; print;' |\
perl -ne 's/(?<=LD\s\(..\),)[-\d\"\+]/#$&/gi; print;' |\
perl -ne 's/(?<=LD\s\(..\+\d\),)[-\d\"\+]/#$&/gi; print;' |\
perl -ne 's/(?<=LD\s\(..\+\d\d\),)[-\d\"\+]/#$&/gi; print;' |\
perl -ne 's/(?<=LD\s\(..\+0x\d\),)[-\d\"\+]/#$&/gi; print;' |\
perl -ne 's/(?<=LD\s\(..\+0x\d\d\),)[-\d\"\+]/#$&/gi; print;' |\
# Add label prefix 8 bit
perl -ne 's/(?<=LD\s\w,)\w{2,}/#$&/gi; print;' |\
perl -ne 's/(?<=LD\s\w,)\w_\w+/#$&/gi; print;' |\
# Add label prefix 16 bit
perl -ne 's/(?<=LD\s\w\w,)\w{2,}/#$&/gi; print;' |\
perl -ne 's/(?<=LD\s\(\w\w\),)\w{2,}/#$&/gi; print;' |\
# fix ix/iy offset notation
perl -ne 's/\(\s?IX\s?\+\s?([0x\d\w]+)\s?\)/$1(IX)/gi; print;' |\
perl -ne 's/\(\s?IY\s?\+\s?([0x\d\w]+)\s?\)/$1(IY)/gi; print;'