Manipulating bits Help!
ChrisG
Posts: 3
Here's hoping someone will take pity on a poor Basic Stamp programmer and tell me what I'm doing wrong with my brand new SX28.
·
I'm trying to follow the development manual, and the first sample program it has you run is a simple LED flasher, moving the inverse of rc.7 into W and then moving it back, as in 'mov w,/rc.7' 'mov rc.7,w'.· And every time I even try to assemble it, it gives me an ‘Error 1, Pass 2: Bad instruction statement' error.· It works just fine if I allow it to move the entire register 'mov rc,w', but doesn't like having its bits moved individually.· If I set the entire C register as outputs ‘mov !RC,#$FF’, and try a ‘not RC’, then all of RC toggles as I expected, and also RB.7 which I didn’t expect.
·
It will assemble with ‘mov w,rc.0’, but that has the same effect as ‘mov w,rc’, where it moves the entire register.· I can 'setb rc.7' and 'clrb rc.7' (or any other bit) easily enough, just can't seem to move anything into or out of it.· Same thing happens for any individual bit in any other register, too.·
·
Another demo program demonstrating the 'watch' directive stores '%01' into the variable 'flags', and then uses a 'watch flags.0,1,UBIN' and 'watch flags.1,1,UBIN' to look at each bit separately.· When I tried it, both 'flags.0' and 'flags.1' showed the same value '1', and when I toggled the relevant bit in the debugger, both flags.0 and flags.1 toggled together.
·
I have downloaded the latest version SX-Key v2.02.· I have ‘use SASM’ checked in the configuration menu.· Curiously, it does assemble and run when I uncheck the ‘Use SASM’ box, but it still doesn’t run properly; a ‘not RC.6’ toggles the entire RC register as well as bit 7 of the RB register.
·
Help!
·
I'm trying to follow the development manual, and the first sample program it has you run is a simple LED flasher, moving the inverse of rc.7 into W and then moving it back, as in 'mov w,/rc.7' 'mov rc.7,w'.· And every time I even try to assemble it, it gives me an ‘Error 1, Pass 2: Bad instruction statement' error.· It works just fine if I allow it to move the entire register 'mov rc,w', but doesn't like having its bits moved individually.· If I set the entire C register as outputs ‘mov !RC,#$FF’, and try a ‘not RC’, then all of RC toggles as I expected, and also RB.7 which I didn’t expect.
·
It will assemble with ‘mov w,rc.0’, but that has the same effect as ‘mov w,rc’, where it moves the entire register.· I can 'setb rc.7' and 'clrb rc.7' (or any other bit) easily enough, just can't seem to move anything into or out of it.· Same thing happens for any individual bit in any other register, too.·
·
Another demo program demonstrating the 'watch' directive stores '%01' into the variable 'flags', and then uses a 'watch flags.0,1,UBIN' and 'watch flags.1,1,UBIN' to look at each bit separately.· When I tried it, both 'flags.0' and 'flags.1' showed the same value '1', and when I toggled the relevant bit in the debugger, both flags.0 and flags.1 toggled together.
·
I have downloaded the latest version SX-Key v2.02.· I have ‘use SASM’ checked in the configuration menu.· Curiously, it does assemble and run when I uncheck the ‘Use SASM’ box, but it still doesn’t run properly; a ‘not RC.6’ toggles the entire RC register as well as bit 7 of the RB register.
·
Help!
Comments
Either paste it below or as an attachement
Also, exactly which development manual are you using? Is there a link to a downloadable version so I can check it out?
Ken
Post Edited (KenM) : 8/27/2004 3:19:20 PM GMT
or to put a bit into a byte I do this:
CLR bytevar
ADDB bytevar,bitvar ; bytevar = 0 or 1
or
CLR bytevar
SUBB bytevar,bitvar ; bytevar = 0 or 255
You cannot set individual bits of configuration registers like !RB by using SETB or CLRB
Terry
·
Okay, I’m using the SX-Key/Blitz! Development System Manual Version 2.0 available for download at http://www.parallax.com/dl/docs/prod/sx/SXKeyMan2_0.pdf, and the program that I’m having difficulty with is LED28.src - straight off of the CD included with the starter kit.
Simple enough even for someone like me to follow ... or so I thought.· Like I said, it won't even assemble due to errors on lines 15 and 16 'Error 1, Pass 2: Bad instruction statement.'
Bean, I tried replacing the ‘mov W,/RC.7’ instruction with a ‘movb W,/RC.7’ but still got the same error.
Change the code to MOVB Z,/RC.7 and MOVB RC.7,Z
Z is the zero flag and it is a bit variable.
Bean.
Thanks