From 8d38709c46a8373ebf0dec834b205d23d9c43351 Mon Sep 17 00:00:00 2001 From: Daniele Verducci su MatissePenguin Date: Mon, 1 Mar 2021 19:50:50 +0100 Subject: [PATCH] Working on memtest --- .../software/z80-assembly/os/monitor.asm | 102 +++++++++--------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/pat80-computer/software/z80-assembly/os/monitor.asm b/pat80-computer/software/z80-assembly/os/monitor.asm index 5061af6..71def64 100644 --- a/pat80-computer/software/z80-assembly/os/monitor.asm +++ b/pat80-computer/software/z80-assembly/os/monitor.asm @@ -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