Re: A85: two byte chunks


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

Re: A85: two byte chunks




you may be confused with "inc hl" and "inc (hl)".  to increment the
16-bit value in memory do:

ld hl,(Score)
inc hl
ld (Score),hl

Score:
.dw 0

if you do this:

ld hl,Score
inc (hl)

only the low byte will be incremented.  but you could check the carry flag
which will tell you if the number went from 255 to 0 (i think "inc (hl)"
sets the carry flag, but check a reference to make sure!). so you would
need to do something like this:

ld hl,Score
inc (hl)		;increment low byte of score
jr nc,JumpHere		;jump if didn't cause carry out
inc hl			;move to high byte of score
inc (hl)		;now increment the high byte
JumpHere:
....

-mike pearce

On Wed, 22 Apr 1998 nine1one@juno.com wrote:

> 
> If I increment a number in HL will it go over 255?  Lets say that the
> value in L is 255.  If I inc (hl) will the number 256 appear if I do a
> ROM_CALL(D_HL_DECI)?  These questions come up after I figured out how to
> store numbers in the RAM permanently.
> 
> _____________________________________________________________________
> You don't need to buy Internet access to use free Internet e-mail.
> Get completely free e-mail from Juno at http://www.juno.com
> Or call Juno at (800) 654-JUNO [654-5866]
> 
> 


Follow-Ups: References: