DEAR TO ALL, I AM DEALING WITH C8051F120 MICROCONTROLLER.UTILIZING 16 X 16 MAC ENGINE OPERATION.I AM DOING ASSEMBLY LANGUAGE PROGRAMMING USING THIS MICROCONTROLLER FOR MULTIPLICATION. IS IT POSSIBLE TO MULTIPLY TWO UNSIGNED 16 BIT INPUTS? IF YES, THEN HOW ?
tried answers are different first input msb bit is set so our MAC Engine treating it as signed integer i dont want any signed operation i need only what calculator gives. Mr.Erac told to do shift operation. But how can we tell whether the inputs msb bit is set or not in my application data is 16 bit datas are getting from one equipment and we have to multiply the two and do further operation that is why i am asking you all that whether any bit setting for signed or unsigned operation in C8051F120
PLEASE THIS ENTIRELY HARDWARE DEPENDENT QUESTION
that is why i am asking you all that whether any bit setting for signed or unsigned operation in C8051F120
There isn't. At least not officially and described in the datasheet.
However, you could break up a 16x16 unsigned multiplication into four 8x8 unsigned multiplications and a few bit-shifts and adds. That may or may not be faster than the method I described earlier, which doesn't make use of the MAC unit at all.
YES,I TRIED WITH THE MULTIPLICATION YOU EXPLAINED DO YOU KNOW ,WITH MAC ENGINE WITHIN TWO SYSTEM CYCLE WE WILL GET ANSWER THAT IS WHY WE OPTED C8051F120
"But how can we tell whether the inputs msb bit is set or not"
The same way you'd test any bit, or the MSB in any byte, surely?
"THIS ENTIRELY HARDWARE DEPENDENT QUESTION"
So why are you asking it in the Keil forum - as Keil have nothing to do with this hardware?!
HARDWARE DEPENDENT MEANS 8051 HARDWARE I MEAN IT AS ASSEMPLY LANGUAGE PROGRAMING
Your Caps-Lock is stuck again - you're writing in ALL CAPITALS again.
"WITH MAC ENGINE WITHIN TWO SYSTEM CYCLE WE WILL GET ANSWER"
But, apparently, only with signed values
"THAT IS WHY WE OPTED C8051F120"
You missed the bit about signed values, then? I agree, it's very annoying when that happens - but that's life!
:-(
DO YOU KNOW ,WITH MAC ENGINE WITHIN TWO SYSTEM CYCLE WE WILL GET ANSWER
Well, the datasheet for the device clearly states that the MAC engine does 16x16 signed integer multiplications (which is quite usual for MAC units, since signed/signed is the multiplication type usually used in DSP applications).
There's no way of getting a 16x16 unsigned/unsigned result out of the MAC engine in just two cycles, if it's supposed to be accurate. You'll have to break the multiplication up into several parts, or use the 8051's MUL command. I don't know from the top of my head which one is faster, but I guess it's going to be the former.
"But how can we tell whether the inputs msb bit is set or not" why 'tell', shift ALL inputs one right, if you do not shift ALL inputs, you will have a true mess.
I answered your first SHOUT because you might be SHOUTING being unaware of the implications (rude and difficult to read), but when you start SHOUTING again (as below) after being asked to stop, I see no reason to help you if you persist.
Erik
hi Mr.Christoph Franck and others, thank you for your reply.what is the use of MAC0RS bit in C8051f120
I searched about that bit pdf files,but in vane can you help me?
"I searched about that bit pdf files,but in vane"
Really?
What about page 170?
www.silabs.com/.../C8051F12x-13x.pdf
what is the use of MAC0RS bit in C8051f120
The chips datasheet states, on page 162:
When set to 1, the 40-bit MAC0 Accumulator register will be shifted during the next SYSCLK cycle. The direction of the shift (left or right) is controlled by the MAC0RS bit. This bit is cleared to ‘0’ by hardware when the shift is complete.
Setting this bit to 1 therefore instructs the MAC engine to do a 1-bit bitshift on the accumulator of the MAC engine. The direction of this shift can be controlled with another bit in the same register.
MAC0SC: Accumulator Shift Control.
After reading this section i searched for MAC0RS bit in the include files,for getting more about this bit.
do you know which register contain this bit? help me please
Mr.Christoph Franck, first of all i am thanking you for giving immediate response. now discussion:
After reading the part you pointed out,i got confused that whether MAC0SC and MAC0RS are equal because no where i saw any further description about that bit.
may i interrupt you asking other question?
if yes my question is:
ACALL and LCALL how we utilize in program?
because i have to reduce execution time
guide me for this question : how many ways we can reduce code size
MAC0SD and MAC0RS seem to refer to the same bit (the one that controls the direction of the bit-shifts). MAC0SC is the bit that actually triggers the bit shift.
You can use ACALL to call a subroutine within the same 2 kB page of the code memory. Else you have to use LCALL. ACALL and LCALL take the same number of processor cycles, but ACALL only takes two bytes, while LCALL takes three.
ACALL and LCALL have the same execution time.
That is a question that's usually treated in large books. Especially since you also say that you need to reduce the execution time, too - quite often, you need to make a tradeoff between code size and execution time.
You can unroll loops, which makes the program faster, but larger, for example.
You can use macros instead of function calls, which also makes the program faster, but larger.
You can calculate any math functions you need, or you can use lookup tables. The former usually leads to slow, but small code, while the latter takes up a lot of space, but can be very fast.
You are right - the Datasheet says what the MAC0RS bit does, but omits to tell you where it is!
But that is a fault in the SiLabs Datasheet - it has nothing to do with Keil. Therefore you should direct this question to SiLabs!
"ACALL and LCALL how we utilize in program?"
Sounds like you need a basic 8051 assembler tutorial, then?
Have you read Chapter 2 of the so-called "bible" for the 8051?
Chapter 1 - 80C51 Family Architecture: www.nxp.com/.../80C51_FAM_ARCH_1.pdf
Chapter 2 - 80C51 Family Programmer's Guide and Instruction Set: www.nxp.com/.../80C51_FAM_PROG_GUIDE_1.pdf
Chapter 3 - 80C51 Family Hardware Description: www.nxp.com/.../80C51_FAM_HARDWARE_1.pdf
Here are some other introductory & reference materials: http://www.keil.com/books/8051books.asp www.8052.com/books.phtml www.8052.com/tutorial.phtml
"That is a question that's usually treated in large books."
It is a common fallacy that the mere act of writing in assembler will inherently give you fast, tight code.
This is simply not true: it takes a great deal of skill and experience to write fast, tight code in any language! Sure, assembler gives you more opportunities - but you need to know how to use them!
If you need to ask basic questions like how to use ACALL and LCALL, you're probably not quite ready to be turning out super-optimised code...
You might even find that the compiler can do a better job - especially with optimisations enabled (but then that gives you the issues with debugging - which comes back to skill & experience)