79366693

Date: 2025-01-18 07:11:58
Score: 1.5
Natty:
Report link

I use Bascom-Avr.

There is another way: using overlay. Basically you define 2 bytes and one Integer, but it is possible to assign the same memory space for the two variables. Even share to bytes array.

Example:

Dim mBytes(2) As Byte Dim mLsb As Byte At mBytes(1) Overlay

Dim mMsb As Byte At mBytes(2) Overlay

Dim Rd As Integer At mBytes(1) Overlay

Then, you can access mBytes as array, or mLsb and mMsb as components of Rd, or directly the Rd variable.

It only is matter of the order of mLsb and mMsb (little/big endian).

As memory is shared, that's do the trick. It is faster than shifting or doing the arithmetic...

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Coder