Searching \ for '[PIC]: what does this notation mean?' 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/microchip/devices.htm?key=pic
Search entire site for: 'what does this notation mean?'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: what does this notation mean?'
2002\08\19@135455 by Scott Touchton

picon face
Hi folks,

Been seeing this notation in various bits of code, and can't quite ascertain what it really means.  Assumed it was related to pushing the program counter, or making jumps in code:

goto  $ + 1

Basically, I am confused as to what the $ represents.

Thanks,

Scott

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu


2002\08\19@140614 by Tom Messenger

flavicon
face
At 01:48 PM 8/19/02 -0400, you wrote:
>Hi folks,
>
>Been seeing this notation in various bits of code, and can't quite
ascertain what it really means.  Assumed it was related to pushing the
program counter, or making jumps in code:
>
>goto  $ + 1
>
>Basically, I am confused as to what the $ represents.

What a ripoff! You can goto Digikey and get them for $ - 1

Oh, wait, er, wrong topic.

The dollar sign - $ - means 'here'. So goto $ + 1 means to increment the pc
by one. This is used in two ways, (at least). The usual idea is that when
writing your program, you don't know where the assembler will stick your
code.  If you need to reference a nearby location, you say $ which means
where the current pc is. $ + 1 means to go to the next location.

Why would you say goto $ + 1 ? This burns two instruction cycles and can be
used to make short delays with only one program memory space used.

Other brighter folks can (and will no doubt) elaborate on this.

Tom M.

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu


2002\08\19@141443 by Quentin

flavicon
face
You are asuming correct.
$ means the current value in program counter (PC) and goto $+1  means add 1
to PC, which in this case will only move it to the next step.
goto $+2 will jump over next step,
and goto $-1 will go back one step.
Be careful how you use this. If you have say goto $+12  and you add an extra
line with in the 12 steps you are jumping, then you have to change it to
goto $+13. When you have a few of these, it gets confusing. Also when you
use macros in your code, it gets waaayy confusing.

Rather stick to labels. As a rule of thumb, I only use this notation with in
2 steps, ex:
btfss    porta, 0 ; is porta,0 released (keyup)?
goto    $-1        ; wait for keyup
;carry on with code

Quentin
qscspamKILLspamiptech.co.za
http://www.iptech.co.za

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam.....mitvma.mit.edu


2002\08\19@141445 by Andrew Warren

flavicon
face
Scott Touchton <EraseMEPICLISTspam_OUTspamTakeThisOuTmitvma.mit.edu> wrote:

> goto  $ + 1
>
> Basically, I am confused as to what the $ represents.

Scott:

The "$" represents the address of the current instruction.  "GOTO $",
therefore, is an infinite loop.

"GOTO $+1" has the same effect as a NOP... EXCEPT that it takes two
instruction cycles instead of one, so it's a more-compact way to
build small delays.

-Andy

=== Andrew Warren -- aiwspamspam_OUTcypress.com
=== Principal Design Engineer
=== Cypress Semiconductor Corporation
===
=== Opinions expressed above do not
=== necessarily represent those of
=== Cypress Semiconductor Corporation

--
http://www.piclist.com hint: To leave the PICList
@spam@piclist-unsubscribe-requestKILLspamspammitvma.mit.edu


2002\08\19@141651 by Harold M Hallikainen

picon face
On Mon, 19 Aug 2002 13:48:29 -0400 Scott Touchton
<KILLspamScott.TouchtonKILLspamspamCOMCAST.NET> writes:
> Hi folks,
>
> Been seeing this notation in various bits of code, and can't quite
> ascertain what it really means.  Assumed it was related to pushing
> the program counter, or making jumps in code:
>
> goto  $ + 1
>
> Basically, I am confused as to what the $ represents.


       $ is the address of the current instruction. So, goto $+1 skips the next
instruction (assuming there's one address per instruction, like in the
PIC16, but not in the PIC18, which has two addresses (minimum) per
instruction). I've sometimes used goto $-1 after a skp instruction so it
loops until some condition is true. It's better, though, to just give the
skip instruction a label so that later, when you migrate to another
processor, it will still work.

Harold


FCC Rules Online at http://hallikainen.com/FccRules
Lighting control for theatre and television at http://www.dovesystems.com

Reach broadcasters, engineers, manufacturers, compliance labs, and
attorneys.
Advertise at http://www.hallikainen.com/FccRules/ .


________________________________________________________________
GET INTERNET ACCESS FROM JUNO!
Juno offers FREE or PREMIUM Internet access for less!
Join Juno today!  For your FREE software, visit:
dl.http://www.juno.com/get/web/.

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu


2002\08\19@142311 by Harold M Hallikainen

picon face
On Mon, 19 Aug 2002 20:11:44 +0200 Quentin <spamBeGoneqscspamBeGonespamIPTECH.CO.ZA> writes:
{Quote hidden}

       I agree with MOST of this, but I think we need to distinguish between
the address of the current instruction and the address in the program
counter. One of the first thing the processor does in executing an
instruction is to increment the program counter, so the "current program
counter" value is a bit ambiguous.

       For example,

       goto    $+1
       nop

       executes the nop.

       However (ignoring pclath for now),

       movlw   1
       addwf   pcl,f
       nop
       movlw   something

       adds one to the program counter, causing the NOP to be skipped and the
movlw something to be executed.

       So, $ is the address of the instruction, which is indeed the current
program counter prior to the start of execution of the instruction...

       Picky picky picky!

Harold

FCC Rules Online at http://hallikainen.com/FccRules
Lighting control for theatre and television at http://www.dovesystems.com

Reach broadcasters, engineers, manufacturers, compliance labs, and
attorneys.
Advertise at http://www.hallikainen.com/FccRules/ .


________________________________________________________________
GET INTERNET ACCESS FROM JUNO!
Juno offers FREE or PREMIUM Internet access for less!
Join Juno today!  For your FREE software, visit:
dl.http://www.juno.com/get/web/.

--
http://www.piclist.com hint: To leave the PICList
TakeThisOuTpiclist-unsubscribe-requestEraseMEspamspam_OUTmitvma.mit.edu


2002\08\19@142741 by Roman Black

flavicon
face
Tom Messenger wrote:

> >Been seeing this notation in various bits of code, and can't quite
> ascertain what it really means.  Assumed it was related to pushing the
> program counter, or making jumps in code:

>
> The dollar sign - $ - means 'here'. So goto $ + 1 means to increment the pc
> by one. This is used in two ways, (at least). The usual idea is that when
> writing your program, you don't know where the assembler will stick your
> code.  If you need to reference a nearby location, you say $ which means
> where the current pc is. $ + 1 means to go to the next location.


I like these 3 home made mnemonics;
#define         skp1    goto $+1+1      ; skips one instruction
#define         skp2    goto $+1+2      ; skips 2 instructions
#define         skp3    goto $+1+3      ; skips 3 instructions
(never needed skp4)

These can really neaten-up code and avoid the use
of messy un-needed goto labels when all you want
to do is skip the next 3 instructions;

       btfss input,2           ; test input
       skp3                    ;
       movlw b'11001100'       ; input == hi, so do these 3
       movwf lastb             ;
       movwf PORTB             ;

I don't know if that makes the .asm purists cringe
but I see it as part of the natural evolution of
the .asm language that you develop new "instructions"
that make it easier to read, code, work with etc.
In many cases of .asm logic branching the goto
labels are not symbolic at all and just represent
"miss the next 3 instructions". I feel that these
particular labels can often be replaced by a neater
mnemonic, especially in complex logic trees. :o)
-Roman

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestspamTakeThisOuTmitvma.mit.edu


2002\08\19@144219 by Quentin

flavicon
face
OK, thanks for the heads up.

>Picky picky picky!
To return the favour (tongue firmly in cheek):
You said on your other reply:
So, goto $+1 skips the next instruction

;)
Quentin
qscEraseMEspam.....iptech.co.za
http://www.iptech.co.za

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspammitvma.mit.edu


2002\08\19@144614 by Scott Touchton

picon face
Just wanted to thank you all..... I am enlightened.  Great Group!
----- Original Message -----
From: Roman Black <RemoveMEfastvidEraseMEspamEraseMEEZY.NET.AU>
To: <RemoveMEPICLISTspam_OUTspamKILLspamMITVMA.MIT.EDU>
Sent: Monday, August 19, 2002 2:24 PM
Subject: Re: [PIC]: what does this notation mean?


> Tom Messenger wrote:
>
> > >Been seeing this notation in various bits of code, and can't quite
> > ascertain what it really means.  Assumed it was related to pushing the
> > program counter, or making jumps in code:
>
> >
> > The dollar sign - $ - means 'here'. So goto $ + 1 means to increment the
pc
> > by one. This is used in two ways, (at least). The usual idea is that
when
{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspamspamspamBeGonemitvma.mit.edu


2002\08\19@154053 by Wouter van Ooijen

face picon face
> goto  $ + 1
> Basically, I am confused as to what the $ represents.

Think of it as 'here', so 'goto $ + 1' means 'jump to the next
instruction. The same effect as a nop, but a goto takes 2 instruction
cycles instead of a nop just one, so it is a code-effective way to spend
two cycles. Likewise 'call x' where x is a return (use an existing
return) is a code-effective way to burn 4 cycles.

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestKILLspamspammitvma.mit.edu


2002\08\19@161025 by Olin Lathrop

face picon face
> goto  $ + 1
>
> Basically, I am confused as to what the $ represents.

The $ represents the address of that instruction.  GOTO $+1 is of dubious
value, but you may have seen GOTO $-1, which can be useful.  For example:

   btfss   portb, 3     ;is it toast yet?
   goto    $-1          ;no, go back and check again
;
;   Toasted to golden perfection.
;



*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestSTOPspamspamspam_OUTmitvma.mit.edu


2002\08\19@162726 by Olin Lathrop

face picon face
> You are asuming correct.
> $ means the current value in program counter (PC) and goto $+1  means add
1
> to PC, which in this case will only move it to the next step.

It just occurred to me that this correct for all PICs except the 18 family.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: To leave the PICList
spamBeGonepiclist-unsubscribe-requestSTOPspamspamEraseMEmitvma.mit.edu


2002\08\19@163351 by Olin Lathrop

face picon face
> I like these 3 home made mnemonics;
> #define         skp1    goto $+1+1      ; skips one instruction
> #define         skp2    goto $+1+2      ; skips 2 instructions
> #define         skp3    goto $+1+3      ; skips 3 instructions
> (never needed skp4)
>
> These can really neaten-up code and avoid the use
> of messy un-needed goto labels when all you want
> to do is skip the next 3 instructions;
>
>         btfss input,2           ; test input
>         skp3                    ;
>         movlw b'11001100'       ; input == hi, so do these 3
>         movwf lastb             ;
>         movwf PORTB             ;

I can agree with this up to a point.  The longer the skip, the greater the
chance that someone won't notice it when editing the code.  At the least,
skips longer than 1 instruction should be clearly documented at the
skipped-to point.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: To leave the PICList
KILLspampiclist-unsubscribe-requestspamBeGonespammitvma.mit.edu


2002\08\19@190513 by Nelson Hochberg

flavicon
face
$ = current opcode counter

-----Original Message-----
From: pic microcontroller discussion list
[EraseMEPICLISTspamEraseMEMITVMA.MIT.EDU]On Behalf Of Scott Touchton
Sent: Monday, August 19, 2002 10:48 AM
To: @spam@PICLIST@spam@spamspam_OUTMITVMA.MIT.EDU
Subject: [PIC]: what does this notation mean?


Hi folks,

Been seeing this notation in various bits of code, and can't quite ascertain
what it really means.  Assumed it was related to pushing the program
counter, or making jumps in code:

goto  $ + 1

Basically, I am confused as to what the $ represents.

Thanks,

Scott

--
http://www.piclist.com hint: To leave the PICList
spamBeGonepiclist-unsubscribe-requestspamKILLspammitvma.mit.edu

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestspam_OUTspammitvma.mit.edu


2002\08\20@044502 by Alan B. Pearce

face picon face
{Quote hidden}

Grief, you guys seem to be making a rod for your own back. I shudder to
think of the possibilities for having the code go into hyperspace because
you have managed to cross a page boundary.

Perhaps you all use small linkable modules, in which case you can probably
get away with it, but I can envisage making a small modification to code
where the code space is getting full, and finding it suddenly "very broke"
as the skip crosses a page boundary.

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\08\20@080420 by Olin Lathrop

face picon face
> Perhaps you all use small linkable modules, in which case you can probably
> get away with it,

Of course, as everyone should, not that I'm defending GOTO $+N instructions
where N > 2 or < -2.  If you don't guarantee each module is entirely on a
single page, you will have lots of other problems too.  Any local GOTO or
CALL becomes suspect, whether specified relative to $ or not.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\08\20@125037 by Brendan Moran

flavicon
face
> > Perhaps you all use small linkable modules, in which case you can
probably
> > get away with it,
>
> Of course, as everyone should, not that I'm defending GOTO $+N
instructions
> where N > 2 or < -2.  If you don't guarantee each module is entirely on a
> single page, you will have lots of other problems too.  Any local GOTO or
> CALL becomes suspect, whether specified relative to $ or not.

Would this still be a problem in an 18F part, or has that been cleared up in
them?

--Brendan

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\08\20@141542 by Roman Black

flavicon
face
Alan B. Pearce wrote:
> Grief, you guys seem to be making a rod for your own back. I shudder to
> think of the possibilities for having the code go into hyperspace because
> you have managed to cross a page boundary.

Hi Alan, firstly, the (2kword) page boundary doesn't
make any more difference than with a normal goto. It's
not a computed goto like a table, just that the
preprocessor and assembler do the work for you
instead of forcing you to think up a goto tag name
and use it. :o)

Second, I didn't say that I do it that way all the time,
in fact it is just for those times when it is *better*
because in assembler there are many times in logic
processing code where you test a bit, then perform an
action. The standard asm only lets you perform a
one-instruction action.
ie:
       btfsc input,2           ; test bit
       blah                    ; the one-instruction action

Many easy tasks require a superfluous goto like this:

       btfss input,2           ; test input
       goto waste_of_a_tag_147 ;
       movlw b'11001100'       ; input == hi, so do these 3
       movwf lastb             ;
       movwf PORTB             ;
waste_of_a_tag_147

I think that goto tags are much better suited to
defining "blocks" of code that perform specific
functions, instead of just a mechanism to enable
simple logic decisions. In some cases the code can
be more readable when superfluous goto tags are
removed for SOME basic decision making tasks, and
reserved for pieces of code that mean something.
More like:

       btfss input,2           ; test input
       skp3                    ;
       movlw b'11001100'       ; input == hi, so do these 3
       movwf lastb             ;
       movwf PORTB             ;

I don't do this a lot, but there are some sections
of my code that cleaned up really well using skp2
and skp3.
-Roman

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\08\20@153257 by Olin Lathrop

face picon face
> Many easy tasks require a superfluous goto like this:
>
>         btfss input,2           ; test input
>         goto waste_of_a_tag_147 ;
>         movlw b'11001100'       ; input == hi, so do these 3
>         movwf lastb             ;
>         movwf PORTB             ;
> waste_of_a_tag_147

The Microsoft X86 assembler has a special syntax for jumping forwards or
backwards to the next generic tag.  I forget the exact details, but is uses
at signs (@).  It is intended for exactly this case.  I thought is was a
nice feature, but I've never seen it on any other assembler.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\08\21@043221 by Alan B. Pearce

face picon face
>Hi Alan, firstly, the (2kword) page boundary doesn't
>make any more difference than with a normal goto. It's
>not a computed goto like a table, just that the
>preprocessor and assembler do the work for you
>instead of forcing you to think up a goto tag name
>and use it. :o)

Yeah, I appreciated it is only the 2k boundary that would cause a problem,
but I can see a beginner using your skip macro close to a 2k boundary, and
having the code go into hyperspace by adding an opcode inside the interrupt
routine down in the first 256 bytes, and having great difficulty figuring
out why things went AWOL, and he hasn't even enabled the interrupts yet :)

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


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