[A83] Re: finding the absolute value of hl


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

[A83] Re: finding the absolute value of hl



>  bit 7,h
>  jp z,HL_Is_Positive
>  ex hl,de
>  or a
>  ld hl,0000h  
>  sbc hl,de
>  ex hl,de
> HL_Is_Positive:
> 
> I cannot see anything wrong, but I am fighting with this horrendous bug,
> and I am becoming desperate!
> 
You shouldn't exchange hl and de in the end. BTW if you want to preserve
de, you can use this code to negate hl (destroys the accumulator, but
it's usually less of a problem):

ld a,l
cpl
ld l,a
ld a,h
cpl
ld h,a
inc hl

-- 
http://www.fastmail.fm - I mean, what is it about a decent email service?



References: