En voici un simple mais efficace, facile à intégrer dans un programme.
Code : Tout sélectionner
EnableExplicit
Procedure.s PeekAscii(*mem.BYTE, length.l)
  
  Protected text.s
  Protected *tmp.BYTE = *mem + length - 1
  
  While *mem < *tmp
    If (*mem\b < 32) Or (*mem\b > 126)
      text + "."
    Else
      text + Chr(*mem\b)
    EndIf
    *mem + 1
  Wend
  
  ProcedureReturn text
  
EndProcedure
Procedure.s HexaView(*memAddr.BYTE, memSize.l, columnCount.l = 16, baseAddr.l = 0)
  
  Protected *mem1.BYTE  = *memAddr
  Protected *mem2.BYTE  = *memAddr + memSize
  Protected lineWidth   = (13+(columnCount*3))
  Protected columnIndex =  0
  Protected bar.s, line.s, text.s
  
  bar = "+----------+-"
  bar + RSet("", columnCount*3, "-")
  bar + "+-"
  bar + RSet("", columnCount*1, "-")
  bar + "-+" + #CRLF$
  
  For columnIndex = 0 To columnCount - 1
    line + RSet(Hex(columnIndex), 2, "0") + " "
  Next
  
  text + bar
  text + "|  Offset  | " + line + "| "
  text + Space(columnCount + 1) + "|" + #CRLF$
  text + bar
  
  columnIndex = 0
  line = "| " + RSet(Hex(baseAddr, #PB_Long), 8, "0") + " | "
  While *mem1 < *mem2
    line + RSet(Hex(*mem1\b, #PB_Byte), 2, "0") + " "
    *mem1 + 1 : columnIndex + 1
    If (columnIndex >= columnCount) Or (*mem1 >= *mem2)
      text + LSet(line, lineWidth, " ") + "| "
      text + LSet(PeekAscii(*mem1 - columnIndex, columnIndex + 1), columnCount + 1, " ") + "|" + #CRLF$
      line = "| " + RSet(Hex(baseAddr + *mem1 - *memAddr, #PB_Long), 8, "0") + " | "
      columnIndex = 0
    EndIf
  Wend
  
  ProcedureReturn (text + bar)
  
EndProcedure
; Test code
Debug HexaView(?TEST1, ?TEST2-?TEST1, 16)
DataSection
  TEST1:
  IncludeBinary #PB_Compiler_Filename
  TEST2:
EndDataSection
Le résultat, avec une police taille fixe ressemble à çà :


La largeur est modifiable avec l'argument columnCount.



 
  
 


 
  
 



 
  )  :
 )  :