go_away

Author Topic: $ + 1  (Read 1890 times)

0 Members and 1 Guest are viewing this topic.

Offline mpuvddTopic starter

  • Jr. Member
  • **
  • Posts: 19
  • Helpful? 0
$ + 1
« on: March 29, 2008, 09:38:37 AM »
HI everyone,
I'm learning C and some assembly language currently, and was told that $ + 1 would delay 2 instruction cycles instead of 1.  Shouldn’t it just take 1 instruction cycle?  How's that work?  Also, $ does stand for PCL, right?

Thanks,
mpuvdd
Any man who reads too much and uses his own brain too little falls into lazy habits of thinking-Einstein

Offline bulkhead

  • Full Member
  • ***
  • Posts: 102
  • Helpful? 0
Re: $ + 1
« Reply #1 on: March 29, 2008, 10:40:19 PM »
Which assembly language standard is this for?

Offline mpuvddTopic starter

  • Jr. Member
  • **
  • Posts: 19
  • Helpful? 0
Re: $ + 1
« Reply #2 on: March 29, 2008, 11:44:19 PM »
I'm not sure?  I'm using MPLAB IDE as a compiler, but that's all I know.
Any man who reads too much and uses his own brain too little falls into lazy habits of thinking-Einstein

Offline hazzer123

  • Supreme Robot
  • *****
  • Posts: 460
  • Helpful? 3
Re: $ + 1
« Reply #3 on: March 30, 2008, 09:04:54 AM »
I think that $ + 1 is shorthand for adding 1 to the PC register (program counter).

In a normal instruction, where the PC isnt modified, the PC automatically increments itself (which doesn't take a cycle). But when it's been modified, the MCU has to first jump to the new location (which takes a cycle) , before executing it. This adds the extra cycle. The $ + 1 just tricks the MCU into thinking the PC has been modified.

I think thats basically it.

Heres a webpage which goes into more detail (see the pipelining section) - http://www.mikroe.com/en/books/picbook/2_01chapter.htm
Imperial College Robotics Society
www.icrobotics.co.uk

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
Re: $ + 1
« Reply #4 on: March 30, 2008, 01:35:16 PM »
$ is a symbol reffering to current line. It's a shorthand for doing short jumps (although longer ones can be performed, too).
Less labels mean less clutter, so instead of doing a jump with "goto here", you can simply write "goto $+2".
it will not alter the PC in any different way than a goto does. It's just a different way of determining the jump location.
Check out my homepage for in depth tutorials on microcontrollers and electronics.

 


Get Your Ad Here

data_list