Hint for using avr200.asm code in my C program for 8 by 8 bit unsingned/signed multiplication

Thread Starter

Tanushree Banerjee

Joined Dec 9, 2015
3
Hello!

I have learned that fast and optimised 8 by 8 bit multiplication code is available for AVR 8 bit microcontrollers from the below link :

ftp://www.inf.fh-dortmund.de/pub/contributors/rottke/ATMEL/APPLICAT/AVR200.PDF

The code was found over here :
https://people.ece.cornell.edu/land...DENTPROJ/1999to2000/mlk24KATZ/code/avr200.asm

And also here:

http://elm-chan.org/docs/avrlib/mul08.txt

The 'mpy8u' subroutine is for unsigned 8X8 bit multiplication, which I'm interested in.

But however I'm not very sure how to integrate it with my normal C code for building on Atmel Studio 7.

I'm not very used to assembly language coding. Sorry :(
Say I have ,

void main()

{

uint8_t a = 23;
uint8_t b = 46;
//multiply a * b using ASM code

}

Now how to use the above assembly code for that, I couldn't figure out.

Any help will be appreciated very much. Thanks in advance!
 

MrChips

Joined Oct 2, 2009
26,481
Atmel AVR has a MUL instruction.
You can multiply the contents of any two registers (8 bit each). The result is left in R1,R0.

You can add inline asm code, e.g.

asm ("mul R4,R5");

although it would be better to create a multiply function in asm and then call it from C.
 
Top