News:

;) This forum is the property of Proton software developers

Main Menu

Test a bit in a byte

Started by Ecoli-557, Dec 17, 2024, 10:19 PM

Previous topic - Next topic

Ecoli-557

Hello All-
I am getting this, but I still am working under years of doing it another way.....
I have honestly looked for this but did not find out how to do this in this compiler.
Dim SPIByteIn[80]       As Byte

If SPIByteIn.0[7] = 1 Then GoTo Init
This is what I am trying to do - simple yeah but that is just brain surgery - easy if you know not what to touch <grin>.
How is this done in Positron?

trastikata

I'd assume SPIByteIn.0 is the first byte in an array and you want to test the 8th bit?

If SPIByteIn#0.7 = 1 Then GoTo Init

Ecoli-557

Yes trastikata, have you done this?

trastikata

Quote from: Ecoli-557 on Dec 17, 2024, 10:36 PMYes trastikata, have you done this?

I gave you the example. If a 16b MCU is used, the correct syntax is:

If SPIByteIn_0.7 = 1 Then GoTo Init

Ecoli-557

Ahhhh, I did not pick up on that:
If SPIByteIn#0.7 = 1 Then GoTo Init
I have replaced my line with yours and it does not give an error.
I can move forward now.
Thank you for the help.
Where is this in the manual?

trastikata

General case:

Dim bTemp As Byte
Dim SPIByteIn[16] As Byte

Main:
    'Static 8b MCU
    If SPIByteIn#0.7 = 1 Then GoTo Init
    'Static 16b MCU
    'If SPIByteIn_0.7 = 1 Then GoTo Init

    'Dynamic
    bTemp = SPIByteIn[0]
    If bTemp.7 = 1 Then GoTo Init
Init:

Ecoli-557

#6
Thank you for this, a very slight difference in the 2 compilers.

Where is this information in the manual?



John Lawton

Page 32 of the 8 bit manual, "Aliases" gives the example of a symbol:

Dim Flea as Dog.0          ' Flea is bit-0 of Dog, which is aliased to Fido

The dot is often used to specify PORT bits, e.g. PORTB.0 so this is just a similar concept.

John

Ecoli-557

Thanks John.
I was specifically wondering about the '#' in
If SPIByteIn#0.7 = 1 Then GoTo Init

John Lawton

Indeed. I think the use of # is an almost undocumented method of identifying an array member, see 8 bit manual page 200 where members of the array Buffer[4] are referred to using #
Buffer#1 = 0
Buffer#2 = -2
etc

John



Ecoli-557


Dompie

Quote from: Ecoli-557 on Dec 18, 2024, 10:06 PMThanks John.
I was specifically wondering about the '#' in .......

A very instructive source of knowledge is the assembler listing that Les generates. After compilation press <F2> and you will see the assembler listing of your compilation and that is easy to read and above all very instructive (and there you find the # too).

Johan