Re: LZ: Ramviewer


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

Re: LZ: Ramviewer



On 30 Aug 96 at 22:00, Josh Lynch wrote:
 
>         I was wondering if someone could help me out with this prog, I'm
> making. It's supposed to show what value, in Hex, is in a particular
> location. So far that value (the address of memory) is hard coded in the
> prog. The problem is that it (I think) is showing the value of that address,
> but not in Hex, it is showing it in ASCII (or whatever the calc uses) So,
> what function do I have to call to display a memory location or register in
> Hex (or do I have to write a whole new routine) I have the source for
> hexview0.1 but I just seem to get lost in all those calls to functions.
> 
>         BTW I'm making it in hex opcodes. Using the compiler program. As an
> aside, where could find better documentation on the compiler program (such
> as how it works)? Translations are located on right.
> 


You need your own routine to display a hex number. A good one, 
posted by Darryl Nester some time ago is the following:


\\\\\\\
Here are two ways to display the value in A as a two-digit hex number.
 The first method is shorter; the second is slightly more
understandable (but longer by 2 bytes).


Note that both routines destroy the value of A; other registers should
be untouched. \\\\\\\


PrintHex:
  push  af
  rrca
  rrca
  rrca
  rrca
  CALL_(HexDigit)
  pop   af
HexDigit:
  and   $0F
  add   a,$90
  daa
  adc   a,$40
  daa
  ROM_CALL(TX_CHARPUT)
  ret


\\\\\\\\
Version 2: the same up to the HexDigit section ...
\\\\\\\\
HexDigit:
  and   $0F
  add   a,$30               ;= '0'
  cp    $3A                 ;= '9' + 1
  jr    c,PrintIt
  add   a,7                 ;= 'A' - ':'
PrintIt:
  ROM_CALL(TX_CHARPUT)
  ret


\\\\\\\\
To display the four-digit hex number in (e.g.) HL, one could place the
following three lines above the either of the "PrintHex" routines
given above:


PrintHex4:
        ld      a,h
        CALL_(PrintHex)
        ld      a,l


\\\\\\\\




Mattias Lindqvist
CS student at LTH, Sweden
E-mail: d96mli@efd.lth.se


References: