| @@ -26,16 +26,13 @@ ifdef DEBUG | |||||
| MODE = debug | MODE = debug | ||||
| endif | endif | ||||
| .PHONY: all clean test | |||||
| .PHONY: all clean test test-all test-z80 test-asm test-dasm | |||||
| all: $(BNRY) | all: $(BNRY) | ||||
| clean: | clean: | ||||
| $(RM) $(BUILD) $(PROGRAM) $(PROGRAM)$(DEVEXT) | $(RM) $(BUILD) $(PROGRAM) $(PROGRAM)$(DEVEXT) | ||||
| test: | |||||
| @echo "not implemented yet" | |||||
| $(DIRS): | $(DIRS): | ||||
| $(MKDIR) $@ | $(MKDIR) $@ | ||||
| @@ -48,3 +45,17 @@ $(BUILD)/$(MODE)/%.o: %.c | |||||
| $(CC) $(FLAGS) $(CFLAGS) -MMD -MP -c $< -o $@ | $(CC) $(FLAGS) $(CFLAGS) -MMD -MP -c $< -o $@ | ||||
| -include $(DEPS) | -include $(DEPS) | ||||
| test: test-all test-z80 test-asm test-dasm | |||||
| test-all: | |||||
| @echo "running all tests" | |||||
| test-z80: | |||||
| @echo "running Z80 CPU tests" | |||||
| test-asm: | |||||
| @echo "running assembler tests" | |||||
| test-dasm: | |||||
| @echo "running disassembler tests" | |||||
| @@ -0,0 +1,47 @@ | |||||
| ;; Copyright (C) 2014-2015 Ben Kurtovic <ben.kurtovic@gmail.com> | |||||
| ;; Released under the terms of the MIT License. See LICENSE for details. | |||||
| ; ----- CRATER UNIT TESTING SUITE --------------------------------------------- | |||||
| ; This file contains test cases for basic arithmetic operations on registers, | |||||
| ; without involving memory or control flow. | |||||
| .include "_header.asm" | |||||
| test: | |||||
| ld a, 0 | |||||
| ld b, 0 | |||||
| ld c, 0 | |||||
| ld d, 0 | |||||
| ld e, 0 | |||||
| ld h, 0 | |||||
| ld l, 0 | |||||
| emu rassert(a=$00, b=$00, c=$00, d=$00, e=$00, h=$00, l=$00) | |||||
| inc a | |||||
| emu rassert(a=$01, b=$00, c=$00, d=$00, e=$00, h=$00, l=$00) | |||||
| emu fassert(s=0, z=0, f5=0, h=0, f3=0, pv=0, n=0) | |||||
| inc b | |||||
| emu rassert(a=$01, b=$01, c=$00, d=$00, e=$00, h=$00, l=$00) | |||||
| emu fassert(s=0, z=0, f5=0, h=0, f3=0, pv=0, n=0) | |||||
| inc c | |||||
| emu rassert(a=$01, b=$01, c=$01, d=$00, e=$00, h=$00, l=$00) | |||||
| emu fassert(s=0, z=0, f5=0, h=0, f3=0, pv=0, n=0) | |||||
| inc d | |||||
| emu rassert(a=$01, b=$01, c=$01, d=$01, e=$00, h=$00, l=$00) | |||||
| emu fassert(s=0, z=0, f5=0, h=0, f3=0, pv=0, n=0) | |||||
| inc e | |||||
| emu rassert(a=$01, b=$01, c=$01, d=$01, e=$01, h=$00, l=$00) | |||||
| emu fassert(s=0, z=0, f5=0, h=0, f3=0, pv=0, n=0) | |||||
| inc h | |||||
| emu rassert(a=$01, b=$01, c=$01, d=$01, e=$01, h=$01, l=$00) | |||||
| emu fassert(s=0, z=0, f5=0, h=0, f3=0, pv=0, n=0) | |||||
| inc l | |||||
| emu rassert(a=$01, b=$01, c=$01, d=$01, e=$01, h=$01, l=$01) | |||||
| emu fassert(s=0, z=0, f5=0, h=0, f3=0, pv=0, n=0) | |||||
| @@ -0,0 +1,30 @@ | |||||
| ;; Copyright (C) 2014-2015 Ben Kurtovic <ben.kurtovic@gmail.com> | |||||
| ;; Released under the terms of the MIT License. See LICENSE for details. | |||||
| ; ----- CRATER UNIT TESTING SUITE --------------------------------------------- | |||||
| ; This file contains basic header code for standard assembly files in the unit | |||||
| ; testing suite. It sets values for the ROM header, and contains basic test | |||||
| ; runner code. | |||||
| .optimizer off ; Generate faithful rather than fast code | |||||
| .rom_size auto ; Smallest possible ROM size >= 32 KB | |||||
| .rom_header auto ; Standard header location (0x7FF0) | |||||
| .rom_checksum off ; Don't write a ROM checksum to the header | |||||
| .rom_product 0 ; Zero product code | |||||
| .rom_version 0 ; Zero version number | |||||
| .rom_region "GG Export" ; Common region code for Western ROMs | |||||
| .rom_declsize auto ; Set declared size to actual ROM size | |||||
| ; Main routine (execution begins here) | |||||
| .org $0000 | |||||
| main: | |||||
| di ; Disable maskable interrupts | |||||
| call test ; Run test subroutine | |||||
| emu except(done) ; Signal to emulator that test is done | |||||
| ; Non-maskable interrupt handler (should not happen; raise an exception) | |||||
| .org $0066 | |||||
| nmi_handler: | |||||
| emu except(nmi) ; Signal to emulator that an NMI was received | |||||
| @@ -0,0 +1,4 @@ | |||||
| /* Copyright (C) 2014-2015 Ben Kurtovic <ben.kurtovic@gmail.com> | |||||
| Released under the terms of the MIT License. See LICENSE for details. */ | |||||
| // ... | |||||