put and get don't work with s_wn variables in simulator

lbenson

Senior Member
"put" and "get" using, for example, "s_w0", compile but execute incorrectly in simulation.
Code:
w0 = 257
put 0, word w0
get 0, word s_w1
sertxd(#w0," = ",#s_w1,"?",cr,lf)

w0 = 0
put 0, word w0
s_w0 = 257
put 0, word s_w0
get 0, word s_w1
sertxd(#s_w0," = ",#s_w1,"?",cr,lf)
The result, for PE5, is "257 = 1?" and "257 = 0?"

In PE6, the result is different: "257 = 1?" and "513 = 1?"

In PE6, "put 0, word s_w0" results in nothing being put in the scratchpad at location 0. "get 0, word s_w1" results in only the least significant byte being retrieved.

I understand that the system variables, e.g., "s_w0" are pretty much used at the programmers risk, but one would hope that they would either work or not pass the syntax check.

peek and poke fail in the same manner.
 

hippy

Technical Support
Staff member
Many thanks for reporting the issue and we will investigate. Please accept our apologies if it's not working as expected.
 

Technical

Technical Support
Staff member
As these 'special' word variables do not have a split byte equivalent they were never designed to be used in this way (as these statements effectively do a put/get twice, once on each byte var that make up the word var). However the compiler should indeed provide a warning.

The workaround is to simply copy them into a standard var before attempting to use these commands.
 

lbenson

Senior Member
Thanks for the responses. Standard vars are pretty much used up, thus the search for additional, but I can probably swap around symbol definitions to avoid having to put/get s_w0, etc.

I'm happy to see that "put s_w0, word w27" works.

Still would like to see "put" take a constant: put w27, word 257
 

lbenson

Senior Member
I bumped into this again. In the simulator, POKE word s_w1 and WRITE word s_w1 don't work, but they do work on the real chip. Can the simulator be fixed for this use? Obviously, the fact that the system variables don't have user-addressable constituent bytes doesn't keep it from working on a real chip.
Code:
#no_data
#terminal 4800 'turn on terminal after program load--4mHz

pause 2000
w1=12345
write 0, word w1
pause 1000
read 0, word w2
sertxd("w1 & w2: ",#w1," ",#w2,cr,lf)

s_w1=w1
write 0, word s_w1
pause 1000
read 0, word s_w2
sertxd("s_w1 & s_w2: ",#s_w1," ",#s_w2,cr,lf)

poke 28, word s_w1
pause 1000
peek 28, word s_w2
sertxd("s_w1 & s_w2: ",#s_w1," ",#s_w2,cr,lf)
In the simulator, this produces:
w1 & w2: 12345 12345
s_w1 & s_w2: 12345 57
s_w1 & s_w2: 12345 57

On a real chip (e.g., 08M2):
w1 & w2: 12345 12345
s_w1 & s_w2: 12345 12345
s_w1 & s_w2: 12345 12345
 
Top