Searching \ for '[SX] how to get label in rept to work' 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: 'how to get label in rept to work'.

Exact match. Not showing close matches.
PICList Thread
'[SX] how to get label in rept to work'
2008\01\12@220839 by msmirbn/a

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

Hi,

I try to assemble the following:


rept 16
    jmp MyLabel%
    nop
MyLabel%
endr

but it says label already defined. Ive tried a few combinations but can't get anything to work.


I hoped it would assemble as:

   jmp MyLabel0
    nop
MyLabel0  
    jmp MyLabel1
    nop
MyLabel1

etc...


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

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

2008\01\14@185159 by PJMontyn/a

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

Msmirb,
Given that your desired resulting code...

    jmp MyLabel0
    nop
MyLabel0  
    jmp MyLabel1
    nop
MyLabel1
etc, etc
...is identical to this:

jmp $ + 1
nop
jmp $ + 1
nop
jmp $ + 1
etc, etc
...you could skip the whole label stuff.  What exactly is the point of this code.  Your "nop" could be any single byte of gibberish since it will never get executed anyway.  In addition, since you apparently need only 16 copies of this code, you could cut and paste it in about 30 seconds rather than trying to figure out how to get a macro to do it.

Thanks,
PeterM
---------- End of Message ----------

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

2008\01\14@190307 by msmirbn/a

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

Thanks Peter,
Sorry it was only an example for clarity, my real code does much more and I didn't want to manually work the nn in $+nn since this is prone to error if I alter the code. Copying it 16 times doesn't help readability and I then have to change 16 places if I alter the code.  If I have to I will do one of these but I would have thought there must be a proper solution as in other compilers, I just can't find it in the documentation.

Best regards
Mark
---------- End of Message ----------

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

2008\01\14@192714 by James Newtonn/a

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

Time for the naked ugly truth as I know it: The macro section in SASM has a few strange and interesting bugs. The ones I've found have been reported years ago, but the people who originally wrote the code (back in Scenix days) apparently aren't around and what they left behind is, according to the people who have seen it, a mess that no human could hope to correct without introducing more bugs than they fixed. Peter did fix some bugs years ago, much to his credit.

Having said that, I've been able to do some fairly cool things with macros in the past:

http://www.sxlist.com/techref/new/letter/news0403.htm starts from the beginning, but may point out some things that will help reguarding local and global scope in macro labels. E.g. try local variables rather than global.


http://www.sxlist.com/techref/ubicom/inst/macro.htm links to that and other interesting macro related things.


Let us know what you find.

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

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

2008\01\14@215517 by PJMontyn/a

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

Mark,
The problem is that the assembler gives up on pass 1 because it hasn't expanded the "%" into a number yet.  Because of the unexpanded "%", SASM looks in the symbol table to verify that there is no other symbols with the same name, finds the exact same symbol and flags it as an error.  This is one of those, "Is it a bug or a feature?" kind of situations.  You want the assembler to prevent duplaictae names (feature), but you want it to recognize that the "%" means you have to wait until pass two to figure out if there is a duplicate (bug ).  
The fix requires changes to the SASM source code.  I'm pretty sure there's no way to "trick" the assembler into doing what you want it to do.

Thanks,
PeterM
---------- End of Message ----------

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

2008\01\14@220659 by PJMontyn/a

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

Mark,
I played with it a bit more and realized it's really a feature and not a bug.  The problem is that the percent sign is a perfectly legitimate character to use in a label.  For example, a label like this...

L%a%b%b%e%l%
...is just a label.  For SASM to handle it differently inside a repeat could have some unintended side effects.  Specifically, any code that counted on "%" being a regular character for labels in or out of repeats would suddenly stop assembling correctly if SASM was changed to handle "%" differently inside of repeats.  Now, how many people use "%" in their label names?  Not a clue.  I would assume a small number, but I imagine they would be really annoyed when the next version of the IDE stopped assembling their code.  Not sure what the best solution would be for this.

Thanks,
PeterM
---------- End of Message ----------

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

2008\01\14@224120 by msmirbn/a

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

Peter,
Thanks, I will do it the manual way ($+nn) and just put a comment to check it if I alter the code. In general I am happy with the SX environment compared to other assemblers/compilers.

Best regards
Mark
---------- End of Message ----------

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

2008\01\15@004809 by peterverkaikn/a

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

The following will generate your example code
_myjumptable macro
 local loc
 jmp loc
 nop
loc
endm rept 16
 _myjumptable
endr
(Thanks James, for pointing us again to the power of macros)

regards peter
---------- End of Message ----------

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

2008\01\15@100723 by PJMontyn/a

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

Peter,
Nice work!  I'm not a real user of macros with the SX (sorry James) so I had to check the manual to see what was going on with your code.  Clever stuff.  Apparently, the fine folks who originally wrote SASM must have encountered a similar circumstance to Mark.  Here's what the manual says (and for those who want to play along at home, it's on page 63) :

The syntax for the LOCAL directive is
LOCAL

It declares the labels named after the directive as private symbols. Private symbols are available only
inside a macro body. These symbols are private to each invocation of the particular macro and cannot
be referenced outside of the macro body.

The private symbol is used within a macro body just like any other label. Each time the macro is
invoked, SASM will assign each private symbol a unique name of the form ??0001, ??0002, ??0003, and
so forth. The unique name will appear in the listing file in place of all uses of the text of the private
symbol.

All LOCAL directives must appear immediately after the MACRO directive and before the first actual
line of the macro body.

Cool.

Thanks,
PeterM
---------- End of Message ----------

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

2008\01\15@234436 by msmirbn/a

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

Peter+Peter,
Thanks very much, I never would have figured that out. Ill give it a go.

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

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

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