Re: A86: sub


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

Re: A86: sub




if by 'bit' you mean 16-bit piece, yes.
you can subtract 32-bit values like this:

; src = src - dest
sub32:		ld hl,(srclow)
		ld de,(destlow)
		or a				; clear the carry flag
		sbc hl,de			; subtract low 16 bits
		ld (srclow),hl		; store low result
		ld hl,(srchigh)
		ld de,(desthigh)
		sbc hl,de			; subtract high 16 bits and carry
		ld (srchigh),hl		; store high result
		ret

srclow:	.dw 0
srchigh:	.dw 0
destlow:	.dw 0
desthigh:	.dw 0

(remember to store something into the src and dest first!)

this can be extened to as large as you want, but unless you need really
fast math, or more precision than they offer, i'd work with the op
registers for anything more than that.

and if you were really going for high speed and low space, you could use
self modifying code and store the src and dest in the opcodes that load
them into the registers...

-josh

On Sat, 18 Sep 1999 04:20:13 GMT "Andrew T" <ironman_294@hotmail.com>
writes:
>
>Ok I might have to subtract numbers that take up more mem then 16 
>bits.  And 
>as I thought about it I came up with takeing one bit at a time and 
>subtracting them.  Will this work or am I just out of my mind (if I am 
>right 
>would I use the carry flag or not).
>
>Thanx
>Andrew
>
>______________________________________________________
>Get Your Private, Free Email at http://www.hotmail.com
>

___________________________________________________________________
Get the Internet just the way you want it.
Free software, free e-mail, and free Internet access for a month!
Try Juno Web: http://dl.www.juno.com/dynoget/tagj.