Searching \ for 'GOTO $-1 versus GOTO $ (was: "Re: Code error")' 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/index.htm?key=code+error
Search entire site for: 'GOTO $-1 versus GOTO $ (was: "Re: Code error")'.

Truncated match.
PICList Thread
'GOTO $-1 versus GOTO $ (was: "Re: Code error")'
1997\02\20@175926 by Andrew Warren

face
flavicon
face
Andy Kunz <spam_OUTPICLISTTakeThisOuTspamMITVMA.MIT.EDU> wrote:

> > Isn't an infinite loop done with:   goto   $
>
> No, because PC has been incremented to point to the next
> instruction. Standard notation is to do it: goto $-1
>
> ....
>
> Here's a hint.  If you have to a waste time, and you would normally
> write it as
>    NOP
>    NOP
>    NOP
>    NOP
>
> try using the following instead.
>
>    goto    $+1
>    goto    $+1

   Um, Andy?

   How do you reconcile your "$-1" infinite loop with your "$+1"
   two-cycle NOP?

   The PIC's program counter is incremented before the current
   instruction is executed, but the ASSEMBLER's "program counter"
   isn't.  Perhaps you've confused the two?

   -Andy

=== Andrew Warren - .....fastfwdKILLspamspam@spam@ix.netcom.com
=== Fast Forward Engineering, Vista, California
=== http://www.geocities.com/SiliconValley/2499

1997\02\20@222750 by Andy Kunz

flavicon
face
>    How do you reconcile your "$-1" infinite loop with your "$+1"
>    two-cycle NOP?
>
>    The PIC's program counter is incremented before the current
>    instruction is executed, but the ASSEMBLER's "program counter"
>    isn't.  Perhaps you've confused the two?

I stand corrected.

"goto $-1" will jump to the instruction preceding the goto
"goto $"   will be an endless loop
"goto $+1" will jump to the next address (I was right about this one, anyway).

                                       ===== Parallax PIC16Cxx Assembler v4.7 =
====


    1    0000-                                 device  PIC16C73
    2
    3    0000-                                 org     0
    4
    5    0000- 2800                    start   goto    start
    6    0001- 2802                            goto    stop
    7    0002- 0000                    stop    nop
    8
    9    0003- 2802                            goto    $-1
   10    0004- 2804                            goto    $
   11    0005- 2806                            goto    $+1
   12
   13    0006-                                 end


                                                   ===== Errors: 0 =====

==================================================================
Andy Kunz - Montana Design - 409 S 6th St - Phillipsburg, NJ 08865
         Hardware & Software for Industry & R/C Hobbies
       "Go fast, turn right, and keep the wet side down!"
==================================================================

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