9086/common.mk

51 lines
1.3 KiB
Makefile

.PRECIOUS:${BOOT_CODE}
QUIET=1
ifeq "${QUIET}" "1"
QUIET_AS = @echo ' AS '$@;
QUIET_VVP = @echo ' VVP '$@;
QUIET_IVERILOG = @echo ' IVERILOG '$@;
QUIET_CLEAN = @printf ' CLEAN %s\n' $1;
Q = @
MAKEOPTS=--no-print-directory
.SILENT:
else
Q =
endif
.PHONY: run wave disas
run: $(subst .txt,.run,${BOOT_CODE})
wave: $(subst .txt,.wave,${BOOT_CODE})
disas: $(subst .txt,.disas,${BOOT_CODE})
# Assembling code
%.txt:%.bin
${Q}dd if=/dev/zero bs=1 count=16384 of="$(subst .bin,.stage,$<)" status=none
${Q}dd if="$<" of="$(subst .bin,.stage,$<)" conv=notrunc,nocreat status=none
${Q}xxd -ps -c 2 "$(subst .bin,.stage,$<)" > "$@"
${Q}rm "$(subst .bin,.stage,$<)"
%.bin:%.asm
${QUIET_AS}
${Q}as86 -0 "$<" -b "$@"
# Running simulation
%.lx2 %.memdump: %.txt ${SYSTEM_VVP}
${QUIET_VVP}
${Q}vvp "${SYSTEM_VVP}" -lxt2 +BOOT_CODE="$<" +WAVEFORM="$(subst .txt,.lx2,$<)" +MEMDUMP="$(subst .txt,.memdumptxt,$<)"
${Q}grep -v '^//' "$(subst .txt,.memdumptxt,$<)" | xxd -ps -c 2 -r > "$(subst .txt,.memdump,$<)"
${Q}rm "$(subst .txt,.memdumptxt,$<)"
%.run: %.txt ${SYSTEM_VVP}
${QUIET_VVP}
${Q}vvp "${SYSTEM_VVP}" +BOOT_CODE="$<"
%.disas: %.bin
objdump -D -b binary -m i8086 $^ | less
# Tools
%.wave : %.lx2
gtkwave "$<" "${GTKWSAVE}"