Close

Debugging code using CEGMON

A project log for OSI SD Card Operating System (OSISDOS)

Ohio Scientific / UK101 SD Card based Operating System under Multicomp FPGA Computer

land-boardscomland-boards.com 08/02/2020 at 17:400 Comments

CEGMON has some minimal debugging facilities.

The code I am trying to run is on the previous log. The command line for cl65 is:

cl65 --start-addr 0x300 -Wl -D,__HIMEM__=$2000,-D,__STACKSIZE__=$0200 -t osic1p -vm -m OSISDOS.map -o OSISDOS.o OSISDOS.c

This generates a verbose map file. The map file has addresses for each of the functions. The relevant functions are:

_exit                     000315  LA    _init                     000300  LA    
_issueSDCardCommand       0003DC  LA    _main                     000327 RLA    
_readBlock                000371  LA    _readByteFromSDCard       00041C  LA    
_setLBA0                  000341  LA    _setLBA1                  000351  LA    
_setLBA2                  000361  LA    _waitSDCardRcvDataReady   0003FC  LA    
_waitSDCardReady          0003EC  LA    _waitSDCardTxDataEmpty    00040C  LA    
_writeBlock               00044B  LA    _writeByteToSDCard        000438  LA    

CEGMON has the ability to load code, run code and set a breakpoint in the code. CEGMON can also display memory.

To load code:

To run code enter the address (4-digits) then G for Go.

Debug Using Breakpoints

To debug code, insert a breakpoint at the address to stop at by entering Zaaaa where aaaa is the address to insert the breakpoint at. Then enter 0300G for Go at address 0x0300. The program will run until it hits the breakpoint and then will return to the Monitor prompt and display 00E0/aa. From the CEGMON manual:

At this point another breakpoint can be set using the Zaaaa as above.

Enter R to (re)start running from the breakpoint. 

To dump a block of memory, use Taaaa,bbbb where aaaa is the start address and bbbb is the end address. CEGMON will insert the comma between the two numbers.

Discussions