![]() | ![]() | ![]() |
| |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
![]() |
| | Tools |
| | #1 |
|
Hi, I'm wrote a small 18F in-line assembly snippet in MPLAB referencing a local C variable. From the results I'm not referencing the C variable correctly. Any ideas? unsigned char count = 0; unsigned char current_count = 10; count = current_count; _asm // Loop until count is 0 start: DECFSZ count, 1, 0 BRA start GOTO done done: _endasm | |
| |
| | #2 |
|
To use a variable without managing the banking you need to have it in access ram. Try moving your variable so it is global and put it in the access area by doing, Code: #pragma udata access somename near unsigned char count; #pragma udata | |
| |
| | #3 |
|
Thanks Mike, How would I manage the banking to avoid allocating it in access ram? | |
| |
| | #4 |
|
Well, if you run out of access ram you need to load the bsr with the bank number of your variable. What is wrong with using the access ram, the compiler doesn't seem to!! Mike. | |
| |
| | #5 |
|
Thanks again Mike, I believe I can use access RAM (near), and it do sound like it would end up being faster and require less cycles. But lets say I wanted to set the BSR with bank information to access the count variable in my simple loop example above. How would I accomplish that? I am sorry for these newbie questions but I'm just starting up with MPASM syntax (as you can tell) | |
| |
| | #6 |
|
You would simply do movlb count. Mike. | |
| |
|
| Tags |
| 18f, assembly, in-line, mplab, pic |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| Assembly Variables for PICs! | Peter_wadley | Micro Controllers | 9 | 22nd June 2007 06:05 AM |
| How reliable is cross referencing parts? | Canti | General Electronics Chat | 23 | 3rd May 2007 10:30 PM |
| in-line assembly for PicBasic Compiler | Erwin_Macaraig | Micro Controllers | 0 | 3rd November 2004 08:02 AM |
| ground referencing a differential input signal | giaracam | Electronic Projects Design/Ideas/Reviews | 2 | 22nd September 2004 01:41 PM |
| Where is variables located in a PIC? | egh01 | Micro Controllers | 0 | 22nd November 2003 01:08 PM |