Searching \ for '[SX] Simple Code Question' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/ubicom/devices.htm?key=sx
Search entire site for: 'Simple Code Question'.

Exact match. Not showing close matches.
PICList Thread
'[SX] Simple Code Question'
2005\07\30@221457 by JJHawgn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, JJHawg wrote:

Hi all...

I was going to start a new thread with this question, but found this one to add on to.

Regarding this set of special move instructions, Scenix surely went to a lot of trouble to incorporate them into the instructions set, but I have found very few times I was able to use them.

Is there a programming construct that I am missing?  Can anyone provide examples of how these would be used in an effective way?

Thanks,
Jim
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=60809#m82609
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\07\31@112852 by TD-Linuxn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, TD-Linux wrote:

There is no reason that you should use these. You probably always use the expanded machine language equivalent. In fact, most people do, because it is the same thing. I think Scenix/Ubicom did this to try to lower the learning curve for the SX, by making an easier transition from Basic. Or, perhaps, to pretend to have a massive instruction set so that Z80 programmers would be happy. Or possibly because the assembler's programmers were very bored that day.  :turn:

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=60809#m82631
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\07\31@115244 by TD-Linuxn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, TD-Linux wrote:

There is no reason that you should use these. You probably always use the expanded machine language equivalent. In fact, most people do, because it is the same thing. I think Scenix/Ubicom did this to try to lower the learning curve for the SX, by making an easier transition from Basic. Or, perhaps, to pretend to have a massive instruction set so that Z80 programmers would be happy. Or possibly because the assembler's programmers were very bored that day.  :turn:

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=60809#m82633
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\07\31@143145 by g_daubachn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, g_daubach wrote:

TD-Linux,
sorry, I can't agree. MOV instructions with modifiers like "/", "++", "--", "<<", ">>", "<>", and "fr-W" are not equivalents to "expanded machine language instructions". They are in fact single word, sincle cycle instructions (in turbo mode).

As stated before in this thread,
MOV W, /fr is executed within one clock cycle, where the functional equivalent
MOV W, fr
NOT W
"eats up" two clock cycles, and two words in program memory.

There are good practical reasons for such modified instructions, and I'm glad that Scenix/Ubicom has implemented them when designing the SXes. For example, let's assume port B configured with all pins as inputs with internal pull-ups active, and push-buttons connected to all of these pins pulling them low when pressed.

With no button pressed,
MOW W, rb would set W to $FF, and with the button at RB.0 pressed, W would be set to $FE, i.e. this is negative logic (we Germans are said to mostly think this way - Arghhhh).

If you'd use
MOW W, /rb instead, the results would be
$00 or
$01 instead. I think, this looks much more "positive" :-)
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=60809#m82643
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\07\31@152116 by TD-Linuxn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, TD-Linux wrote:

Oh, really? I always thought that the SX had an instruction set similar to the PIC, and the compiler did all the work. Not any more.   :rolleyes:

I have never seen them used at all, which is odd, considering that they do fairly common tasks. Thank you for pointing them out! Will use in my next tight timing loop (which will also be my first  ;-)  ). I'm new to SX - which means I take in information too fast  :burger:

Editing my other post to avoid confusion.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=60809#m82646
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\07\31@154158 by g_daubachn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, g_daubach wrote:

Well,
Let me tell you a secret: There are some similarities between the many PICs and the few SXes but we should not discuss them here in detail because this forum is dedicated to the SX controller, the "better one" - I hope noone will kill me for this.

FYI: Besides the one-word/one cycle instructions, SASM, the SX assembler also supports many "expanded machine language instructions" which I usually call "compund instructions". For example,
MOW fr, #$55 can't be directly executed by the SX. SASM converts this into the sequence
MOV W, #$55
MOV fr, W i.e. into two single word/single cycle instructions.

Please be aware that such compound instructions can cause some real trouble when they a placed after a skip instruction:

SZ
MOV fr, #55 is good for a desaster as this expands to
SZ
MOV W, #55
MOV fr, W i.e. the
MOV W, #55 is skipped or not, depending on the status of the Z flag, but
MOV fr, W is always executed (either with the expected value in W, or some arbitrary nonsense).

Fortunately, the latest version of SASM gives you a warning on such constructs.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=60809#m82647
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)


'[SX] Simple Code Question'
2005\08\01@035155 by beann/a
flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, bean wrote:

Good info Gunther, what usually get me into trouble is forgetting that MOV fr,#55 will also make W equal to #55.
Bean.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=60809#m82673
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\08\01@055727 by g_daubachn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, g_daubach wrote:

Bean,
yes this is another important point I forgot to mention. Many "compound" instructions make use of W as temporary register, so code like this mov W, #11
mov fr, #55 ends up in both, fr and W containing 55, and W does not contain 11 as one might expect on first glance as this sequence is expanded into mov W, #11
mov W, #55
mov fr, W
So, "compound" instructions are nice shorthands, on the other side, they can be dangerous. You can always avoid such pitfalls by simply not using them as each can be replaced by two or more "native" SX instructions. This does not increase the code size, it is just more typing work. Sometimes, not using "compund" instructions can even save code, like the following example shows:

mov !RB, #$ff
mov !RC, #$ff is expanded into mov W, #$ff
mov !RB, W
mov W, #$ff
mov !RC, W i.e. into four instruction words. Using ""native" instructions, i.e. the sequence mov W, #$ff
mov !RB, W
mov !RC, W results in only three instruction words, as there is no need to re-load W with $ff in this case.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=60809#m82678
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\08\01@221845 by JJHawgn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, JJHawg wrote:

I appreciate the info in the previous posts...

As I think about these move instructions, they all help answer a "what if" question, "what would be in fr if I had decremented it?"
So, for instance, if you wanted to decrement a counter to 1, and not less, you could use this:

mov w, --Counter
sz
dec  Counter
Or a more universal impementation (useable with all of the special move instructions) would be to conditionally copy w to fr, like:

mov w, --Counter
sz
mov Counter, w
In the simple case of inc/dec however, you could just "put it back" if you didn't like the result, like:

dec Counter
sz
inc Counter
I don't want to beat this to death, but as I mentioned earlier, Scenix must have had something special in mind for these instructions.  I may dig into some of their VP code to see if they used any of them.

Thanks for thinking about this...

Jim
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=60809#m82823
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\08\04@134648 by James Newtonn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, James Newton wrote:

You might be interested in looking at the bock diagram of some microcontroller or microprocessor designs. One of the things you notice is that the logic unit that does stuff like inc, dec, shift, swap, negate, etc... has to be connected in-line with the registers and accumulator wether it is used or not. It doesn't take any more time to turn it on while you are moving data than it does to leave it of. So why not provide opcodes that allow that to happen? It turns out that it takes more logic to turn OFF the ALU for op codes that don't use it than it does to just "hardwire" the bits in the opcode that select the ALU operation to the ALU and let them be active for a wider range of operations.

I'm not sure I said that in a way that will inc or dec everyones confusion counter but in general, I'm saying that it would probably require more logic in the chip to NOT provide those "move with operation" instructions than it does to just let them happen.

CPU design is fun.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=60809#m83196
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\08\04@194133 by KenMn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, KenM wrote:

Which is why I avoid such instructions and use the "root" instructions


mov w,#55 mov fr,w

[Quoting: "Bean (Hitt Consulting)"]
what usually get me into trouble is forgetting that MOV fr,#55 will also make W equal to #55.
Bean.


---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=60809#m83242
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\08\05@090317 by JJHawgn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, JJHawg wrote:

Thanks for the reply James, I know exactly what you mean.

If what you said is true then the task is to figure out what these instructions are good for... ;-)
Just for the record "mov  w, <<fr" can be handy for putting the high-order bit of a register into the carry bit in preparation for an arithmetic right shift using "rr  fr".

And, of course, "mov w, <>fr" is handy for dealing with hex to ASCII conversions without messing with the actual source value in the register.


Thanks for everyone's input.


Jim G.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=60809#m83291
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\08\05@131600 by g_daubachn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, g_daubach wrote:

When looking at the instruction set of a processor/controller, in most cases, you will find some instructions that make you think "what are these good for?". Don't worry, one day, you will be glad that they are there.

For example, when I started with the SX I was wondering about the SKIP instruction, asking me why should I ever use an instruction that always skips the next one, I could always leave out the SKIP and the next instruction.

Later, when dealing with code to handle the IC protocol, I found a good use for SKIP: To handle the bus timing, you sometimes need a delay routine for a certain period - let me call it T1 here, but sometimes you need to delay twice as long, i.e. T * 2, or T2. Here is a code snippet for this using the SKIP instruction:

DelayT1
 mov w, #Delay
 SKIP
DelayT2
 mov w, #Delay * 2
 mov  DelayCounter, w
:Loop
 decsz DelayCounter
 jmp :Loop
ret
As you can see, the SKIP is used here to skip the initialization of W for the longer delay in case DelayT1 is called. Using SKIP instead of a JMP requires two clock cycles instead of three - not a big deal but "tricky" :-) .

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=60809#m83344
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\08\05@150911 by Peter Van der Zeen/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Peter Van der Zee wrote:

Hey Guenther;
While you're on the SKIP instruction, it is very useful to turn a DECSZ into a DECSNZ or an INCSZ into a INCSNZ.

Simply use the standard DECSZ followed by the SKIP ; see the following snippet for an example to SKIP a JUMP (or whatever other instruction you lke) when the variable is NOT zero. Very handy!


DECSNZ:        DECSZ       Variable                  ;this will skip the next instruction if the variable equals zero
                     SKIP                                        ;the variable was not zero, so now this instruction will skip the next instruction
                     JUMP          Wherever                ;this (arbitrary) instruction is executed when the variable is zero, and will be skipped when the variable is non-zero
Cheers,
Peter (pjv)
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=60809#m83364
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\08\05@151227 by g_daubachn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, g_daubach wrote:

Hey Peter,
good trick - I owe you a beer!

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=60809#m83365
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\08\05@151531 by Peter Van der Zeen/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Peter Van der Zee wrote:

Hi;
Next time I'm in Germany I'll probably look you up! It would be fun to share experiences and compare notes.

And, of course, I'd be happy to take that beer off your hands!

Peter (pjv)
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=60809#m83367
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\08\05@151734 by g_daubachn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, g_daubach wrote:

Peter,
the beer is for granted - I'm living in the Cologne area, i.e. not that far away from your location. I'd be glad meeting you some day - just let me know then you are around.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=60809#m83368
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\08\05@152313 by Peter Van der Zeen/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Peter Van der Zee wrote:

Guenther;
Perhaps you are thinking of one of the other chaps; but I live in Canada, and I think that a ways from Cologne!

But I'll come and see you regardless; It'll be worth the trip. And if you ever want to see the Rocky Mountains or Banff and Lake Louise, I'd be happy to host you!

Cheers,
Peter (pjv)
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=60809#m83370
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

2005\08\05@164748 by g_daubachn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, g_daubach wrote:

Peter,
sorry, I obviously have messed up the various "Peters" on this forum thinking of one, living a bit closer to Cologne :-) .

Nevertheless, should you make it to Germany, please let me know in time - you are more than welcome here at any time. I also appreciate your hosting offer. So far, I only had the chance to visit Canada/Toronto just once, besides the many trips to the US (about 40 so far).

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=60809#m83383
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)

More... (looser matching)
- Last day of these posts
- In 2005 , 2006 only
- Today
- New search...