Add printhex
commit
0ad262563a
|
@ -0,0 +1,22 @@
|
|||
// This asm macro prints out a long value in hex, assuming it can print by
|
||||
// writing ASCII to an address (hardcoded as 0x01fffe here). It uses no stack
|
||||
// or memory, only registers, so is good for very very low level debugging (I
|
||||
// used it to diagnose issues with a c runtime).
|
||||
//
|
||||
// Clobbers d0 through d3 and ccr
|
||||
|
||||
.macro printhex input
|
||||
move.l \input, %d0
|
||||
move.w #8, %d2
|
||||
moveq #28, %d3
|
||||
111: move.l %d0, %d1 // 12345678 12345678
|
||||
lsr.l %d3, %d1 // 12345678 00000001
|
||||
addi.w #'0', %d1
|
||||
cmpi.w #':', %d1
|
||||
blt.s 222f
|
||||
addi.w #('A'-':'), %d1
|
||||
222: move.w %d1, 0x01fffe // debug console out
|
||||
lsl.l #4, %d0 // 23456780
|
||||
subi.w #1, %d2
|
||||
bne.s 111b
|
||||
.endm
|
Loading…
Reference in New Issue