'------------------------------------------------------------------------------- ' Module: HexDebug.bas ' ' Copyright 2005 Elba Corp. ' All rights reserved. ' ' Non-exclusive permission to use, copy, modify, and distribute this ' software for any purpose and without fee is hereby granted, provided: ' 1) that the above copyright notice is retained in the source code and, ' 2) that it is understood and agreed that no warranty of any kind, ' express or implied is provided. ' Use of this code in any manner shall be prima facie evidence of ' acceptance of these terms. ' ' You may contact the author by email at dkinzer@zbasic.net. ' '------------------------------------------------------------------------------- ' ' Overview: ' This module provides functions for outputting data in hexadecimal format. ' See the procedure headers for details. ' '------------------------------------------------------------------------------- '------------------------------------------------------------------------------- ' '' dbgDspNibbleHex ' ' Display the value of the least significant 4 bits of a value in hexadecimal. ' Private Sub dbgDspNibbleHex(ByVal n as Byte) n = n And &H0f If (n <= 9) Then n = n + &H30 Else n = (n - 10) + &H41 End If debug.print chr(n); End Sub '------------------------------------------------------------------------------- ' '' dbgDspByteHex ' ' Display a byte value in hexadecimal. Two hex digits will be displayed. ' Sub dbgDspByteHex(ByVal b as Byte) Call dbgDspNibbleHex(Shr(b, 4)) Call dbgDspNibbleHex(b) End Sub '------------------------------------------------------------------------------- ' '' dbgDspWordHex ' ' Display a word value in hexadecimal. Four hex digits will be displayed. ' Sub dbgDspWordHex(ByVal w as UnsignedInteger) Call dbgDspByteHex(HiByte(w)) Call dbgDspByteHex(LoByte(w)) End Sub '------------------------------------------------------------------------------- ' '' dbgDspDWordHex ' ' Display a double word value in hexadecimal. Eight hex digits will be displayed. ' Sub dbgDspDWordHex(ByVal w as UnsignedInteger) Call dbgDspWordHex(HiWord(w)) Call dbgDspWordHex(LoWord(w)) End Sub '------------------------------------------------------------------------------- ' '' dbgDspRamBytes ' ' Display a sequence of bytes in RAM ' Public Sub dbgDspRamBytes(ByVal addr as UnsignedInteger, ByVal cnt as Integer) Dim i as Byte i = 0 Do While (cnt > 0) If (i > 0) Then debug.print " "; End If dbgDspByteHex(RamPeek(addr)) i = i + 1 If (i >= 16) Then debug.print i = 0 End If addr = addr + 1 cnt = cnt - 1 Loop If (i > 0) Then debug.print End If End Sub