Debug routines for assembly use
Mike Green
Posts: 23,101
Here are some basic debug display routines that can be used from a COG assembly program. They assume that there's an active hires text driver running and these routines write directly into the display buffer. They can be modified to use the TV driver by writing a word rather than a byte (and including a default color) and by incrementing the buffer address by 2 instead of 1 (in displayOut).
The character output routine (debugOut) will actually take up to 4 characters (LSB..MSB) in its argument (debugChr). It stops when there's just zeroes left. It increments the screen buffer pointer which wraps around from row to row. There's no checking for the end of the screen buffer.
Update: Re-download the routines, the hex output routines have been fixed. There are calls for byte, word, and long as well as character output.
Post Edited (Mike Green) : 8/4/2006 7:22:59 PM GMT
The character output routine (debugOut) will actually take up to 4 characters (LSB..MSB) in its argument (debugChr). It stops when there's just zeroes left. It increments the screen buffer pointer which wraps around from row to row. There's no checking for the end of the screen buffer.
Update: Re-download the routines, the hex output routines have been fixed. There are calls for byte, word, and long as well as character output.
call #debugInit ' sets up the display pointer to row 0, col 0 mov debugChr,#"$" call #debugOut ' writes the "$" to the display buffer mov debugVal,#$34F call #debugHexWord ' writes 4 characters of hex ("034F")
Post Edited (Mike Green) : 8/4/2006 7:22:59 PM GMT