Re: A82: Debug DM_HL_DECI


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

Re: A82: Debug DM_HL_DECI



I have not looked at the rutine you send, but it seems to me that there is
an easier way to do it. The rom includes a function which unpacks on digit
of hl into a, using this rutine the function could be made smaller. I
wrote the code below which uses the function, but i did not have time to
test it. As you can see this is less half the size of your rutine.

  ld a,h
  or l
  jr z,hl_is_zero
  ld de,$802C ; -> OP1 (temp storage)
  ld b,5      ; maimum number of digits
  jr loop
loop:
  dec b
loop2:
  CALL $A1    ; Unpack one digit of HL into A
  or a        ; If zero then do not use digit
  jr z,loop
  add a,$30   ; make it ASCII
  ld (de),a   ; Save in buffer
  dec de      ; point to next digit
  djnz loop2
  sub a
  ld ($802D),A ; make it ASCIIZ
  inc de       ; point to first digit
  ex de,hl     ; hl points to string
  ROM_CALL(D_ZM_STR) ; print it
  ret
hl_is_zero:
  ld a,$30 ; display 0
  rom_call($37E8-$1A)
  ret

Use the rutine if you want.

Dines

_______________________________________

Dines Justesen
Email: dines@post1.com or
       c958362@student.dtu.dk
WWW  : http://www.gbar.dtu.dk/~c958362/
_______________________________________


References: