Hello Cemetech!
So, I was writing a program I planned on using for debugging some other programs, that would basically display the contents of HL, but in hex, and not destroy HL, which really bugged me from using BCALL DispHL
My program requires coordinates to be fed into it for display i.e. you load into (curRow) and (curCol), so that it can display in varied locations. I might rework so that it uses a register for coords... but not right now.
So, I wrote my program, DEBUG, as follows, which probably isn't very efficient but it worked... in testing:
Code:
I tested this by adding a label to the start and some input:
Code:
And it worked.
However, when I tried calling from within another program, DEDEBUG, using it as a 'library'
Code:
It displayed this:
Code:
And I went whaaat? and tried a couple things to fix it and test further. CALLs for DispHLHex WITHIN prgmDEBUG worked. Within DEDEBUG, none worked right for me.
Even more stangely, running DEDEBUG and DEBUG consecutively resulted in strange screen glitches.
I was using Mimas as my assembler, so I wonder if there was something specific I needed to change for it to work?
I can get pictures if needed/wanted.
So, I was writing a program I planned on using for debugging some other programs, that would basically display the contents of HL, but in hex, and not destroy HL, which really bugged me from using BCALL DispHL
My program requires coordinates to be fed into it for display i.e. you load into (curRow) and (curCol), so that it can display in varied locations. I might rework so that it uses a register for coords... but not right now.
So, I wrote my program, DEBUG, as follows, which probably isn't very efficient but it worked... in testing:
Code:
ORG userMem-2
DB $BB,$6D
DispHLHex:
PUSH HL
LD B,4
DispHLHexLooP: ;Caps P was a typo, did not bother fixing because I kinda liked it :)
CALL GetPart
CALL DispDigit
CALL ShiftHL
DJNZ DispHLHexLooP
POP HL
RET
GetPart:
LD A,H
; A=____????
SRL A
SRL A
SRL A
SRL A ;yes this probably could be better...
; A=0000____
RET
DispDigit:
PUSH BC
PUSH HL
LD H,0
LD L,A
LD DE,DispDigitDAT
ADD HL,DE
LD A,(HL)
BCALL PutC
POP HL
POP BC
RET
ShiftHL:
PUSH BC
LD B,4
ShiftHLLoop:
SLA L
RL H ;Shift HL so next nibble can be extracted
DJNZ ShiftHLLoop
POP BC
RET
DispDigitDAT:
DB "0123456789ABCDEF"
I tested this by adding a label to the start and some input:
Code:
Aaaa: ;This was my label name just because
LD HL,$0202
LD (curRow),HL
LD HL,$2486
And it worked.
However, when I tried calling from within another program, DEDEBUG, using it as a 'library'
Code:
ORG userMem-2
DB $BB,$6D
Start:
LD HL,$0101
LD (curRow),HL
LD HL,$2486
CALL DispHLHex
RET
It displayed this:
Code:
7 5
B Done
4
And I went whaaat? and tried a couple things to fix it and test further. CALLs for DispHLHex WITHIN prgmDEBUG worked. Within DEDEBUG, none worked right for me.
Even more stangely, running DEDEBUG and DEBUG consecutively resulted in strange screen glitches.
I was using Mimas as my assembler, so I wonder if there was something specific I needed to change for it to work?
I can get pictures if needed/wanted.