In SX Microcontrollers, SX/B Compiler and SX-Key Tool, PJMonty wrote: Lewis, Hmm, getting ugly here in SASM-land. The problem appears to be that whomever originally wrote SASM (or performed later updates) allowed nested REPT commands, but never took into account the possibility that inside a nested REPT there might be two or more sequential REPTs. In other words, they assumed this: [code]REPT 5 REPT 2 REPT 4 ENDR ; close the rept 4 ENDR ; close the rept 2 ENDR ; close the rept 5[/code] ...and never saw this coming: [code]REPT 5 REPT 2 ENDR ; close the rept 2 REPT 4 ENDR ; close the rept 4 ENDR ; close the rept 5[/code] In the second example, what ends up happening is that when SASM sees the closure for "REPT 2", it basically drops down a nesting level, since it assumes that not encountering another REPT means the code has no more nesting in it. When it then hits the "REPT 4", it dutifully starts expanding the desired number of repeats. This works great for the first pass of "REPT 4", but when it starts the next pass, it incorrectly starts using the code and number of repetitions for "REPT 2". It then continues to repeat the "REPT 2", and when that is done it finds the "REPT 4" again, and the process repeats. Here was your code: [code]rept 2 ; Outermost rept rept 3 ; 1st inner rept jmp $+1 endr ; 1st inner rept closure rept 3 ; 2nd inner rept nop endr ; 2nd inner rept closure endr ; Outermost rept closure[/code] SASM (incorrectly) expands this into: [code]jmp$ + 1 jmp$ + 1 jmp$ + 1 nop jmp$ + 1 jmp$ + 1 nop jmp$ + 1 jmp$ + 1 nop etc, etc, etc... [/code] I am not 100% sure yet, but this may require an architectural change to SASM rather than a bug fix. I have to give this some more thought for what the fix would entail (time = money) and then contact Parallax to see about whether this gets officially scheduled for fixing. Sorry for the not so upbeat news... [list]Thanks, PeterM[/list] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=157382#m157562 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)