Society of Robots - Robot Forum
|
Robot Tutorials
|
FAQ
|
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Squirrels have fuzzy tails.
Home
Help
Search
Login
Register
Society of Robots - Robot Forum
»
Software
»
Software
»
$ + 1
Print
Author
Topic: $ + 1 (Read 3788 times)
0 Members and 1 Guest are viewing this topic.
mpuvdd
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
Logged
Any man who reads too much and uses his own brain too little falls into lazy habits of thinking-Einstein
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?
Logged
mpuvdd
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.
Logged
Any man who reads too much and uses his own brain too little falls into lazy habits of thinking-Einstein
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
Logged
Imperial College Robotics Society
www.icrobotics.co.uk
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.
Logged
Check out
my homepage
for in depth tutorials on microcontrollers and electronics.
Print
Society of Robots - Robot Forum
»
Software
»
Software
»
$ + 1