|
|
View previous topic :: View next topic |
Author |
Message |
henry007a
Joined: 07 Aug 2006 Posts: 1
|
MOVWF instruction |
Posted: Mon Aug 07, 2006 9:37 am |
|
|
Hi,
I am using PCH C Compiler, Version 3.249, and processor is 18F65J10.
I am writing some inline assembly, the code is as follows:
#asm
MOVLW 01 ; load 1 into W
MOVLB 1 ; load 1 to low nibble in BSR
MOVWF 0x17 ; move W into location 0x17
#endasm
For the “MOVWF 0x17” instruction, the compiler generates 17 6E in the resulting image ie. using the Access Bank. What I really want is for the compiler to generate code that uses BSR to select the GPR bank ie. 17 6F. How do I get the compiler to do that?
In the PIC data sheet, the format for MOVWF is MOVWF f {,a}
where a = 0, the Access Bank is selected,
a = 1, the BSR is used to select the GPR bank.
But the PCH compiler doesn’t seem to accept MOVWF 0x17,1. The error message is: “Expecting an opcode mnemonic”.
Is there a document that describes the assembly syntax that PCH uses?
Thanks. |
|
|
Ttelmah Guest
|
|
Posted: Mon Aug 07, 2006 10:04 am |
|
|
Multiple possibilities.
First do it without assembler at all:
#byte LOC117=0x117
LOC117=1;
Or just use:
#asm
MOVLW 01 ; load 1 into W
MOVWF 0x117 ; move W into location 0x117
#endasm
Or do what you were trying:
#asm asis
MOVLW 1
MOVLB 1
MOVWF 0x17
#endasm
The keys to understand, is that the internal assembler 'knows' about banks for itself, and you can just tell it to put a byte into location 117, and it'll handle the bank switching for you. Doing it this way, or just in C, the optimiser will still 'know' what bank is selected, and will avoid switching backwards and forwards if other code wants to use the same bank.
You can turn this behaviour off with the 'asis' command.
However really the easiest way, is not to use assembler at all, and just define the location, as shown in the first version.
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|