Re: A86: Dec to Hex


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

Re: A86: Dec to Hex




;this routine is actually more efficient
;modified routine by Kirk Meyer   5/11/98

disp_ahl_hex:
  call put_number
  ld a,h
  call put_number
  ld a,l
put_number:
  push af
  rrca
  rrca
  rrca
  rrca
  and %00001111
  call put_digit
  pop af
  and %00001111
put_digit:
  push hl
  add a,'0'
  cp '9'+1
  jr c,put_digit_ok
  add a,'A'-'9'+1
put_digit_ok:
  call _putc
  pop hl
  ret


> ;i didn't test this, someone verify it. this is the idea though.
> ;routine to display AHL as hex number in normal font
> ;written by Kirk Meyer    5/11/98
> 
> disp_ahl_hex:
>  call put_number
>  ld a,h
>  call put_number
>  ld a,l
> put_number:
>  push af
>  ld hl,$0000            ;if you used an HL that contained 0,
>                         ;then you could eliminate the line
>                         ;labeled "could be eliminated"
>  rrd
>  and %00001111          ;could be eliminated
>  call put_digit
>  pop af
>  and %00001111
> put_digit:
>  push hl
>  add a,'0'
>  cp '9'+1
>  jr c,put_digit_ok
>  add a,'A'-'9'+1
> put_digit_ok:
>  call _putc
>  pop hl
>  ret
> 
> 
> Dux Gregis wrote:
> >
> > How about this?
> >
> >  xor a
> >  add hl,0
> >  daa
> >  call $4a33
> >
> > My use of daa might be backwards...
> >
> > Trey Jazz wrote:
> >
> > > can someone post the routine to display ahl in hex
> 
> --
> 
> =====================================
> =                                   =
> =   Kirk Meyer (mailto:_@ibm.net)   =
> = http://www.bigfoot.com/~kirkmeyer =
> =                                   =
> =   "Set your affection on things   =
> =    above, not on things on the    =
> =      earth."  Colossians 3:2      =
> =                                   =
> =====================================

-- 

=====================================
=                                   =
=   Kirk Meyer (mailto:_@ibm.net)   =
= http://www.bigfoot.com/~kirkmeyer =
=                                   =
=   "Set your affection on things   =
=    above, not on things on the    =
=      earth."  Colossians 3:2      =
=                                   =
=====================================


Follow-Ups: References: