Skip to content

Commit

Permalink
Update to 1.1
Browse files Browse the repository at this point in the history
* reorganize CPU system
* add more minx macros
* make pmdis use runtime CPU disasm info straight from the cpu folder
* add -c flag to pmas
* reduce dependency on pmas.h (not good enough, see dummy stuff)
  • Loading branch information
logicplace committed Sep 26, 2022
1 parent f426f98 commit 3b8c1fc
Show file tree
Hide file tree
Showing 34 changed files with 2,099 additions and 3,631 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__pycache__
*.pyc
cpu/pm
cpu/pm.s

obj
build
Expand Down
49 changes: 30 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
####
#### build_common_pm.py works on Python 2.7+ so the version that ships with
#### your linux install should be good enough.
PMAS_VERSION := 1.0
PMAS_VERSION := 1.1

.PHONY: help
help:
Expand Down Expand Up @@ -52,13 +52,14 @@ DEPFILES := $(SOURCES:src/%.cpp=obj/%.d)
NODEPS := clean

# Build flags
INCLUDES := -Isrc -Icpu/pm
INCLUDES := -Isrc
CXXFLAGS := -Wall $(INCLUDES) -DVERSION="\"$(PMAS_VERSION)\""
LDFLAGS := $(INCLUDES)

ifeq ($(OS),Windows_NT)
tPMAS := pmas.exe
tPMDIS := pmdis.exe
tPARSEMINDX := parsemindx.exe
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
BUNDLE := releases/pmas-windows-x64.zip
else
Expand All @@ -67,6 +68,7 @@ endif
else
tPMAS := pmas
tPMDIS := pmdis
tPARSEMINDX := parsemindx
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
BUNDLE := releases/pmas-windows-x64.zip
else
Expand All @@ -87,11 +89,6 @@ endif
endif

# Generate dependecies
## Generate an objects list from the g++ -MM export based on which header files have cpp files
define getobjs =
$(patsubst src/%.h,obj/%.o,$(filter $(SOURCES:%.cpp=%.h),$(shell [ -f obj/$(1).d ] && sed -e 's/^[^:]*://' obj/$(1).d)))
endef

## Do g++ -MM exports and make object deps rules
ifeq (,$(filter $(MAKECMDGOALS),$(NODEPS)))
-include $(DEPFILES)
Expand Down Expand Up @@ -121,13 +118,24 @@ bundle: releasetest $(BUNDLE)
##############################################################################
#### Executables ####
##############################################################################
$(tPMAS):: obj/pmas.d
$(tPMAS):: obj/stack.o $(call getobjs,pmas)
$(LD) $(LDFLAGS) -o $@ $(filter %.o,$+)
EVAL_O = obj/eval.o obj/stack.o obj/misc.o obj/symbol.o $(TMPLABEL_O) obj/valuetype.o
INSTRUCTION_O = obj/instruction.o $(MEM_O) $(EVAL_O)
MACROLIST_O = obj/macrolist.o obj/misc.o # $(SYMBOL_O)
MEM_O = obj/mem.o obj/misc.o
STACK_O = obj/stack.o obj/misc.o $(VALUETYPE_O)
SYMBOL_O = obj/symbol.o $(MACROLIST_O) $(EVAL_O) # $(VALUETYPE_O)
TMPLABEL_O = obj/tmplabel.o obj/misc.o
VALUETYPE_O = obj/valuetype.o $(EVAL_O)

$(tPMAS): obj/pmas.o $(MACROLIST_O) $(INSTRUCTION_O)
$(LD) $(LDFLAGS) -o $@ $(filter %.o,$^)

$(tPMDIS): obj/pmdis.o
@echo $+
$(LD) $(LDFLAGS) -o $@ $(filter %.o,$+)
$(tPMDIS): obj/pmdis.o $(INSTRUCTION_O)
$(LD) $(LDFLAGS) -o $@ $(filter %.o,$^)

# Isn't needed anymore but...
$(tPARSEMINDX): obj/parsemindx.o $(INSTRUCTION_O)
$(LD) $(LDFLAGS) -o $@ $(filter %.o,$^)

obj/%.d: src/%.cpp
@mkdir obj 2>/dev/null | true
Expand All @@ -137,6 +145,9 @@ obj/%.o: src/%.cpp
@mkdir obj 2>/dev/null | true
$(CXX) $(CXXFLAGS) -c -o $@ $<

cpu/pm.s: cpu/s1c88/s1c88.s
$(PY) build_common_pm.py

##############################################################################
#### Building release rules ####
##############################################################################
Expand All @@ -146,7 +157,7 @@ releases/pmas-%.zip: build
releases/pmas-%.tar.gz: build
cd $< && tar -czf ../$@ *

build: $(COPYME)
build: cpu/pm.s $(COPYME)
@echo 'If this fails, update the changelog'
grep $(PMAS_VERSION) README.md
-mkdir $@
Expand All @@ -160,12 +171,12 @@ TESTFILESS1C88 := test/test-reference.s $(wildcard test/s1c88/*.s)
TESTFILESR16 := $(wildcard test/r16/*.s)

# Test suites
.PHONY: test-all $(addprefix test-,$(patsubst cpu/%,%,$(wildcard cpu/*)))
.PHONY: test-all test-pm $(addprefix test-,$(patsubst cpu/%,%,$(wildcard cpu/*)))

test-all: test-nested.min test-r16 test-pm
test-all: test/test-nested.min test-r16 test-pm

test-pm: CPU = pm
test-pm: test-minx test-s1c88
test-pm: cpu/pm.s test-minx test-s1c88

test-minx: $(tPMAS) $(TESTFILESMINX:.s=.min)
$(COMPARE) test/minx/opcodes1.min test/minx/opcodes2.min
Expand All @@ -183,8 +194,8 @@ test/%.min: test/%.s $(tPMAS)
$(PMAS) $< $@ $(@:.min=.sym)

define test_template =
test/$(1)/%.min: test/$(1)/%.s $(tPMAS)
$(PMAS) -c $(CPU:all=$(1)) $< $@ $(@:.min=.sym)
test/$(1)/%.min: test/$(1)/%.s $$(tPMAS) cpu/$(1)/$(1).s
$$(PMAS) -c $$(CPU:all=$(1)) $$< $$@ $$(@:.min=.sym)
endef

$(foreach cpu,$(CPUS),$(eval $(call test_template,$(cpu))))
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ Taken from [here](https://www.darkfader.net/info/)

Old versions can be accessed [here](https://sourceforge.net/projects/pmas/files/).

### v1.1 - 2022-09-26

* Reorganized source code and Makefile
* pmdis now supports CPU selection at runtime
* minx CPU supports a lot more now (which it should've before!!)


### v1.0 - 2022-09-20

* Add support for S1C88 ops
Expand Down
4 changes: 2 additions & 2 deletions build_common_pm.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ def fmt_cmd(mnemonic, params):
try: os.mkdir("cpu/pm")
except: pass

with open("cpu/s1c88/pm.s", "rt") as fin, open("cpu/pm/pm.s", "wt") as fout:
with open("cpu/s1c88/s1c88.s", "rt") as fin, open("cpu/pm.s", "wt") as fout:
out = []
fout.write("; Automatically generated file, edit cpu/s1c88/pm.s instead\n")
fout.write("; Automatically generated file, edit cpu/s1c88/s1c88.s instead\n")
for line in fin:
if line.startswith(".instruction"):
assert line[13] == '"'
Expand Down
1 change: 1 addition & 0 deletions cpu/cpu.s
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
.set FLAG_CONT 0x01 ; can continue to next location
.set FLAG_REL 0x02 ; PC relative (SHOULD THIS BE HERE?)
.set FLAG_EXTENDED 0x04 ; only used in parsemindx
.set FLAG_DISASMTO 0x10 ; use this version for disasm if there are multiple macros which asm to this

.set MAX_ARGS 4

Expand Down
Loading

0 comments on commit 3b8c1fc

Please sign in to comment.