Working as designed, or compiler/interpreter bug?

vttom

Senior Member
I was just wondering... Is the following something that should work?

poke 80, pins

And by work, I mean the values at the input pins should get poked into register 80.

When I try it, I seem to get random data in register 80, not the value at the input pins (I'm using a PICAXE-14M, by the way).

Instead, I've had to do the following:

b0 = pins
poke 80, b0

This is unfortunate, because my program would be simpler and run a lot faster if I could do the former instead of the latter.
 

BeanieBots

Moderator
Until Technical answer, here's my take on it.

I would expect it to work the way you describe.
However, "pins" is not a variable in the same sense as say b0.
It has dual functionality which can represent either input or output depending on which side it is on.

pins=b0 will set the outputs.
b0=pins will put the input states into b0.

When you say "random", does the value represent your outputs?
 

Technical

Technical Support
Staff member
This is by design, because as BB points out, this is a pseudo variable that can be inputs or outputs and so can't be poked like this. However we agree that the compiler could give a warning.

What you need is either

b0 = pins 'inputs value
poke 80, b0

or
readoutputs b0 'outputs value
poke 80,b0
 

vttom

Senior Member
This is by design, because as BB points out, this is a pseudo variable that can be inputs or outputs
That's too bad. You'd think the compiler or the interpreter could figure out that "poke 80, pins" implies input pins and "peek 80, pins" implies outputs pins. An alternative would be to supply in "inpins" pseudo-variable in addition to the existing outpins. Then I could do "poke 80, inpins" and "peek 80, outpins".
 

inglewoodpete

Senior Member
vttom, I think the problem is in the way the code is tokenised. The tokens for a 'Poke' command can't reference the type of variable that is 'pins'. If the compiler was to do what you want (Poke 80, pins) , it most likely would insert the equivalent code for:

Code:
Poke temp, b0
b0 = pins
Poke 80, b0
Peek temp, b0
Which would take more memory and take longer to execute as you typing the 2 commands in longhand.
 
Last edited:

Jeremy Leach

Senior Member
Do you really need to poke the pins value? This implies that you want to take a snapshot of the values - but is this really the case??
 
Top