Shop OBEX P1 Docs P2 Docs Learn Events
code question — Parallax Forums

code question

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 -

·

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-11-24 19:06
    1. The second version of the instruction isn't supported by the SX -- so the assembly takes care of that for us. That said, we have to be aware of these "compound" instructions because Skip instructions only skip one -- using a skip instruction right before a compound instruction can lead to troubles.

    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
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2005-11-24 19:12
    Hi,

    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 WilliamsJon Williams Posts: 6,491
    edited 2005-11-24 19:13
    I won't be fast for long ... about to sit down to Thanksgiving turkey and Cowboys football; that'll slow me down!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2005-11-24 19:21
    Ha, thats great - too bad that we don't celebrate Thanksgiving here this way here.

    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
  • edited 2005-11-25 04:41
    Thanks to you both for clarifying that and Happy Thanksgiving. That explanation makes sense to me.·Now, I will endeavor to turn yet another exciting page in Geunther's book... : )
Sign In or Register to comment.