Truncated match.
PICList
Thread
'Multiplication'
1997\02\24@155204
by
David Novak
Why can't I use multiplication with MPLABC and the 16C63? I get all kinds
of errors when I attempt it. Is it not possible, or am I doing something
wrong?
Thanks,
David Novak
Hopkins Mfg.
spam_OUTnovakTakeThisOuT
valu-line.net
1997\02\24@182750
by
Andy Kunz
At 02:44 PM 2/24/97 -0600, you wrote:
>Why can't I use multiplication with MPLABC and the 16C63? I get all kinds
>of errors when I attempt it. Is it not possible, or am I doing something
>wrong?
The 16C parts don't have hardware multiply.
If using software, how about posting the routine.
Andy
==================================================================
Andy Kunz - Montana Design - 409 S 6th St - Phillipsburg, NJ 08865
Hardware & Software for Industry & R/C Hobbies
"Go fast, turn right, and keep the wet side down!"
==================================================================
1997\02\25@125957
by
David Novak
|
This code:
long i, j;
i =j*5;
causes these errors:
ERROR C:\MPLAB\MPLABC14.LIB 20:16:ILLEGAL OR UNDEFINED ARGUMENT _t 1
ERROR C:\MPLAB\MPLABC14.LIB 21:7:EXPECTED ;,
ERROR C:\MPLAB\MPLABC14.LIB 21:7:EXPECTED , got s
ERROR C:\MPLAB\MPLABC14.LIB 24:5:ILLEGAL OR UNDEFINED ARGUMENT R1 .. 6
ERROR C:\MPLAB\MPLABC14.LIB 25:5:ILLEGAL OR UNDEFINED ARGUMENT R1 .. 6
ERROR C:\MPLAB\MPLABC14.LIB 26:5:ILLEGAL OR UNDEFINED ARGUMENT R1 .. 6
ERROR C:\MPLAB\MPLABC14.LIB 27:12:ILLEGAL OR UNDEFINED ARGUMENT R1 .. 6
ERROR C:\MPLAB\MPLABC14.LIB 35:14:ILLEGAL OR UNDEFINED ARGUMENT _r 2
ERROR C:\MPLAB\MPLABC14.LIB 36:14:ILLEGAL OR UNDEFINED ARGUMENT _q 2
ERROR C:\MPLAB\MPLABC14.LIB 37:14:ILLEGAL OR UNDEFINED ARGUMENT _s 2
I find this very disturbing since a file named ctutor.c which shipped with
the compiler contains this code:
#include <16c54.h>
#include <math.h>
unsigned int Num1=2, Num2=3; // Declare two eight bit numbers.
unsigned long Num3; // Declare one long for the result.
unsigned int Num3High @ &Num3+1; // Create an address for the top
byte.
void main() {
while(1) {
Num3 = Num1 * Num2; // Multiply the two bytes into a
long.
}
}
Thanks,
David Novak
Hopkins Mfg.
.....novakKILLspam
@spam@valu-line.net
----------
> From: Andy Kunz <montana
KILLspamFAST.NET>
> To: .....PICLISTKILLspam
.....MITVMA.MIT.EDU
> Subject: Re: Multiplication
> Date: Monday, February 24, 1997 5:25 PM
>
> At 02:44 PM 2/24/97 -0600, you wrote:
> >Why can't I use multiplication with MPLABC and the 16C63? I get all
kinds
{Quote hidden}> >of errors when I attempt it. Is it not possible, or am I doing something
> >wrong?
>
> The 16C parts don't have hardware multiply.
>
> If using software, how about posting the routine.
>
> Andy
> ==================================================================
> Andy Kunz - Montana Design - 409 S 6th St - Phillipsburg, NJ 08865
> Hardware & Software for Industry & R/C Hobbies
> "Go fast, turn right, and keep the wet side down!"
> ==================================================================
'Multiplication'
2000\03\11@121858
by
Saurabh Sinha
part 0 16 bytes
</x-html>
2000\03\11@124840
by
Byron A Jeff
> Hi,
>
> I needed some help in multiplication.
>
> I needed to multiply a 24 and a 8 bit number -> result 32 bits
You can do it the old fashioned shift and add method. Take the 24 bit
value and for each of the 8 bits, shift it one bit to the left. The rlf
instruction for each of the 4 bytes (because once you start shifting the
24 bits will expand to 32 bits) will do the job. Then for each bit in the
8 bit multiplicand, if it's a one add it to the product.
Something like this:
--------------------
mult24x8:
clrf prod0 ; Clear the product
clrf prod1
clrf prod2
clrf prod3
clrf twofour3 ; Clear the top byte of the multiplicand
multloop:
movf eight,W ; Check to see if eight bit is empty
btfsc STATUS,Z ; Done if zero
return
bcf STATUS,C ; clear carry
rrl eight,F ; Get the next bit
btfss STATUS,C ; Add if carry is set
goto multshift ; shift only if 0
movf twofour0,W ; Add the 32 bits of multiplicand to product
addwf prod0,F ; each addwf sets the carry
btfsc STATUS,C ; Don't increment if no carry
incf prod1,F ; Add one to next byte if carry occured
movf twofour1,W ;
addwf prod1,F ;
btfsc STATUS,C ; Don't increment if no carry
incf prod2,F ; Add one to next byte if carry occured
movf twofour2,W ;
addwf prod2,F ;
btfsc STATUS,C ; Don't increment if no carry
incf prod3,F ; Add one to next byte if carry occured
movf twofour3,W ;
addwf prod3,F ;
multshift:
bcf STATUS,C ; clear carry
rlf twofour0,F ; Shift the 24 bits one bit to the left
rlf twofour1,F
rlf twofour2,F
rlf twofour3,F
goto multloop
------------------------------------------------------------
I wrote this off the top of my head and I haven't tested it, but it should be
in the ballpark.
Not speedy, but should work.
BAJ
>
> Also, could someone please explain how the comf instruction works...
>
> eg. comf 1111 -> 0000 ? Is that right?
Yes. it just flips each bit.
BAJ
2000\03\13@115202
by
jamesnewton
More... (looser matching)
- Last day of these posts
- In 2000
, 2001 only
- Today
- New search...