Why won't this assignment work?
RichardF
Posts: 168
I can do this:
· number := 234
· outa := number
but not this:
· number := 234
· outa.byte[noparse][[/noparse]1] := number
I want to pass a byte at a time to 8 pins of the outa register. Then read that byte in 8 ina pins of another prop chip. I thought any register could be treated as a variable, including addressing specific byte, word or long segments.
Thanks,
Richard
· number := 234
· outa := number
but not this:
· number := 234
· outa.byte[noparse][[/noparse]1] := number
I want to pass a byte at a time to 8 pins of the outa register. Then read that byte in 8 ina pins of another prop chip. I thought any register could be treated as a variable, including addressing specific byte, word or long segments.
Thanks,
Richard
Comments
outa[noparse][[/noparse] msb..lsb ] := value
msb is the number of the most significant bit to be used and lsb is the number of the least significant bit. In your case use:
outa[noparse][[/noparse] 15..8 ] := value
Note that you can have an msb with a lower number than the lsb. The bits are reversed in that case.
Similarly, you can read with:
value := ina[noparse][[/noparse] 15..8 ]
It isn't always clear as to addressibility (is this a word? ) of registers and variables. I would think that anything that·is saved in a contiguous area of ram should be byte, word and long adressable. Apparently not. Is it true that dira·:= 4 means that·pin·2·will be ·set to·output? I can certainly do this: dira[noparse][[/noparse]2] := 1, it seems odd that I can't use dira.byte[noparse][[/noparse]0] := 4. No logic here, just a rule, right?
In any event, to pass a byte between two Prop chips I should be able to send a byte to outa[noparse][[/noparse]7..0] in chip 1 and read it in ina[noparse][[/noparse]7..0] in chip 2, or just use outa := value_passed, ina := value_received, making sure that bits 0..7 are reserved for passing data.
Richard
There is a logic to this "rule". OUTA, INA, and DIRA are not memory locations (at least not in the hub or main memory). They are special cog memory locations that are not accessible as memory to Spin programs. The same thing is true for the other 13 long words located in the last 16 long words of cog memory. They're not byte or word addressable. Of these, only the I/O registers have this bit addressability notation that's allowed for convenience. The others are usable only as long words.