code question
Death Star Public Relations Officer
Posts: 5
Hi folks,
I am learning assembler and have a few questions.
1. here are·two sequential·commands:
mov w,#%11111110
mov !rb, w
I see this a lot, but Guenther's guide doesn't clear up for me why you can't say
mov !rb, #%11111110
Why do you have to copy the number into register W and then copy it again to where you want it? Can't you just plug the value where you need it?
2. Where is the documentation for SX/B language so I can program in it if I need to?
3. Is it possible, should it ever be necessary, to·have one SX output port feed the input of another SX chip?
Thanks -
·
I am learning assembler and have a few questions.
1. here are·two sequential·commands:
mov w,#%11111110
mov !rb, w
I see this a lot, but Guenther's guide doesn't clear up for me why you can't say
mov !rb, #%11111110
Why do you have to copy the number into register W and then copy it again to where you want it? Can't you just plug the value where you need it?
2. Where is the documentation for SX/B language so I can program in it if I need to?
3. Is it possible, should it ever be necessary, to·have one SX output port feed the input of another SX chip?
Thanks -
·
Comments
2. The SX/B documentation is online in the help file.
3. Sure -- just make sure that you don't create an electrical conflict (both outputs and in opposite states); you can prevent programming errors from doing damage by making the connection through a 1K resistor (this limits the current enough to prevent damage to either chip).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
1)
Due to the internal structure (12 bits per instruction code), the SX does not allow for instructions to directly move a constant value into a register, or for moving the contents of one register into another. So, the W register will have to be used as temporary buffer.
Actually, instead of
mov w,#%11111110
mov !rb, w
you can say
mov !rb, #%11111110
i.e. use a so-called "multi-word", or "compound" instruction. As the SX can't execute this as "native" instruction, SASM automatically translates this into two separate instructions, i.e. into
mov w,#%11111110
mov !rb, w
2)
Select "Help" and then "SX/B" in the SX-Key IDE, any you will enter into an excellent help text, created by Jon Williams
3)
Hey, I noticed that Jon was faster this time - so I have nothing to add to his advise.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Nevertheless, I was "instructed" by my wife that I better take some days off from tomorrow until Monday to visit some cities with nice Christmas markets the next days.
I finally agreed - Arghhh...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G