mikep wrote:Can you confirm that this is the correct way of doing it
It is indeed. Eventually, we'll need an application note describing the nuances of using inline C and assembly language. Since you're familiar with using avr-gcc, you likely already know everything that is necessary.
There currently isn't a good way to share constant values between ZBasic code and inline assembly code. One way to get the desired effect is to use a variable with a Constant attribute and an initial value.
Code: Select all
Private foo as Byte = &H55 Attribute(Constant)
Sub Main()
Debug.Print foo
#asm
out %0, %1
:
: "I" (_SFR_IO_ADDR(PORTB)), "r" (zv_foo)
#endasm
End Sub
I've given some thought to emitting ZBasic constants as #define preprocessor macros. That may be the best way to accomplish the desired effect.