Debug DM_HL_DECI


[Prev][Next][Index][Thread]

Debug DM_HL_DECI



After giving myself a headache, I have decided to release a section of my
source from my "top secret" project.  The only reason I'm doing this is
because I need someone to debug it.  This function works EXACTLY like the
D_HL_DECI function except it has no whitespace and uses the small font.  It
works about 80% of the time.  The rest of the time it crashes by running a
series of digits on forever (i.e. when HL=510d).  If anyone could fix it, I
would appreciate it very much.  TIA

DM_HL_DECI:
  push af
  push bc
  push de
  push hl
  ld b,48
  ld a,h
  or l
  jr z,DM_HL_3
  ld c,-1
  ld b,46
  jr DM_HL_NEXT2
DM_HL_INIT:
  ld a,h
  cp d
  jr c,DM_HL_NEXT2
  ld a,l
  cp e
  jr c,DM_HL_NEXT2
  dec c
DM_HL_NEXT:
  ld b,47
DM_HL_NEXT2:
  inc c
  ld a,c
  or a
  ld de,10000
  jr z,DM_HL_2a
  cp 1
  ld de,1000
  jr z,DM_HL_2a
  cp 2
  ld de,100
  jr z,DM_HL_2a
  cp 3
  ld de,10
  jr z,DM_HL_2a
  ld de,1
DM_HL_2a:
  ld a,b
  cp 46
  jr z,DM_HL_INIT
DM_HL_2b:
  inc b
  ld a,h
  cp d
  jr c,DM_HL_3
  ld a,l
  cp e
  jr c,DM_HL_3
  or a
  sbc hl,de
  jr DM_HL_2b
DM_HL_3:
  ld a,b
  ROM_CALL(M_CHARPUT)
  ld a,h
  or l
  jr nz,DM_HL_NEXT
  pop hl
  pop de
  pop bc
  pop af
  ret


                 Thomas J. Hruska -- thruska@tir.com
Shining Light Productions -- "Meeting the needs of fellow programmers"
         http://www.geocities.com/SiliconValley/Heights/8504
                    http://shinelight.home.ml.org


Follow-Ups: