[Coco] HD63x09 Question
jdaggett at gate.net
jdaggett at gate.net
Wed Jan 5 15:51:33 EST 2005
Robert
Thanks. Nice of Google to keep some old USENET postings. It was only
recently that I finally decided to play with the 6309 and after some readings
I was not certain and this was a godd test of my understanding.
Well I guess I willstay with the old unsigned 8x8 MUL opcode and use the
sum of partial products. That is tried and true an dbattle hardened.
james
On 5 Jan 2005 at 11:47, Robert Gault wrote:
Date sent: Wed, 05 Jan 2005 11:47:26 -0500
From: Robert Gault <robert.gault at worldnet.att.net>
To: CoCoList for Color Computer Enthusiasts
<coco at maltedmedia.com>
Subject: Re: [Coco] HD63x09 Question
Send reply to: CoCoList for Color Computer Enthusiasts
<coco at maltedmedia.com>
<mailto:coco-
request at maltedmedia.com?subject=unsubscribe>
<mailto:coco-
request at maltedmedia.com?subject=subscribe>
> You are correct in your assumptions. Be careful with the MUL and DIV
> instructions as there are very unexpected results from overflow. In
> fact, the DIV instructions seem not to work at all if an overflow
> would be the result.
>
> It is possible to write code that uses MULD to get an unsigned answer
> but the overhead may make it not worth the effort.
>
> *Unsigned 16by16 bit multiply
> *ENTER: numbers in regD & REGX
> *EXIT: regD&X unchanged, answer in regY&U
>
> MUL16 PSHS D,X
> MULD 2,S
> TFR D,Y
> TFR W,U regY&U now contain signed answer
> BNE NOTZRO
> TSTW
> BEQ ZRO
> *Convert signed answer to unsigned. Only regY (MSW) will change.
>
> *If answer is Neg, add positive multipliers
> NOTZRO BPL MULP2
> PULS D,X
> TSTA
> BMI MB1
> ADDR D,Y
> MB1 CMPX #$8000
> BHS MC1
> ADDR X,Y
> MC1 RTS
>
> *If answer is Pos, add negative multipliers
> MULP2 PULS D,X
> TSTA
> BPL MB2
> ADDR D,Y
> MB2 CMPX #$8000
> BLO MC2
> ADDR X,Y
> MC2 RTS
More information about the Coco
mailing list