INA syntax in spin2
ke4pjw
Posts: 1,231
in Propeller 2
I have looked through the language reference and don't understand why why this does not compile.
dbus := INA[0..7]
I want to read p0-p7 into dbus but get the error that it is expecting a ] where .. is.
What am I doing wrong? Is there a more complete spin2 reference than this https://docs.google.com/document/d/16qVkmA6Co5fUNKJHF6pBfGfDupuRwDtf-wyieh_fbqw/edit#heading=h.nagbjtem5ytb
As always, thanks in advance.
--Terry
dbus := INA[0..7]
I want to read p0-p7 into dbus but get the error that it is expecting a ] where .. is.
What am I doing wrong? Is there a more complete spin2 reference than this https://docs.google.com/document/d/16qVkmA6Co5fUNKJHF6pBfGfDupuRwDtf-wyieh_fbqw/edit#heading=h.nagbjtem5ytb
As always, thanks in advance.
--Terry

Comments
dbus := INA[0..7] == Pinread(0 addpins 7, dbus rev 7)
Or
dbus := INA[7..0] == Pinread(0 addpins 7, dbus)
Bill M.
Also, as an OT comment, I absolutely *LOVE* the ansi_vgatext_demo! I have not thought about ANSI escape sequences in years. It's perfect for using as a debug output! Thank you for all of your work!
If I *ONLY* read the apins, I see random addresses displayed as expected from abus.
If I read apins and dpins, then the last octet of abus always equals dbus, and it is always 03.
If I read apins, dpins, and cpins, the first octet of abus is always random, the last octet of abus is 03, as is dbus and cbus.
What am I doing wrong. This is driving me crazy!
CON PINBASE = 48 _clkfreq = 250_000_000 dpins = 0 addpins 7 ' CoCo Databus pins apins = 8 addpins 15 ' CoCo Addressbus pins cpins = 24 addpins 1 ' CoCo Clock pins DAT abus word dbus byte cbus byte OBJ scrn: "ansi" PUB runtext() | n pinfloat(dpins) pinfloat(apins) pinfloat(cpins) scrn.start(PINBASE) scrn.str(string(27, "[1;1H")) scrn.str(string(27, "[0J")) repeat dbus := Pinread(dpins) abus := Pinread(apins) cbus := Pinread(cpins) scrn.str(string(27, "[1;1H")) scrn.nl() scrn.str(string("Address bus:")) scrn.hex(abus,0) scrn.nl() scrn.str(string("Data bus:")) scrn.hex(dbus,0) scrn.nl() scrn.str(string("Clock:")) scrn.hex(cbus,0)Andy
Similar results, except it is not 03. It is random but all three are the same.
Various configurations yield different results based on the order I perform the read. Something is not right, If I read only one of the three, it performs as expected.
Either my hardware is bad, but it works as expected when only reading one set of pins, or this is a compiler issue. I will try this on my P2 Edge board and see if I get similar results without ever attaching the pins to my hardware.
I don't know where to start. My code looks right. Maybe this is a problem in the ANSI display driver and the way it displays hex. Maybe it is a compiler problem. Maybe I don't know enough about what is really going on. I don't see a problem in either my code or the ANSI num or hex methods.
I can say that the last digit of all three outputs follows what the cbus inputs are. I just don't see how that can happening unless this is a hardware glitch or a memory bookeeping problem.
*OR* addpins doesn't work the way I would expect at all.
I don't think I am smart enough to figure it out. I have spent 10 hours on this and the solution eludes me.
try making abus and dbus longs also...
Mike
CON PINBASE = 48 _clkfreq = 250_000_000 DAT a long d long c long OBJ scrn: "ansi" PUB runtext() | n scrn.start(PINBASE) scrn.str(string(27, "[1;1H")) scrn.str(string(27, "[0J")) d := $A0 a := $FFFF c := $01 scrn.str(string(27, "[1;1H")) scrn.nl() scrn.str(string("Variables are:")) scrn.nl() scrn.str(string("A Long:")) scrn.hex(a,0) scrn.nl() scrn.str(string("D Long:")) scrn.hex(d,0) scrn.nl() scrn.str(string("C Long:")) scrn.hex(c,0) scrn.nl() scrn.str(string("Variables should be:")) scrn.nl() scrn.str(string("A Long:")) scrn.hex($A0,0) scrn.nl() scrn.str(string("D Long:")) scrn.hex($FFFF,0) scrn.nl() scrn.str(string("C Long:")) scrn.hex($01,0) scrn.nl()A Long: 01
D Long: 01
C Long: 01
Variables should be:
A Long: A0
D Long: FFFF
C Long: 01
If you comment out c := $01, then all three are then FFFF.
DAT
a long 0
d long 0
c long 0
you need to provide a value in dat sections else they refer to the same memory location, maybe word and byte will then work too...
Mike
There is a use-case for the syntax you're using, as I demonstrated in my Christmas light code. In this case I declared Colors without a value to use like an array to make the code easier to understand. Without a value, Colors has the same address as DimRed.
I know there is plenty of spin 1 code out there where the value is not declared in the DAT section.
Getting hung up on a syntax bugaboo like this is maddening. Thank you everyone for pointing this out!
Again, thanks everyone.