Search code examples
basicbascom

Join two bytes in BASCOM-AVR


How can I join two bytes to make an 16-bit int variable in BASCOM-AVR?


Solution

  • You can find this in BASCOM index:

    varn = MAKEINT(LSB , MSB)
    

    The equivalent code is:

    varn = (256 * MSB) + LSB
    
    • Varn: Variable that will be assigned with the converted value.
    • LSB: Variable or constant with the LS Byte.
    • MSB: Variable or constant with the MS Byte.

    For example:

    varn = MAKEINT(&B00100010,&B11101101)
    

    The result is &B1110110100100010.