Re: A86: TI-86 VAT


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

Re: A86: TI-86 VAT




Here is a code example. The first number is in IXHL and the second
number is in BCDE. Output is stored in IXHL.

Add32:
	add hl,de
	adc ix,bc
	ret

Sub32:
	or a
	sbc hl,de
	sbc ix,bc
	ret

because of the short nature of these routines you may want to define a
macro for them. Note that the use of IX is going to slow these down a
bit... if you're going to use the output IXHL at all I recommend doing:
	ex de,ix
because then it will be in DEHL which works a lot faster. You would only
do this if, say, you were going to test each bit in your 32-bit number.
Then you would definitely convert IXHL -> DEHL. (Note: DE=MSW, HL=LSW,
etc.)

Matt Johnson wrote:
> 
> > Has anybody writen 32 bit addition/subtraction routines?
> > I doubt I'll need 32b division or multiplication routines
> > (I can imagine how many cycles 32 bit division takes on
> > an 8 bit processor...) but I know there are routines for
> > * and / on ticalc.org. Is addition really simple, or has
> > nobody bothered to write them yet?
> 
> 32-bit? Four bytes.. umm.. sure I think all you have to do is something
> like this
> 
> Source:
> LSB [BYTE 1] [BYTE 2] [BYTE 3] [BYTE 4] MSB
>             /\             /\            /\              /\
>           ADD        ADC       ADC         ADC
>             \/            \/             \/              \/
> Destination:
> LSB [BYTE 1] [BYTE 2] [BYTE 3] [BYTE 4] MSB
> 
> I think that is all you do. ADC just adds the carry. So when you add the
> first two bytes and if it overflows, the overflow is added to the next set
> of bytes
> that you add.. This is like the approach they use to add numbers in
> electronics,
> they use full 1-bit chained adders, If I recall correctly.
> 
> And subtractions are similar too, SUB and SBC combos I believe.
> 
> Later,
>         Matt

-- 

=====================================
=                                   =
=   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      =
=                                   =
=====================================


References: