Hi, I while ago I posted an request for 24x24 =3D 48 and 48/24 =3D 24. Lacking replies ( apart from Nikolai's pseudo code ) I had to 'make' them myself. Not particulary hard, just tedious :). Anyway had some time during the latest days to start hammer on it and here you have the 24x24 =3D 48 bit routine. I *think* it works ( atleast on the values tested so-far ) but dont take my word on it: ; *********************************************************************** ; MULTTIPLY_24x24 - Routine to mutltiply two 24 bit numbers = ; result in 48 bits ! ; Format: Ram =3D MSB, Ram+2 =3D LSB ( for 24 bit variable ) ( little endian ? ) ; Ram used: Multiplier, Multipland 3 bytes each ( 24 bits ) = ; Product 6 bytes ( 48 bits ) = ; BitCount 1 byte for loop counting ; ; Multiplier is zero at exit ( destroyed ) ; Multipland is preserved ; Product holds result ; ; Probably more efficient to use Ram =3D LSB, Ram+2 =3D MSB ( big endian = ? ) ; According to helpful hints from Nikolai, however my requirements ; dictated the used format. ; MULTIPLY_24x24 ; preload values to test MOVLW 0xAB MOVWF Multipland MOVLW 0xCD MOVWF Multipland+1 MOVLW 0xEF MOVWF Multipland+2 MOVLW 0x98 MOVWF Multiplier MOVLW 0x76 MOVWF Multiplier+1 MOVLW 0x54 MOVWF Multiplier+2 ; these values should generate the reply =3D 0x6651AF33BC6C = CLRF Product ; clear destination CLRF Product+1 CLRF Product+2 CLRF Product+3 CLRF Product+4 CLRF Product+5 = MOVLW 23 MOVWF BitCount ; number of bits CLRC ; make sure the carry is initially cleared ADD_LOOP_24x24 ; note carry assummed to be zero ! = RLF Multiplier+2,F ; up shift multiplier one bit RLF Multiplier+1,F RLF Multiplier,F BTFSS STATUS,C ; if carry is set we must add multipland to the product GOTO SKIP_LOOP_24x24 ; nope, skip this bit = MOVF Multipland+2,W ; get LSB of multiplicand ADDWF Product+5,F ; add it to the lsb of the product = MOVF Multipland+1,W ; middle byte BTFSC STATUS,C ; check carry for overflow INCFSZ Multipland+1,W ; = ADDWF Product+4,F ; handle overflow = MOVF Multipland,W ; MSB byte BTFSC STATUS,C ; check carry INCFSZ Multipland,W ADDWF Product+3,F ; handle overflow ; carry propagation, if set then make sure if 'follows' through = MOVLW 0x01 ; preload with 1 BTFSC STATUS,C ; check carry for overflow ADDWF Product+2,F ; add one to next byte BTFSC STATUS,C ; check carry for overflow ADDWF Product+1,F ; add one to next byte BTFSC STATUS,C ; check carry for overflow ADDWF Product,F ; add one to next byte = SKIP_LOOP_24x24 ; shift and prepare for next bit ; note Carry is always assumed to be zero here ! ; should be handled by carry propagation above. = RLF Product+5,F RLF Product+4,F RLF Product+3,F RLF Product+2,F RLF Product+1,F RLF Product,F ; note carry should always be zero here ( else overflow ? ) ; affects rotate at the beginning of ADD_LOOP_24x24 DECFSZ BitCount,F GOTO ADD_LOOP_24x24 NOP NOP RETURN Use at will/risk/leisure/etc. Oh..pic-code on the pic-list what will come next ;) /Tony Tony K=FCbek, Flintab AB = =B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2= =B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2= =B2=B2=B2=B2=B2=B2=B2=B2=B2=B2 E-mail: tony.kubek@flintab.com =B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2= =B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2=B2= =B2=B2=B2=B2=B2=B2=B2=B2=B2=B2 -- http://www.piclist.com hint: PICList Posts must start with ONE topic: "[PIC]:","[SX]:","[AVR]:" =uP ONLY! "[EE]:","[OT]:" =Other "[BUY]:","[AD]:" =Ads