Skip to content

Instantly share code, notes, and snippets.

@jdiez17
Created November 1, 2012 21:01
Show Gist options
  • Save jdiez17/3996515 to your computer and use it in GitHub Desktop.
Save jdiez17/3996515 to your computer and use it in GitHub Desktop.
DT_PATH=$(HOME)/DCPUToolchain
CC=$(DT_PATH)/dtcc/dtcc
ASM=$(DT_PATH)/dtasm/dtasm
LD=$(DT_PATH)/dtld/dtld
EMU=$(DT_PATH)/dtemu/dtemu
STDLIB=$(DT_PATH)/stdlib-c/stdlib.dlib16
KERNEL=$(DT_PATH)/kernel/stubsys.dkrn16
JUMP=$(DT_PATH)/kernel/stubsys.djmp16
INCLUDE=${DT_PATH}/stdlib-c/include
TARGET=main
all: $(TARGET).dcpu16
run: $(TARGET).dcpu16
# Emulate the final output
$(EMU) $(TARGET).dcpu16
$(TARGET).oa: $(TARGET).c
# -v means verbose, -o is the output file, -I sets the include path
$(CC) -v -o $@ -I $(INCLUDE) $(TARGET).c
$(TARGET).o: $(TARGET).oa
# -i generates intermediate code, -o is the output file, -s generates symbol files
$(ASM) -i -o$@ $(TARGET).oa -s $@.s
$(TARGET).dcpu16: $(TARGET).o
# link the intermediate file with stubsys, the minimal kernel
$(LD) -k $(KERNEL) --jumplist $(JUMP) -o $@ $(STDLIB) $(TARGET).o
clean:
rm -fv *.bin *.asm *.o *.oa *.cdasm *.dcpu16 *.dasm16 pp.*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment