View previous topic :: View next topic |
Author |
Message |
embedded_tom
Joined: 09 Oct 2008 Posts: 4 Location: Long Island, NY
|
Accessing hi byte of int16 in assembly |
Posted: Mon Oct 20, 2008 8:36 am |
|
|
I read through the forum and found a way to do this by using the '&' prefix: http://www.ccsinfo.com/forum/viewtopic.php?t=7220
Code: | bcf TMR1ON
movf Next_Time, W
addwf TMR1, F
btfsc C
incf TMR1H, F
movf &Next_Time+1, W
|
Next_Time is located at 0x28 according to the .lst file:
But it doesn't access 0x29 in the second movf!?!
Code: | 00484 .................... bcf TMR1ON
0015 1010 00485 BCF 10.0
00486 .................... movf Next_Time, W
0016 0828 00487 MOVF 28,W
00488 .................... addwf TMR1, F
0017 078E 00489 ADDWF 0E,F
00490 .................... btfsc C
0018 1803 00491 BTFSC 03.0
00492 .................... incf TMR1H, F
0019 0A8F 00493 INCF 0F,F
00494 .................... movf &Next_Time+1, W
001A 082A 00495 MOVF 2A,W
|
Adding parenthesis or dropping the "+1" doesn't work. Next_Time is declared as an int16.
My compiler is Ver 4.080. uP is rfPIC12F675 (12F675 w/RF transmitter).
Ideas?
Thanks.
Tom |
|
|
RLScott
Joined: 10 Jul 2007 Posts: 465
|
Re: Accessing hi byte of int16 in assembly |
Posted: Mon Oct 20, 2008 8:59 am |
|
|
Try this:
Code: |
#byte Next_Time_H=Next_Time+1
. . .
movf Next_Time_H,W
|
This has the advantage of also working outside of the assembly language block as in:
Code: |
int k;
k = Next_Time_H;
|
_________________ Robert Scott
Real-Time Specialties
Embedded Systems Consulting |
|
|
embedded_tom
Joined: 09 Oct 2008 Posts: 4 Location: Long Island, NY
|
Re: Accessing hi byte of int16 in assembly |
Posted: Tue Oct 21, 2008 7:26 am |
|
|
Thanks, but got this error for the #byte statement: Error 43 Expecting a declaration.
tom |
|
|
RLScott
Joined: 10 Jul 2007 Posts: 465
|
Re: Accessing hi byte of int16 in assembly |
Posted: Tue Oct 21, 2008 7:30 am |
|
|
embedded_tom wrote: | Thanks, but got this error for the #byte statement: Error 43 Expecting a declaration.
tom |
Please post the code showing how you used the #byte directive. It is a valid CCS directive. Look it up in the CCS help file. _________________ Robert Scott
Real-Time Specialties
Embedded Systems Consulting |
|
|
embedded_tom
Joined: 09 Oct 2008 Posts: 4 Location: Long Island, NY
|
|
Posted: Tue Oct 21, 2008 7:34 am |
|
|
I did review #byte in the CCS manual. Here's what I used:
Code: | #byte Next_TimeH = Next_Time + 1; |
Is #byte similar to "assign" in other compilers?
I just tried this & it worked:
Code: | movf make8(Next_Time,1), W |
Thanks for the push in the right direction!
tom |
|
|
RLScott
Joined: 10 Jul 2007 Posts: 465
|
|
Posted: Tue Oct 21, 2008 9:20 am |
|
|
embedded_tom wrote: | I did review #byte in the CCS manual. Here's what I used:
Code: | #byte Next_TimeH = Next_Time + 1; |
|
The problem is the ';' at the end. Take it off and it should work. _________________ Robert Scott
Real-Time Specialties
Embedded Systems Consulting |
|
|
embedded_tom
Joined: 09 Oct 2008 Posts: 4 Location: Long Island, NY
|
|
Posted: Tue Oct 21, 2008 2:30 pm |
|
|
Yep, that did it.
Thanks.
tom |
|
|
|