![]() | ![]() | ![]() |
| |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
![]() |
| | Tools |
| | #1 |
|
Just a quick question. What does the $ symbol mean/equate in this code mean? It is not in my pic mcu quickchart. The code needs to go into a 16f870. I found this code in a delay code generator at piclist.com http://www.piclist.com/techref/picli...egen/delay.htm ; Delay = 0.5 seconds ; Clock frequency = 4 MHz ; Actual delay = 0.5 seconds = 500000 cycles ; Error = 0 % cblock DELAYP5 DELAYP5_1 DELAYP5_2 endc DelayP5 ;499994 cycles movlw 0x03 movwf DELAYP5 movlw 0x18 movwf DELAYP5_1 movlw 0x02 movwf DELAYP5_2 DelayP5_0 decfsz DELAYP5, f goto $+2 decfsz DELAYP5_1, f goto $+2 decfsz DELAYP5_2, f goto DelayP5_0 ;2 cycles goto $+1 ;4 cycles (including call) return | |
| |
| | #2 |
|
$+2 means goto the next 2 instruction. Code: decfsz DELAYP5_1, f goto $+2 decfsz DELAYP5_2, f goto DelayP5_0 EDIT: you can use MPLAB to see the disassembler listing (if not mistaken), see where address it goes.
__________________ bananasiong Last edited by bananasiong; 15th March 2007 at 02:52 AM. | |
| |
| | #3 |
|
$ is the symbol for Present Location 1. goto $ will loop forever given no interrupts intervene. 2. goto $ + X will skip forward X instructions. 3. goto $ - X will skip backward X instructions. P.S. When a delay routine is this ugly, you should just make up your own and make it paramatized so that one routine can suffice for most your long delay times. | |
| |
| | #4 |
|
FYI, $+11 is not the next 11 instruction but next 17. $+0B is the next 11th instruction. I've tried without a '0', i.e. $+B and it doesn't work.
__________________ bananasiong | |
| |
| | #5 |
|
You must always be away of the default radix or use definitive expressions. If you want to skip eleven you do this: GOTO $ + .11 GOTO $ + 0X0B GOTO $ + 0BH GOTO $ + B'00001011' Or do this: RADIX DEC GOTO $ + 11 This is true for every single line of opcode and not just goto's. | |
| |
| | #6 |
|
add this-> "RADIX DEC"? What does it mean? something relavent to decimal?
__________________ bananasiong | |
| |
| | #7 |
|
If not mistaken, it changes the default way that the compiler interprets numerals from a base (or radix) of sixteen (hex) to a base of ten (decimal). Otherwise, it is good common practice to pre/post-fix all numerals as donniedj shows at the top of his post above.
Last edited by TekNoir; 15th March 2007 at 06:00 PM. | |
| |
|
| Tags |
| delay, question, symbol |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| Speedometer | Kiko | Micro Controllers | 131 | 29th November 2007 06:33 PM |
| Log Data using pic16F877A | williB | Micro Controllers | 32 | 31st October 2006 10:28 AM |
| Delay routine not working | gregmcc | Micro Controllers | 6 | 18th September 2005 06:23 PM |
| An error in pic16f84a, why? | Zener_Diode | Micro Controllers | 6 | 11th April 2004 03:55 AM |
| Effects | stephenpic | Micro Controllers | 6 | 19th January 2004 12:57 PM |