I am converting some C code to ZBasic.
The original C code is:
Code: Select all
if(data & 0x08) LCD_DATA3_PORT |= _BV(LCD_DATA3_PIN);
The ZBasic versions that I have thought of are:
Code: Select all
if cBool(data AND &h08) then call PutPin(_data_pins(3),ZXOutputHigh)
if (data AND &h08) > 0 then call PutPin(_data_pins(3),ZXOutputHigh)
if (data AND &h08) = &h08 then call PutPin(_data_pins(3),ZXOutputHigh)
And the C code sets the data direction register first (to 1), and Port is set to 0 pull-up, then the conditional only needs to set the Port register to 1 if the bit in the data byte is set.
In the ZBasic code, I set the pins to zxOutputHigh which I assume requires writing to the Port and DDR registers. I need to do 3 writes to port registers in C. I think ZBasic would need to do it in 4. Is there a way to cut that down to 3, similar to C?