diff --git a/src/common_post_48k_spectrum.asm b/src/common_post_48k_spectrum.asm new file mode 100644 index 0000000..d6047d3 --- /dev/null +++ b/src/common_post_48k_spectrum.asm @@ -0,0 +1,43 @@ +; +; 48k spectrum specific definitions here. +; + +printinit: ld a,2 + jp 0x1601 ; CHAN-OPEN + +printchr: push iy + ld iy,0x5c3a ; ERR-NR + push de + push bc + exx + ei + ; out (0xff),a + rst 0x10 + di + exx + pop bc + pop de + pop iy + ret + +ok_print: call print ; print success + db 23,32-2,1,"OK",13,0 + ret + +failed_print: + call print + db 23,32-6,1,"FAILED",13 + db "CRC:",0 + + call printcrc + + call print + db " Expected:",0 + + ex de,hl + call printcrc + + ld a,13 + jp printchr + +; EOF ; diff --git a/src/common_pre_48k_spectrum.asm b/src/common_pre_48k_spectrum.asm new file mode 100644 index 0000000..bcffea2 --- /dev/null +++ b/src/common_pre_48k_spectrum.asm @@ -0,0 +1,9 @@ +; +; 48k spectrum specific definitions here. +; + +io_compatible equ 1 + + org 0x8000 + +; EOF ; diff --git a/src/common_z80ccf.asm b/src/common_z80ccf.asm new file mode 100644 index 0000000..1d904fa --- /dev/null +++ b/src/common_z80ccf.asm @@ -0,0 +1,18 @@ +; Z80 test - post CCF version. +; +; Copyright (C) 2012-2023 Patrik Rak (patrik@raxoft.cz) +; +; This source code is released under the MIT license, see included license.txt. + + macro testname + db "CCF" + endm + +maskflags equ 0 +onlyflags equ 1 +postccf equ 1 +memptr equ 0 + + include main.asm + +; EOF ; diff --git a/src/common_z80doc.asm b/src/common_z80doc.asm new file mode 100644 index 0000000..7c4ce94 --- /dev/null +++ b/src/common_z80doc.asm @@ -0,0 +1,18 @@ +; Z80 test - officially documented flags version. +; +; Copyright (C) 2012-2023 Patrik Rak (patrik@raxoft.cz) +; +; This source code is released under the MIT license, see included license.txt. + + macro testname + db "doc" + endm + +maskflags equ 1 +onlyflags equ 0 +postccf equ 0 +memptr equ 0 + + include main.asm + +; EOF ; diff --git a/src/common_z80docflags.asm b/src/common_z80docflags.asm new file mode 100644 index 0000000..0a8b061 --- /dev/null +++ b/src/common_z80docflags.asm @@ -0,0 +1,18 @@ +; Z80 test - officially documented flags, flags only version. +; +; Copyright (C) 2012-2023 Patrik Rak (patrik@raxoft.cz) +; +; This source code is released under the MIT license, see included license.txt. + + macro testname + db "doc flags" + endm + +maskflags equ 1 +onlyflags equ 1 +postccf equ 0 +memptr equ 0 + + include main.asm + +; EOF ; diff --git a/src/common_z80flags.asm b/src/common_z80flags.asm new file mode 100644 index 0000000..9034e9b --- /dev/null +++ b/src/common_z80flags.asm @@ -0,0 +1,18 @@ +; Z80 test - flags only version. +; +; Copyright (C) 2012-2023 Patrik Rak (patrik@raxoft.cz) +; +; This source code is released under the MIT license, see included license.txt. + + macro testname + db "flags" + endm + +maskflags equ 0 +onlyflags equ 1 +postccf equ 0 +memptr equ 0 + + include main.asm + +; EOF ; diff --git a/src/common_z80full.asm b/src/common_z80full.asm new file mode 100644 index 0000000..219f991 --- /dev/null +++ b/src/common_z80full.asm @@ -0,0 +1,18 @@ +; Z80 test - the full version. +; +; Copyright (C) 2012-2023 Patrik Rak (patrik@raxoft.cz) +; +; This source code is released under the MIT license, see included license.txt. + + macro testname + db "full" + endm + +maskflags equ 0 +onlyflags equ 0 +postccf equ 0 +memptr equ 0 + + include main.asm + +; EOF ; diff --git a/src/common_z80memptr.asm b/src/common_z80memptr.asm new file mode 100644 index 0000000..b576ad1 --- /dev/null +++ b/src/common_z80memptr.asm @@ -0,0 +1,21 @@ +; Z80 test - MEMPTR version. +; +; However note that the current set of tests was not designed to stress test MEMPTR +; particularly, so it doesn't detect much - I may eventually add such specific tests later. +; +; Copyright (C) 2012-2023 Patrik Rak (patrik@raxoft.cz) +; +; This source code is released under the MIT license, see included license.txt. + + macro testname + db "MEMPTR" + endm + +maskflags equ 0 +onlyflags equ 1 +postccf equ 0 +memptr equ 1 + + include main.asm + +; EOF ; diff --git a/src/idea.asm b/src/idea.asm index c995a12..3928b46 100644 --- a/src/idea.asm +++ b/src/idea.asm @@ -42,9 +42,11 @@ test: ld (.spptr+1),sp inc de call .copy - + +if io_compatible ld a,0x07 ; Make sure we get 0 out (0xfe),a ; on MIC bit when doing IN. +endif ld a,0xa9 ; Set I,R,AF' to known values. ld i,a @@ -264,7 +266,8 @@ test: ld (.spptr+1),sp ; If this moves from 0x8800, all tests which use this address ; will need to have their CRCs updated, so don't move it. - align 256 + align 0x800 + assert data == 0x8800 data .regs ds datasize-4 .regstop @@ -280,12 +283,15 @@ data jp test.continue ; This entire workspace must be kept within single 256 byte page. - + assert (start_of_corework >> 8) == ((end_of_corework - 1) >> 8) +start_of_corework: vector ds vecsize counter ds vecsize countmask ds vecsize shifter ds 1+vecsize shiftend shiftmask ds 1+vecsize +end_of_corework: + ; EOF ; diff --git a/src/main.asm b/src/main.asm index 6fde005..74e429c 100644 --- a/src/main.asm +++ b/src/main.asm @@ -4,8 +4,6 @@ ; ; This source code is released under the MIT license, see included license.txt. - org 0x8000 - main: di ; disable interrupts push iy ; preserve stuff needed by BASIC exx @@ -63,7 +61,13 @@ main: di ; disable interrupts jr .done .ok call print ; print success message - db "all tests passed.",13,0 + db "all ", 0 + + ld a,c + call printdeca + + call print + db " tests passed.",13,0 .done pop hl ; return to BASIC exx @@ -93,12 +97,15 @@ main: di ; disable interrupts .failcheck or b ; some prior failure means do the test jr nz,.pass - +if !io_compatible +.incheck +endif call print ; print that the test was skipped db 23,32-7,1,"Skipped",13,0 ret ; return success +if io_compatible .incheck xor a ; expected IN value means do the test in a,(0xfe) cp 0xbf ; %10111111 - just MIC bit is zero @@ -118,6 +125,7 @@ main: di ; disable interrupts inc a ; return failure ret +endif .pass ld hl,1+3*vecsize ; store expected CRC address add hl,de @@ -142,28 +150,9 @@ main: di ; disable interrupts ld b,4 ; compare CRCs call .cmp - jr nz,.mismatch ; check for mismatch - - call print ; print success - db 23,32-2,1,"OK",13,0 - - ret ; return success - -.mismatch call print ; print mismatched and expected CRC - db 23,32-6,1,"FAILED",13 - db "CRC:",0 - - call printcrc - - call print - db " Expected:",0 - - ex de,hl - call printcrc - - ld a,13 - call printchr + jp z,ok_print ; print ok and retunrn +.mismatch call failed_print ; print mismatched and expected CRC ld a,1 ; return failure ret @@ -179,11 +168,10 @@ main: di ; disable interrupts pop hl ret - include print.asm - align 256 include idea.asm include tests.asm + include print.asm ; EOF ; diff --git a/src/msx/bload_r/common_msx_bload_r.asm b/src/msx/bload_r/common_msx_bload_r.asm new file mode 100644 index 0000000..f7de121 --- /dev/null +++ b/src/msx/bload_r/common_msx_bload_r.asm @@ -0,0 +1,25 @@ +; +; This file is part of z80test MSX version. +; Copyright (C) 2025 Suzumizaki-Kimitaka(鈴見咲 君高) +; This source code is released under the MIT license, see included license.txt. +; + org 0x8040 - 7 + + db 0xFE ; MSX-BASIC BLOAD header + dw bload_loop ; The lowest address to load. + dw last_ptr - 1 ; The highest address to load. + dw bload_loop ; The address to auto-run. +bload_loop: + call common_pre_msx + call main + + call print + db "Press any character key to re-run.",0 + call waitkeyandput + jr bload_loop + +msx_main_starts equ 0x8100 +for_bload_r equ 1 +for_msx_dos equ 0 + +; EOF ; diff --git a/src/msx/bload_r/make_bin_for_bload_r.bat b/src/msx/bload_r/make_bin_for_bload_r.bat new file mode 100644 index 0000000..145fb98 --- /dev/null +++ b/src/msx/bload_r/make_bin_for_bload_r.bat @@ -0,0 +1,8 @@ +sjasm z80ccf.asm z80ccf.bin +sjasm z80doc.asm z80doc.bin +sjasm z80docflags.asm z80docfl.bin +sjasm z80flags.asm z80flags.bin +sjasm z80full.asm z80full.bin +sjasm z80memptr.asm z80mempt.bin +sjasm z80ccfscr.asm z80ccfsc.bin +pause diff --git a/src/msx/bload_r/z80ccf.asm b/src/msx/bload_r/z80ccf.asm new file mode 100644 index 0000000..d4d6f5c --- /dev/null +++ b/src/msx/bload_r/z80ccf.asm @@ -0,0 +1,11 @@ +; +; This file is part of z80test MSX version. +; Copyright (C) 2025 Suzumizaki-Kimitaka(鈴見咲 君高) +; This source code is released under the MIT license, see included license.txt. +; + include common_msx_bload_r.asm + include ../common_pre_msx.asm + include ../../common_z80ccf.asm + include ../common_post_msx.asm + +; EOF ; diff --git a/src/msx/bload_r/z80ccfscr.asm b/src/msx/bload_r/z80ccfscr.asm new file mode 100644 index 0000000..82d0fe9 --- /dev/null +++ b/src/msx/bload_r/z80ccfscr.asm @@ -0,0 +1,30 @@ +; Z80 test - monitor random behavior of bits 5 and 3 after CCF. +; +; Copyright (C) 2023 Patrik Rak (patrik@raxoft.cz) +; +; This file is part of z80test MSX version. +; Copyright (C) 2025 Suzumizaki-Kimitaka(鈴見咲 君高) +; +; This source code is released under the MIT license, see included license.txt. + + +WORK equ 09000H + + macro call_bios addr + call addr + endm + + macro read_bios addr + ld a,(addr) + endm + + org 0x8080 - 7 + + db 0xFE ; MSX-BASIC BLOAD header + dw main ; The lowest address to load. + dw end_of_all_code - 1 ; The highest address to load. + dw start_check ; The address to auto-run. + + include ../common_z80ccfscr.asm + +; EOF ; diff --git a/src/msx/bload_r/z80doc.asm b/src/msx/bload_r/z80doc.asm new file mode 100644 index 0000000..09c4c46 --- /dev/null +++ b/src/msx/bload_r/z80doc.asm @@ -0,0 +1,11 @@ +; +; This file is part of z80test MSX version. +; Copyright (C) 2025 Suzumizaki-Kimitaka(鈴見咲 君高) +; This source code is released under the MIT license, see included license.txt. +; + include common_msx_bload_r.asm + include ../common_pre_msx.asm + include ../../common_z80doc.asm + include ../common_post_msx.asm + +; EOF ; diff --git a/src/msx/bload_r/z80docflags.asm b/src/msx/bload_r/z80docflags.asm new file mode 100644 index 0000000..0cdd777 --- /dev/null +++ b/src/msx/bload_r/z80docflags.asm @@ -0,0 +1,11 @@ +; +; This file is part of z80test MSX version. +; Copyright (C) 2025 Suzumizaki-Kimitaka(鈴見咲 君高) +; This source code is released under the MIT license, see included license.txt. +; + include common_msx_bload_r.asm + include ../common_pre_msx.asm + include ../../common_z80docflags.asm + include ../common_post_msx.asm + +; EOF ; diff --git a/src/msx/bload_r/z80flags.asm b/src/msx/bload_r/z80flags.asm new file mode 100644 index 0000000..886845a --- /dev/null +++ b/src/msx/bload_r/z80flags.asm @@ -0,0 +1,11 @@ +; +; This file is part of z80test MSX version. +; Copyright (C) 2025 Suzumizaki-Kimitaka(鈴見咲 君高) +; This source code is released under the MIT license, see included license.txt. +; + include common_msx_bload_r.asm + include ../common_pre_msx.asm + include ../../common_z80flags.asm + include ../common_post_msx.asm + +; EOF ; diff --git a/src/msx/bload_r/z80full.asm b/src/msx/bload_r/z80full.asm new file mode 100644 index 0000000..ab6f980 --- /dev/null +++ b/src/msx/bload_r/z80full.asm @@ -0,0 +1,11 @@ +; +; This file is part of z80test MSX version. +; Copyright (C) 2025 Suzumizaki-Kimitaka(鈴見咲 君高) +; This source code is released under the MIT license, see included license.txt. +; + include common_msx_bload_r.asm + include ../common_pre_msx.asm + include ../../common_z80full.asm + include ../common_post_msx.asm + +; EOF ; diff --git a/src/msx/bload_r/z80memptr.asm b/src/msx/bload_r/z80memptr.asm new file mode 100644 index 0000000..0868163 --- /dev/null +++ b/src/msx/bload_r/z80memptr.asm @@ -0,0 +1,11 @@ +; +; This file is part of z80test MSX version. +; Copyright (C) 2025 Suzumizaki-Kimitaka(鈴見咲 君高) +; This source code is released under the MIT license, see included license.txt. +; + include common_msx_bload_r.asm + include ../common_pre_msx.asm + include ../../common_z80memptr.asm + include ../common_post_msx.asm + +; EOF ; diff --git a/src/msx/com_for_dos/common_msxdos_com.asm b/src/msx/com_for_dos/common_msxdos_com.asm new file mode 100644 index 0000000..a821379 --- /dev/null +++ b/src/msx/com_for_dos/common_msxdos_com.asm @@ -0,0 +1,28 @@ +; +; This file is part of z80test MSX version. +; Copyright (C) 2025 Suzumizaki-Kimitaka(鈴見咲 君高) +; This source code is released under the MIT license, see included license.txt. +; +msx_main_starts equ 0x8000 +for_bload_r equ 0 +for_msx_dos equ 1 + + org 0x0100 + + ld hl, main_starts + ld de, main + ld bc, last_ptr - main + ldir +loop_on_msxdos: + call common_pre_msx + call main + + call print + db "Re-run to press y or exit otherwise.",0 + call waitkeyandput + cp 'y' + jr z, loop_on_msxdos + ld c, 0 + jp 0005H + +; EOF ; diff --git a/src/msx/com_for_dos/make_msxdos_com_file.bat b/src/msx/com_for_dos/make_msxdos_com_file.bat new file mode 100644 index 0000000..824e868 --- /dev/null +++ b/src/msx/com_for_dos/make_msxdos_com_file.bat @@ -0,0 +1,8 @@ +sjasm z80ccf.asm z80ccf.com +sjasm z80doc.asm z80doc.com +sjasm z80docflags.asm z80docfl.com +sjasm z80flags.asm z80flags.com +sjasm z80full.asm z80full.com +sjasm z80memptr.asm z80mempt.com +sjasm z80ccfscr.asm z80ccfsc.com +pause diff --git a/src/msx/com_for_dos/z80ccf.asm b/src/msx/com_for_dos/z80ccf.asm new file mode 100644 index 0000000..0d78523 --- /dev/null +++ b/src/msx/com_for_dos/z80ccf.asm @@ -0,0 +1,11 @@ +; +; This file is part of z80test MSX version. +; Copyright (C) 2025 Suzumizaki-Kimitaka(鈴見咲 君高) +; This source code is released under the MIT license, see included license.txt. +; + include common_msxdos_com.asm + include ../common_pre_msx.asm + include ../../common_z80ccf.asm + include ../common_post_msx.asm + +; EOF ; diff --git a/src/msx/com_for_dos/z80ccfscr.asm b/src/msx/com_for_dos/z80ccfscr.asm new file mode 100644 index 0000000..09e619b --- /dev/null +++ b/src/msx/com_for_dos/z80ccfscr.asm @@ -0,0 +1,36 @@ +; Z80 test - monitor random behavior of bits 5 and 3 after CCF. +; +; Copyright (C) 2023 Patrik Rak (patrik@raxoft.cz) +; +; This file is part of z80test MSX version. +; Copyright (C) 2025 Suzumizaki-Kimitaka(鈴見咲 君高) +; +; This source code is released under the MIT license, see included license.txt. + + org 0x100 + +WORK equ 09000H + + macro call_bios addr + ld iy,(EXPTBL - 1) + ld ix,addr + call CALSLT + endm + + macro read_bios addr + ld a,(EXPTBL) + ld hl,addr + call RDSLT + endm + + ld hl,main_from + ld de,main + ld bc,end_of_all_code - main + ldir + jp start_check + +main_from: + org 0x8000 + include ../common_z80ccfscr.asm + +; EOF ; diff --git a/src/msx/com_for_dos/z80doc.asm b/src/msx/com_for_dos/z80doc.asm new file mode 100644 index 0000000..95aebe0 --- /dev/null +++ b/src/msx/com_for_dos/z80doc.asm @@ -0,0 +1,11 @@ +; +; This file is part of z80test MSX version. +; Copyright (C) 2025 Suzumizaki-Kimitaka(鈴見咲 君高) +; This source code is released under the MIT license, see included license.txt. +; + include common_msxdos_com.asm + include ../common_pre_msx.asm + include ../../common_z80doc.asm + include ../common_post_msx.asm + +; EOF ; diff --git a/src/msx/com_for_dos/z80docflags.asm b/src/msx/com_for_dos/z80docflags.asm new file mode 100644 index 0000000..ed4b77c --- /dev/null +++ b/src/msx/com_for_dos/z80docflags.asm @@ -0,0 +1,11 @@ +; +; This file is part of z80test MSX version. +; Copyright (C) 2025 Suzumizaki-Kimitaka(鈴見咲 君高) +; This source code is released under the MIT license, see included license.txt. +; + include common_msxdos_com.asm + include ../common_pre_msx.asm + include ../../common_z80docflags.asm + include ../common_post_msx.asm + +; EOF ; diff --git a/src/msx/com_for_dos/z80flags.asm b/src/msx/com_for_dos/z80flags.asm new file mode 100644 index 0000000..a3fc133 --- /dev/null +++ b/src/msx/com_for_dos/z80flags.asm @@ -0,0 +1,11 @@ +; +; This file is part of z80test MSX version. +; Copyright (C) 2025 Suzumizaki-Kimitaka(鈴見咲 君高) +; This source code is released under the MIT license, see included license.txt. +; + include common_msxdos_com.asm + include ../common_pre_msx.asm + include ../../common_z80flags.asm + include ../common_post_msx.asm + +; EOF ; diff --git a/src/msx/com_for_dos/z80full.asm b/src/msx/com_for_dos/z80full.asm new file mode 100644 index 0000000..b86206a --- /dev/null +++ b/src/msx/com_for_dos/z80full.asm @@ -0,0 +1,11 @@ +; +; This file is part of z80test MSX version. +; Copyright (C) 2025 Suzumizaki-Kimitaka(鈴見咲 君高) +; This source code is released under the MIT license, see included license.txt. +; + include common_msxdos_com.asm + include ../common_pre_msx.asm + include ../../common_z80full.asm + include ../common_post_msx.asm + +; EOF ; diff --git a/src/msx/com_for_dos/z80memptr.asm b/src/msx/com_for_dos/z80memptr.asm new file mode 100644 index 0000000..c7860a8 --- /dev/null +++ b/src/msx/com_for_dos/z80memptr.asm @@ -0,0 +1,11 @@ +; +; This file is part of z80test MSX version. +; Copyright (C) 2025 Suzumizaki-Kimitaka(鈴見咲 君高) +; This source code is released under the MIT license, see included license.txt. +; + include common_msxdos_com.asm + include ../common_pre_msx.asm + include ../../common_z80memptr.asm + include ../common_post_msx.asm + +; EOF ; diff --git a/src/msx/common_post_msx.asm b/src/msx/common_post_msx.asm new file mode 100644 index 0000000..9126e32 --- /dev/null +++ b/src/msx/common_post_msx.asm @@ -0,0 +1,137 @@ +; +; This file is part of z80test MSX version. +; Copyright (C) 2025 Suzumizaki-Kimitaka(鈴見咲 君高) +; This source code is released under the MIT license, see included license.txt. +; + + ; The values to assert should be defined before check. + assert msx_main_starts <= main + +default_ok_msg: + db " OK",13,0 +default_skip_msg: + db " Skipped",13,0 +erase_last_line: + db 0x1B, 'M', 0 +ok_msg_ptr: + dw default_ok_msg +skip_msg_ptr: + dw default_skip_msg + +printchr: + push hl + push bc + ld b,a + ld hl, .skipcnt + ld a,(hl) + dec a + jr z,.next_printchr + ld (hl),a +.end_printchr + ld a,b + pop bc + pop hl + ret +.next_printchr + ld a,23 + cp b + jr nz,.next2_printchr + ; Skip 48K Spectrum escape sequence like. + ld (hl),3 + ld a,' ' + call .call_chput + jr .end_printchr +.next2_printchr + ld a,b + pop bc + pop hl + call .call_chput + cp 13 + ret nz + ld a,10 + call .call_chput + ld a,13 + ret +.call_chput + +if for_msx_dos + push ix + push iy + ld ix, CHPUT + ld iy, (EXPTBL - 1) + call CALSLT + pop iy + pop ix +else + call CHPUT +endif + di ; The test must be run under DI. + ret +.skipcnt db 1 ; to skip 48K Spectrum escape sequence like. + +waitkeyandput: +if for_msx_dos + ld ix, KILBUF + ld iy, (EXPTBL - 1) + call CALSLT + ld ix, CHGET + ld iy, (EXPTBL - 1) + call CALSLT +else + call KILBUF + call CHGET +endif + push af + call printchr + call print + db 13, 13, 0 + pop af +printinit: + ret + +ok_print: + ld hl,(ok_msg_ptr) + jp printhl + +failed_print: + push hl + call print + db " FAILED",0 + + ld a, (LINL40) + cp 41 + jr nc, .in_mode_80 + call print + db 13,32,0 + jr .start_show_crc +.in_mode_80 + ld hl, (CSRY) ; l := (CSRY) + ld h, 36 ; h := x position +if for_msx_dos + push ix + push iy + ld ix, POSIT + ld iy, (EXPTBL - 1) + call CALSLT + pop iy + pop ix +else + call POSIT +endif +.start_show_crc + call print + db "CRC: ",0 + pop hl + call printcrc + call print + db " Expected: ",0 + + ex de,hl + call printcrc + + ld a,13 + jp printchr +last_ptr: + + +; EOF ; diff --git a/src/msx/common_pre_msx.asm b/src/msx/common_pre_msx.asm new file mode 100644 index 0000000..2f887a2 --- /dev/null +++ b/src/msx/common_pre_msx.asm @@ -0,0 +1,104 @@ +; +; This file is part of z80test MSX version. +; Copyright (C) 2025 Suzumizaki-Kimitaka(鈴見咲 君高) +; This source code is released under the MIT license, see included license.txt. +; +io_compatible equ 0 + +BDOS equ 0005H +RDSLT equ 000CH +CALSLT equ 001CH +ROM_ID equ 002DH +CHGCLR equ 0062H +INITXT equ 006CH +CHGET equ 009FH +CHPUT equ 00A2H +POSIT equ 00C6H +KILBUF equ 0156H +CHGCPU equ 0180H +LINL40 equ 0F3AEH +CSRY equ 0F3DCH +FORCLR equ 0F3E9H +BDRCLR equ 0F3EBH +EXPTBL equ 0FCC1H + +common_pre_msx: + ld hl, 040FH + ld (FORCLR), hl ; FORCLR, BAKCLR + ld a, h + ld (BDRCLR), a +if for_msx_dos + ld ix, CHGCLR + ld iy, (EXPTBL - 1) + call CALSLT +else + call CHGCLR +endif + + +if for_msx_dos + ld a, (EXPTBL) + ld hl, ROM_ID + call RDSLT +else + ld a, (ROM_ID) +endif + and a + ld a, 40 + jr z, .msx1 + add a, a +.msx1 + ld (LINL40), a ; set width on screen 0. +if for_msx_dos + ld ix, INITXT ; set screen 0. + ld iy, (EXPTBL - 1) + call CALSLT +else + call INITXT ; set screen 0. +endif + call print + db "Show failed case only? please type y to yes. ",0 + call waitkeyandput + cp 'y' + ld hl, default_ok_msg + ld de, default_skip_msg + jr nz, .use_default_msg + ld hl, erase_last_line + ld d, h + ld e, l +.use_default_msg + ld (ok_msg_ptr), hl + ld (skip_msg_ptr), de + +if for_msx_dos + ld a, (EXPTBL) + ld hl, ROM_ID + call RDSLT +else + ld a, (ROM_ID) +endif + cp 3 + ret c + call print + db "Run with R800? ",0 + call waitkeyandput + cp 'y' + ld a, 80H ; Z80 (ROM) mode with LED changed + jr nz, .keep_z80 + inc a ; R800 ROM mode with LED changed. +.keep_z80 +if for_msx_dos + ld ix, CHGCPU + ld iy, (EXPTBL - 1) + jp CALSLT ; call CHGCPU and return. +else + jp CHGCPU ; call CHGCPU and return. +endif + + ; note: ifdef doesn't work with sjasm 0.42c. + if for_bload_r + ds msx_main_starts - $, 0 + endif +main_starts: + org msx_main_starts +; EOF ; diff --git a/src/msx/common_z80ccfscr.asm b/src/msx/common_z80ccfscr.asm new file mode 100644 index 0000000..d27a697 --- /dev/null +++ b/src/msx/common_z80ccfscr.asm @@ -0,0 +1,160 @@ +; Z80 test - monitor random behavior of bits 5 and 3 after CCF. +; +; Copyright (C) 2023 Patrik Rak (patrik@raxoft.cz) +; +; This file is part of z80test MSX version. +; Copyright (C) 2025 Suzumizaki-Kimitaka(鈴見咲 君高) +; +; This source code is released under the MIT license, see included license.txt. + +VDP_W equ 7 +ROM_ID equ 002DH +RDSLT equ 000CH +CALSLT equ 001CH +SETWRT equ 0053H +INIGRP equ 0072H +CHGET equ 009FH +CHPUT equ 00A2H +CHGCPU equ 0180H +GRPCOL equ 0F3C9H +CGPBAS equ 0F924H +JIFFY equ 0FC9EH +EXPTBL equ 0FCC1H +COL1 equ 01EH +COL2 equ 0CFH + + assert (WORK & 0xFF) == 0 +main: + call_bios INIGRP + ld hl,(GRPCOL) + call_bios SETWRT + read_bios VDP_W + ld c,a + + ld d,0 +.init_lp1 + ld b,8 + ld a,COL1 +.init_lp2: + out (c), a + djnz .init_lp2 + + ld b,8 + ld a,COL2 +.init_lp3: + out (c), a + djnz .init_lp3 + + dec d + jr nz,.init_lp1 + + ld a,COL1 + out (c), a + ld a,COL2 + out (c), a + +main_loop: + push bc + ld hl,WORK + di ; make sure no interrupt around 'ccf'. + ld a,h + add a,0FH + assert ($ >> 8) == 0x80 + ld d,a +.loop + push hl + pop af ; low byte of WORK is copied to F regstier. + ccf + push af + ei ; make sure to count up JIFFY. + pop bc + ld a,l + xor c + ld (hl),a + inc hl + ld a,d + di ; make sure no interrupt around 'ccf'. + cp h + jp nc,.loop + assert ($ >> 8) == 0x80 + + ; + ; Show result like 48K Spectrum. + ; + ld hl,(CGPBAS) + call_bios SETWRT + pop bc + ei ; make sure to count up JIFFY. + + ld de,0 + ld b,7 +.vram_loop + ld l,e + ld a,d + rra + rr l + rra + rr l + rra + rr l + ld a,e + and b + ld h,a + ld a,d + and 8 + or h + add a,WORK >> 8 + ld h,a + + ld a,(hl) + out (c),a + + inc de + ld a,d + cp 10H + jp c,.vram_loop + + ; + ; Append signal to show program alive. + ; + ld hl,(JIFFY) + out (c),l + nop + out (c),h + + jr main_loop +end_of_main: + +start_check: + read_bios ROM_ID + cp 3 + jp c,main + call print + db "Run with R800? Please type y for yes.",0 + call_bios CHGET + call_bios CHPUT + cp 'y' + ld a,80H + jr nz,.set_cpu_mode + inc a +.set_cpu_mode + call_bios CHGCPU + jp main + +print: + ex (sp),hl +.print_loop + ld a,(hl) + and a + jr z,.print_end + push hl + call_bios CHPUT + pop hl + inc hl + jr .print_loop +.print_end + ex (sp),hl + ret +end_of_all_code: + +; EOF ; diff --git a/src/msx/rom_image/common_msx_rom.asm b/src/msx/rom_image/common_msx_rom.asm new file mode 100644 index 0000000..8028a42 --- /dev/null +++ b/src/msx/rom_image/common_msx_rom.asm @@ -0,0 +1,34 @@ +; +; This file is part of z80test MSX version. +; Copyright (C) 2025 Suzumizaki-Kimitaka(鈴見咲 君高) +; This source code is released under the MIT license, see included license.txt. +; +msx_main_starts equ 0x8000 +for_bload_r equ 0 +for_msx_dos equ 0 + + defpage 0, 4000h, 16384 ; Make ROM file to 16KB. + page 0 + + org 0x4000 + + db "AB" ; MSX ROM identifier + dw cpyndrun ; INIT to jump + dw 0, 0, 0 ; STATEMENT, DEVICE and TEXT are not used. + dw 0, 0, 0 ; reserved to use future MSX system definition. + +cpyndrun: + ld hl, main_starts + ld de, main + ld bc, last_ptr - main + ldir + + call common_pre_msx + call main + + call print + db "Press any character key to reset.",0 + call waitkeyandput + rst 0 + +; EOF ; diff --git a/src/msx/rom_image/make_rom_images.bat b/src/msx/rom_image/make_rom_images.bat new file mode 100644 index 0000000..aad6872 --- /dev/null +++ b/src/msx/rom_image/make_rom_images.bat @@ -0,0 +1,8 @@ +sjasm z80ccf.asm z80ccf.rom +sjasm z80doc.asm z80doc.rom +sjasm z80docflags.asm z80docflags.rom +sjasm z80flags.asm z80flags.rom +sjasm z80full.asm z80full.rom +sjasm z80memptr.asm z80memptr.rom +sjasm z80ccfscr.asm z80ccfscr.rom +pause diff --git a/src/msx/rom_image/z80ccf.asm b/src/msx/rom_image/z80ccf.asm new file mode 100644 index 0000000..340c2f9 --- /dev/null +++ b/src/msx/rom_image/z80ccf.asm @@ -0,0 +1,11 @@ +; +; This file is part of z80test MSX version. +; Copyright (C) 2025 Suzumizaki-Kimitaka(鈴見咲 君高) +; This source code is released under the MIT license, see included license.txt. +; + include common_msx_rom.asm + include ../common_pre_msx.asm + include ../../common_z80ccf.asm + include ../common_post_msx.asm + +; EOF ; diff --git a/src/msx/rom_image/z80ccfscr.asm b/src/msx/rom_image/z80ccfscr.asm new file mode 100644 index 0000000..88f7449 --- /dev/null +++ b/src/msx/rom_image/z80ccfscr.asm @@ -0,0 +1,32 @@ +; Z80 test - monitor random behavior of bits 5 and 3 after CCF. +; +; Copyright (C) 2023 Patrik Rak (patrik@raxoft.cz) +; +; This file is part of z80test MSX version. +; Copyright (C) 2025 Suzumizaki-Kimitaka(鈴見咲 君高) +; +; This source code is released under the MIT license, see included license.txt. + + defpage 0, 8000h, 16384 ; Make ROM file to 16KB. + page 0 + +WORK equ 0C000H + + org 0x8000 + + db "AB" ; MSX ROM identifier + dw start_check ; INIT to jump + dw 0, 0, 0 ; STATEMENT, DEVICE and TEXT are not used. + dw 0, 0, 0 ; reserved to use future MSX system definition. + + macro call_bios addr + call addr + endm + + macro read_bios addr + ld a,(addr) + endm + + include ../common_z80ccfscr.asm + +; EOF ; diff --git a/src/msx/rom_image/z80doc.asm b/src/msx/rom_image/z80doc.asm new file mode 100644 index 0000000..07be02e --- /dev/null +++ b/src/msx/rom_image/z80doc.asm @@ -0,0 +1,11 @@ +; +; This file is part of z80test MSX version. +; Copyright (C) 2025 Suzumizaki-Kimitaka(鈴見咲 君高) +; This source code is released under the MIT license, see included license.txt. +; + include common_msx_rom.asm + include ../common_pre_msx.asm + include ../../common_z80doc.asm + include ../common_post_msx.asm + +; EOF ; diff --git a/src/msx/rom_image/z80docflags.asm b/src/msx/rom_image/z80docflags.asm new file mode 100644 index 0000000..666fba8 --- /dev/null +++ b/src/msx/rom_image/z80docflags.asm @@ -0,0 +1,11 @@ +; +; This file is part of z80test MSX version. +; Copyright (C) 2025 Suzumizaki-Kimitaka(鈴見咲 君高) +; This source code is released under the MIT license, see included license.txt. +; + include common_msx_rom.asm + include ../common_pre_msx.asm + include ../../common_z80docflags.asm + include ../common_post_msx.asm + +; EOF ; diff --git a/src/msx/rom_image/z80flags.asm b/src/msx/rom_image/z80flags.asm new file mode 100644 index 0000000..554f308 --- /dev/null +++ b/src/msx/rom_image/z80flags.asm @@ -0,0 +1,11 @@ +; +; This file is part of z80test MSX version. +; Copyright (C) 2025 Suzumizaki-Kimitaka(鈴見咲 君高) +; This source code is released under the MIT license, see included license.txt. +; + include common_msx_rom.asm + include ../common_pre_msx.asm + include ../../common_z80flags.asm + include ../common_post_msx.asm + +; EOF ; diff --git a/src/msx/rom_image/z80full.asm b/src/msx/rom_image/z80full.asm new file mode 100644 index 0000000..aa139d2 --- /dev/null +++ b/src/msx/rom_image/z80full.asm @@ -0,0 +1,11 @@ +; +; This file is part of z80test MSX version. +; Copyright (C) 2025 Suzumizaki-Kimitaka(鈴見咲 君高) +; This source code is released under the MIT license, see included license.txt. +; + include common_msx_rom.asm + include ../common_pre_msx.asm + include ../../common_z80full.asm + include ../common_post_msx.asm + +; EOF ; diff --git a/src/msx/rom_image/z80memptr.asm b/src/msx/rom_image/z80memptr.asm new file mode 100644 index 0000000..ab06359 --- /dev/null +++ b/src/msx/rom_image/z80memptr.asm @@ -0,0 +1,11 @@ +; +; This file is part of z80test MSX version. +; Copyright (C) 2025 Suzumizaki-Kimitaka(鈴見咲 君高) +; This source code is released under the MIT license, see included license.txt. +; + include common_msx_rom.asm + include ../common_pre_msx.asm + include ../../common_z80memptr.asm + include ../common_post_msx.asm + +; EOF ; diff --git "a/src/msx/\350\252\254\346\230\216_japanese.txt" "b/src/msx/\350\252\254\346\230\216_japanese.txt" new file mode 100644 index 0000000..749acc9 --- /dev/null +++ "b/src/msx/\350\252\254\346\230\216_japanese.txt" @@ -0,0 +1,63 @@ +- sjasm 0.42c の Windows 版でのみビルドを確認しました。 + 他の OS では make_*.bat の内容を少し変えるだけで作れると思います。 + +- 各環境で実行しやすいように rom_image, com_for_dos, bload_r の + 三種類をビルドできるようになっています。 + +- MSX1 では RAM を 32 KiB 搭載している機種でないと動作しません。 + com_for_dos 版は MSX2 以降でも 64KiB 必要です。 + +- rom_image 版はそのまま各種 MSX エミュレータで使えます。 + ただし、公式の MSXPLAYer では使う方法がありません。 + +- com_for_dos 版は MSX-DOS 上で実行できます。 + エミュレータではディスクイメージへの複製などが必要です。 + 事前に MSX-DOS(1/2/Nextor/CP-M80も多分可) の起動が必要です。 + ファイル名を 8.3 形式に納めるため、8文字目で切っています。 + 例) z80docflags → z80docfl.com + +- bload_r 版は BASIC 起動後 BLOAD"z80(各種).bin",R で実行できます。 + エミュレータではディスクイメージへの複製などが必要です。 + 現状 BASIC が起動しない C-BIOS では実行できません。 + ファイル名を 8.3 形式に納めるため、8文字目で切っています。 + 例) z80docflags → z80docfl.bin + MSX用のテープ音声データに変換すればフロッピーディスクなどが + ない機種でも実行できると思いますが、試していません。 + +- スタックポインタの初期化とかはしてませんが多分大丈夫です。 + rom_image 版と com_for_dos 版はそれぞれの環境から 8000H-BFFFH + に試験内容を転送して実行します。転送されなかった部分も最後に + 使われます。 + bload 版は直接実行アドレスへ読み出します。 + +z80docflags が最小構成ですが、その場合でも一部のいわゆる +未定義命令を実行します。 +1chipMSXでは docflags が 080 RES N,A あたりで暴走します。 +どういうわけか他の試験では完走できることもあります。 + +- 入出力命令の試験は互換性がないのですべて省略しています。 +- BASIC でいう SCREEN 0 に画面を変更します。 +- C-BIOS の初期設定が見づらいので COLOR 15,4,4 相当も実行します。 +- MSX2 以降では WIDTH 80 で実行します。MSX1 では 40 です。 +- 成功した試験の表示を消すかどうかを最初に尋ねます。 +- turbo R では R800 で動作させるかどうかも尋ねます。 + R800 は未定義命令・未使用フラグの動作が異なるので + FAILED が増えます。 + +(2025-06-27,30追記) + +- 漢字モードは CALL KANJI3 または 1 相当時に一応動作します。 + +(2025-06-30追記,2025-07-12修正) + +- z80ccfscr を追加しました。ソースコードは本家とは独立しています。 +- 本家と同じ形だとバイト境界がわかりにくいので色をつけています。 +- 左下は暴走していないことを確認するための JIFFY 読み取り結果です。 +- 本家 48K Spectrum の表示に合わせる処理のため動作は遅めです。 +- 「MSX BASIC でゲームを作ろう(技術評論社 刊行)」付属の + MSXPLAYer の Z80 動作, WebMSX, 1chipMSX が Zilog 本家製 Z80 + と同じか近い動作になっているようです。 +- 実機 HB-F1XD は NEC 製の互換 Z80 の動作になるようです。 +- openMSX での動作は FS-A1GT と一致するようです。 + +2025-06-26 鈴見咲君高 記 / written by Suzumizaki-Kimitaka 2025-06-26 diff --git a/src/print.asm b/src/print.asm index eb7d2fb..14f5b19 100644 --- a/src/print.asm +++ b/src/print.asm @@ -5,10 +5,6 @@ ; This source code is released under the MIT license, see included license.txt. -printinit: ld a,2 - jp 0x1601 ; CHAN-OPEN - - print: ex (sp),hl call printhl ex (sp),hl @@ -38,7 +34,7 @@ printdeca: ld h,a sub b ld h,a ld a,l - jr printchr + jr jp_printchr printcrc: ld b,4 @@ -63,20 +59,7 @@ printhexa: push af daa add a,0xa0 adc a,0x40 - -printchr: push iy - ld iy,0x5c3a ; ERR-NR - push de - push bc - exx - ei - ; out (0xff),a - rst 0x10 - di - exx - pop bc - pop de - pop iy - ret +jp_printchr: + jp printchr ; EOF ; diff --git a/src/tests.asm b/src/tests.asm index 80e8a60..f59d384 100644 --- a/src/tests.asm +++ b/src/tests.asm @@ -148,7 +148,8 @@ testtable: dw .cpd dw .cpir dw .cpdr - + +if io_compatible dw .in_a_n dw .in_r_c dw .in_c @@ -166,6 +167,7 @@ testtable: dw .outd dw .otir dw .otdr +endif dw .jp_nn dw .jp_cc_nn diff --git a/src/z80ccf.asm b/src/z80ccf.asm index 1d904fa..77274cf 100644 --- a/src/z80ccf.asm +++ b/src/z80ccf.asm @@ -4,15 +4,8 @@ ; ; This source code is released under the MIT license, see included license.txt. - macro testname - db "CCF" - endm - -maskflags equ 0 -onlyflags equ 1 -postccf equ 1 -memptr equ 0 - - include main.asm + include common_pre_48k_spectrum.asm + include common_z80ccf.asm + include common_post_48k_spectrum.asm ; EOF ; diff --git a/src/z80doc.asm b/src/z80doc.asm index 7c4ce94..ef940c7 100644 --- a/src/z80doc.asm +++ b/src/z80doc.asm @@ -4,15 +4,8 @@ ; ; This source code is released under the MIT license, see included license.txt. - macro testname - db "doc" - endm - -maskflags equ 1 -onlyflags equ 0 -postccf equ 0 -memptr equ 0 - - include main.asm + include common_pre_48k_spectrum.asm + include common_z80doc.asm + include common_post_48k_spectrum.asm ; EOF ; diff --git a/src/z80docflags.asm b/src/z80docflags.asm index 0a8b061..ae13ef5 100644 --- a/src/z80docflags.asm +++ b/src/z80docflags.asm @@ -4,15 +4,8 @@ ; ; This source code is released under the MIT license, see included license.txt. - macro testname - db "doc flags" - endm - -maskflags equ 1 -onlyflags equ 1 -postccf equ 0 -memptr equ 0 - - include main.asm + include common_pre_48k_spectrum.asm + include common_z80docflags.asm + include common_post_48k_spectrum.asm ; EOF ; diff --git a/src/z80flags.asm b/src/z80flags.asm index 9034e9b..974b82c 100644 --- a/src/z80flags.asm +++ b/src/z80flags.asm @@ -4,15 +4,8 @@ ; ; This source code is released under the MIT license, see included license.txt. - macro testname - db "flags" - endm - -maskflags equ 0 -onlyflags equ 1 -postccf equ 0 -memptr equ 0 - - include main.asm + include common_pre_48k_spectrum.asm + include common_z80flags.asm + include common_post_48k_spectrum.asm ; EOF ; diff --git a/src/z80full.asm b/src/z80full.asm index 219f991..8804f91 100644 --- a/src/z80full.asm +++ b/src/z80full.asm @@ -4,15 +4,7 @@ ; ; This source code is released under the MIT license, see included license.txt. - macro testname - db "full" - endm - -maskflags equ 0 -onlyflags equ 0 -postccf equ 0 -memptr equ 0 - - include main.asm - + include common_pre_48k_spectrum.asm + include common_z80full.asm + include common_post_48k_spectrum.asm ; EOF ; diff --git a/src/z80memptr.asm b/src/z80memptr.asm index b576ad1..b2cf425 100644 --- a/src/z80memptr.asm +++ b/src/z80memptr.asm @@ -7,15 +7,8 @@ ; ; This source code is released under the MIT license, see included license.txt. - macro testname - db "MEMPTR" - endm - -maskflags equ 0 -onlyflags equ 1 -postccf equ 0 -memptr equ 1 - - include main.asm + include common_pre_48k_spectrum.asm + include common_z80memptr.asm + include common_post_48k_spectrum.asm ; EOF ;