Working on memtest

This commit is contained in:
Daniele Verducci su MatissePenguin 2021-03-01 19:50:50 +01:00
parent 2ba63877bf
commit 8d38709c46

View File

@ -21,14 +21,14 @@ MON_COMMAND_ZERO: DB "ZERO",0
MON_COMMAND_LOAD: DB "LOAD",0
MON_COMMAND_RUN: DB "RUN",0
MON_COMMAND_ADB: DB "ADB",0
MON_COMMAND_MEMTEST: DB "MEMTEST",0
MON_COMMAND_QUIT: DB "QUIT",0
MON_ARG_HEX: DB " 0x",0
MON_HELP: DB 10,"Available commands:\nHELP prints this message\nDUMP [ADDR] shows memory content\nSET [ADDR] sets memory content\nZERO [ADDR] [ADDR] sets all bytes to 0 in the specified range\nLOAD\nRUN [ADDR] executes code starting from ADDR\nADB starts Assembly Deploy Bridge\nQUIT exits",0
MON_HELP: DB 10,"Available commands:\nHELP prints this message\nDUMP [ADDR] shows memory content\nSET [ADDR] sets memory content\nZERO [ADDR] [ADDR] sets all bytes to 0 in the specified range\nLOAD\nRUN [ADDR] executes code starting from ADDR\nADB starts Assembly Deploy Bridge\nMEMTEST checks ram boundaries\nQUIT exits",0
MON_MSG_ADB: DB 10,"Waiting for data.",0
MON_ERR_SYNTAX: DB " Syntax error",0
MON_RAMTEST_INTRO: DB "Memory check... ",0
MON_RAMTEST_INTRO: DB " Checking memory... ",0
MON_RAMTEST_RAMSTART: DB " Ram starts at 0x",0
MON_RAMTEST_OK: DB " bytes OK",0
;MON_ADB_TIMEOUT: EQU 0xFF // Number of cycles after an ADB binary transfer is considered completed
MON_DUMP_BYTES_LINES: EQU 8
MON_DUMP_BYTES_PER_LINE: EQU 8
@ -70,6 +70,9 @@ Monitor_main:
ld hl, MON_COMMAND_ADB
cp (hl)
jp z, monitor_adb
ld hl, MON_COMMAND_MEMTEST
cp (hl)
jp z, monitor_memtest
ld hl, MON_COMMAND_QUIT
cp (hl)
jp z, monitor_quit
@ -555,54 +558,51 @@ monitor_copyTermToAppMem:
; Starting from last memory position, writes 0xFF, reads it back, writes 0x00, reads it back.
; Exits when the first value differs from the written value (this may be caused by a bad ram
; block or the start of rom in memory map). Prints the last good address on exit.
monitor_ramTest:
; Prints intro
ld bc, MON_RAMTEST_INTRO
call Sys_Print
; Starts checking
ld hl, MEM_END
monitor_ramTest_loop:
; Write 0xFF
ld a, 0xFF
ld (hl), a
; Read and compare 0xFF
ld a, (hl)
cp 0xFF
jp nz, monitor_ramTest_badram
; Write 0x00
ld a, 0x00
ld (hl), a
; Read and compare 0xFF
ld a, (hl)
cp 0x00
jp nz, monitor_ramTest_badram
; Memory byte is good, next one
dec hl
jp monitor_ramTest_loop
monitor_ramTest_badram:
; Found a bad memory byte (or entered rom block).
ld bc, MON_RAMTEST_RAMSTART
call Sys_Print
; Print memory addr
ld a, h
call monitor_printHexByte
ld a, l
call monitor_printHexByte
; Print message
ld a, ','
call Sys_Printc
ld a, ' '
call Sys_Printc
; Print number of valid bytes
ld bc, hl ; move hl to bc
ld hl, 0xFFFF
sbc hl, bc ; obtain number of good mem bytes
; TODO: Implement 16-bit integer print
; Print message
ld bc, MON_RAMTEST_OK
call Sys_Print
ret
; monitor_memtest:
; ld bc, MON_COMMAND_MEMTEST + 1 ; autocomplete command
; call Sys_Print
; ; Prints intro
; ld bc, MON_RAMTEST_INTRO
; call Sys_Print
; ; Starts checking
; ld hl, MEM_END
; monitor_memtest_loop:
; ; Save current byte value for later restore
; ld c, (hl)
; ; Write 0xFF
; ld a, 0xFF
; ld (hl), a
; ; Read and compare 0xFF
; ld a, (hl)
; cp 0xFF
; jp nz, monitor_memtest_badram
; ; Write 0x00
; ld a, 0x00
; ld (hl), a
; ; Read and compare 0xFF
; ld a, (hl)
; cp 0x00
; jp nz, monitor_memtest_badram
; ; Memory byte is good, restore previous value
; ld (hl), c
; ; Next one
; dec hl
; jp monitor_memtest_loop
; monitor_memtest_badram:
; ; Found a bad memory byte (or entered rom block).
; ld bc, MON_RAMTEST_RAMSTART
; call Sys_Print
; ; Print last valid memory addr
; inc hl
; ld a, h
; call monitor_printHexByte
; ld a, l
; call monitor_printHexByte
; ; Newline
; ld a, 10
; call Sys_Printc
; ; Back to menu
; jp monitor_main_loop