[sdiy] help...no make8() function in Arduino...converting PIC to AVR

dan snazelle subjectivity at hotmail.com
Wed Apr 11 18:47:20 CEST 2012


ok so if


 make8  = (((var >> (offset*8)) & 0xff)
 _mul  value = (int)( a1*val1>>8);



then since i dont quite understand the parentheses in define I could make 2 functions



byte make8(int var, byte offset)
{
byte result=(((var >> (offset*8)) & 0xff);
return result;}



and for the other function  (_mul) 


int _mul (byte a1, byte val) {

int result=(int)( a1*val1>>8);
return result;
}



do those look right?


thanks





On Apr 11, 2012, at 12:00 PM, Martin Klang wrote:

> 
> what do they do on the pic?
> 
> make8 I found in the PIC C Compiler Reference:
> i8 = MAKE8(var, offset)
> Same as: i8 = (((var >> (offset*8)) & 0xff)
> 
> so that
>> tmpbyte1 = make8(tmp1, 1);
> 
> would be
> tmpbyte1 = (tmp1 >> 8) & 0xff;
> 
> and _mul() multiplies, right?
> 
> Looks like the code is specifically optimised for the pic instructions set -
> tmp1 is 16 bit, right? acc1 and val1 8-bit unsigned integers?
> 
> Presumably you can replace the two lines with 
> uint8_t value = (uint8_t)( acc1*val1>>8);
> depending on data types, but would have to see some more code to know.
> 
> 
> hth,
> 
> /m
> 
> On 11 Apr 2012, at 16:25, dan snazelle wrote:
> 
>> can someone help me ?
>> 
>> i am trying to convert some PIC code to AVR
>> 
>> it is going fine except for 2 things
>> 
>> there is no make8() function and there is no _mul()
>> 
>> 
>> so code lines like this:
>> 
>> 
>> tmp1 = _mul (acc1, val1);
>> 
>> tmpbyte1 = make8(tmp1, 1);
>> 
>> 
>> do not work
>> 
>> 
>> 
>> i have been looking for the make8 function online so i can just write that function into my code but no luck
>> 
>> 
>> thanks for any help!
> 
> 




More information about the Synth-diy mailing list