|
- ; E02-S04: diagnostics and ERR-writer test in x128.
- ;
- ; Phase A DIAG.N8 six representative diagnostics on a cleared screen
- ; Phase D BAD*.N8 ERR name the drive refuses: report, screen-only notice,
- ; second report on screen only
- ; Phase B LIMIT.N8 25 errors, screen off: 20 reported, then the limit
- ; Phase C CLEAN.N8 no errors: the stale CLEAN.ERR is scratched, none made
- ; Results (address in MB_DATA+0/1):
- ; +0 A count +1 D count +2 D file state +3 B count +4 C count
- ; +5..+8 LDTND after A, D, B, C
- ; +9..+33 carry returned by each of B's 25 diag_report calls
- ; Mailbox PASS means the program ran to the end; the host checks the rest.
-
- .setcpu "6502"
- .include "../../src/common/c128.inc"
- .include "../../src/common/mailbox.inc"
- .include "../../src/common/errors.inc"
-
- .import mmu_init, mmu_bank0, mmu_shutdown, kcall_inline
- .import diag_init, diag_report, diag_finish, diag_line, diag_col
- .import diag_arg1, diag_arg1_len, diag_arg2, diag_arg2_len
- .import diag_screen, diag_file_state
- .import __COMPILER_ZP_PAGE__
-
- .segment "LOADADDR"
- .word $1C01
-
- .segment "EXEHDR"
- .word basic_end
- .word 10
- .byte $9E
- .byte "7181"
- .byte $00
- basic_end:
- .word $0000
-
- .segment "MAILBOX"
- .res MB_SIZE
-
- .macro REPORT line, col, code
- lda #<(line)
- sta diag_line
- lda #>(line)
- sta diag_line+1
- lda #col
- sta diag_col
- lda #code
- jsr diag_report
- .endmacro
-
- .macro ARG1 text, len
- lda #<text
- sta diag_arg1
- lda #>text
- sta diag_arg1+1
- lda #len
- sta diag_arg1_len
- .endmacro
-
- .macro ARG2 text, len
- lda #<text
- sta diag_arg2
- lda #>text
- sta diag_arg2+1
- lda #len
- sta diag_arg2_len
- .endmacro
-
- .macro INIT name, len
- lda #<name
- ldx #>name
- ldy #len
- jsr diag_init
- .endmacro
-
- .segment "STARTUP"
- .export test_entry, results
- test_entry:
- php
- sei
- ldx #MB_SIZE - 1
- lda #$00
- @clr: sta MB_BASE,x
- dex
- bpl @clr
- lda #MB_MAGIC0_VALUE
- sta MB_MAGIC0
- lda #MB_MAGIC1_VALUE
- sta MB_MAGIC1
- lda #MB_PROD_PLATFORM
- sta MB_PRODUCER
- lda #MB_ST_RUNNING
- sta MB_STATUS
- jsr mmu_init
- jsr mmu_bank0
-
- lda #$93 ; clear screen: the host reads it back
- jsr kcall_inline
- .word CHROUT
-
- ; ------------------------------------------------------ phase A
- INIT n_diag, 7
- REPORT 3, 11, E_LEX_BAD_CHAR_LITERAL
- REPORT 599, 80, E_SYN_EXPECTED_END_PROGRAM
- ARG1 a_counter, 7
- REPORT 12, 5, E_SEM_DUPLICATE_NAME
- ARG1 a_integer, 7
- ARG2 a_long, 16
- REPORT 40, 17, E_TYP_MISMATCH
- ARG1 a_dos, 2
- REPORT 1, 1, E_DSK_SOURCE_UNREADABLE
- REPORT 65535, 255, E_SYN_EXPECTED_RPAREN
- jsr diag_finish
- sta results+0
- jsr open_files
- sta results+5
-
- ; ------------------------------------------------------ phase D
- INIT n_bad, 7
- REPORT 7, 3, E_LEX_INVALID_CHAR
- REPORT 8, 4, E_LEX_INVALID_CHAR
- lda diag_file_state
- sta results+2
- jsr diag_finish
- sta results+1
- jsr open_files
- sta results+6
-
- ; ------------------------------------------------------ phase B
- INIT n_limit, 8
- lda #$00
- sta diag_screen
- ldx #$00
- @limit: stx b_index
- inx ; line = 1..25
- stx diag_line
- lda #$00
- sta diag_line+1
- lda #1
- sta diag_col
- lda #E_LEX_INVALID_CHAR
- jsr diag_report
- lda #$00
- rol a ; carry -> 0/1
- ldx b_index
- sta results+9,x
- inx
- cpx #25
- bne @limit
- jsr diag_finish
- sta results+3
- jsr open_files
- sta results+7
-
- ; ------------------------------------------------------ phase C
- INIT n_clean, 8
- jsr diag_finish
- sta results+4
- jsr open_files
- sta results+8
-
- jsr mmu_shutdown
- lda #<results
- sta MB_DATA+0
- lda #>results
- sta MB_DATA+1
- lda #MB_ST_PASS
- sta MB_STATUS
- plp
- ldy #$00
- @print: lda ok_msg,y
- beq @end
- sty b_index
- jsr CHROUT
- ldy b_index
- iny
- bne @print
- @end: rts
-
- .segment "CODE"
- ; A = number of open logical files (system zero page via the P0 swap).
- open_files:
- lda __COMPILER_ZP_PAGE__ * 256 + LDTND
- rts
-
- .segment "RODATA"
- n_diag: .byte "DIAG.N8"
- n_bad: .byte "BAD*.N8"
- n_limit: .byte "LIMIT.N8"
- n_clean: .byte "CLEAN.N8"
- a_counter: .byte "COUNTER"
- a_integer: .byte "INTEGER"
- a_long: .byte "VERYLONGCLASSNAM"
- a_dos: .byte "62"
- ok_msg: .byte "NOVA128 DIAG TEST OK", $0D, $00
-
- .segment "BSS"
- results: .res 34
- b_index: .res 1
|