LINK    =sdldz80
AS      =sdasz80
OBJCOPY =sdobjcopy

SDAS_OPT=-plowgff
SDLD_OPT=-mwxiu

OBJECTS =hisoftPascal

OUT     =hisoftPascal_out
AADR    =0x0100

all: $(OUT).bin

diff: all
	hexdump -C hisoftPascal.bin >hisoftPascal_in.txt
	hexdump -C $(OUT).bin >$(OUT).txt
	diff hisoftPascal_in.txt hisoftPascal_out.txt || meld hisoftPascal_in.txt hisoftPascal_out.txt

$(OUT).bin: $(addsuffix .rel,$(addprefix ./,$(OBJECTS)))
	$(LINK) $(SDLD_OPT) -b _CODE=$(AADR) -i $(@:bin=ihx) $^
	$(OBJCOPY) -Iihex -Obinary $(@:bin=ihx) "$@"

%.rel:%.s
	sed 's/[ ]*;commentReference.*//g' hisoftPascal.s >hisoftPascal_out.s
	$(AS) -I./ -plosgff "$@" hisoftPascal_out.s

comment:
	sed 's/[ ]*;commentReference.*//g' hisoftPascal.s >hisoftPascal_out.s

clean:
	rm -rf *.ihx *.rel *.rst *.lst *.map *.sym
	rm -rf hisoftPascal_out.txt hisoftPascal_in.txt hisoftPascal_out.bin

	
