--- pgp/src/68000_32.s 2018/04/24 16:41:17 1.1.1.3 +++ pgp/src/68000_32.s 2018/04/24 16:45:46 1.1.1.5 @@ -124,41 +124,52 @@ P_ROTL: move.b d0,d1 ;boolean .base: scs d0 ;set returned carry rts - + ;void P_SETP(short nbits); ; /* sets working precision to specified number of bits. */ ; /* only to minimize portation differences */ ;Parameters: -- ;Result: -- - + P_SETP: rts -; ***NOT TESTED*** -; ;void P_SMUL(MULTUNIT *prod, MULTUNIT *multiplicand, MULTUNIT multiplier) ; /* multiprecision multiply */ ;Parameters: A0.l: prod, A1.l: multiplicand, D0.w: multiplier ;Modifies: D0-D3/A0-A1 ;Result: -- -P_SMUL: move.w global_precision,d3 - lsl.w #1,d3 - subq.w #1,d3 - clr.l d2 - clr.l d1 - -.loop: move.w -(a1),d1 - mulu.l d0,d1 - add.l d2,d1 - add.w d1,-(a0) - scs d2 - lsr.l #16,d1 - add.w d1,d2 - dbf d3,.loop - - move.w d2,(a0) - rts - - - END +; Copied from 3B168000.S (GG) +P_SMUL: ;mov.l 4(sp),a0 ;# fetch first argument: prod + ;PureC already puts arguments there (GG) + ;mov.l 8(sp),a1 ;# fetch second argument: multiplicand + ;mov.l 12(sp),d0 ;# fetch third argument: multiplier + ;mov.l d2,-(sp) ;# save d2 -- not a Unix-PC scratch reg +; (OK for PureC -- GG) + move.l d3,-(sp) ;# save d3 -- not a Unix-PC scratch reg + move.l d4,-(sp) ;# save d4 -- not a Unix-PC scratch reg + clr.l d2 ;# clear the carry register + clr.l d4 ;# clear upper half of temp reg for prod + adda.w #2,a0 ;# position prod to 1 beyond LSB + adda.w #2,a1 ;# position multiplicand to 1 beyond LSB + move.w global_precision,d3 ;# fetch size of multiplicand + add.w d3,d3 ; GG: convert 32bit to 16bit units + bra ddbf1 + +dloop: move.w -(a1),d1 ;# fetch multiplicand + mulu.w d0,d1 ;# multiply by multiplier + move.w -(a0),d4 ;# fetch prod + add.l d4,d1 ;# add in prod + add.l d2,d1 ;# add in carry + move.w d1,(a0) ;# store result back to prod + swap.w d1 ;# fetch carry info (upper 16 bits of mult) + move.w d1,d2 ;# and move it into carry +ddbf1: dbf d3,dloop + + move.w d2,-(a0) ;# store carry + move.l (sp)+,d4 + move.l (sp)+,d3 +; move.l (sp)+,d2 + rts + END