I'm having some proplems with MPLAB which i hope someone has run into and solved. I have this code here
LIST R=DEC
INCLUDE "p16f886.inc"
PAGE
org 0
nop ; Required for MPLAB ICD2
bsf STATUS, RP0 ;Let's select bank 1
bcf STATUS, RP1
movlw 0x00 ;Set all ports as output
movwf TRISA
bcf STATUS, RP0 ;Switch back to bank 0
movlw 0xFF ;Put logic high on all A ports
movwf PORTA ; ------
Start ;Loop
goto Start
end
It's quite simple as you see. Simply puts all A ports on logic high and loops forever afterwards.
If i look at the machine code MPLAB generates it seems it replaces TRISA with PORTB everywhere. So between the bank changes during the beginning of code execution it actually performs movlw, mowlwf on PORTA (which isnt even in bank1) instead of using the correct address of 85h for TRISA it uses 05h (PORTA) even though the asm explicitly states that i want to use TRISA register.
This is extremely wierd and quite annoying. Why would it replace all references to TRISA (at address 85h) with reference to 05h (address of PORTA). The toolsuite i'm using is the MPASM assembler which comes with MPLAB.
Any help or advice greatly appreciated
LIST R=DEC
INCLUDE "p16f886.inc"
PAGE
org 0
nop ; Required for MPLAB ICD2
bsf STATUS, RP0 ;Let's select bank 1
bcf STATUS, RP1
movlw 0x00 ;Set all ports as output
movwf TRISA
bcf STATUS, RP0 ;Switch back to bank 0
movlw 0xFF ;Put logic high on all A ports
movwf PORTA ; ------
Start ;Loop
goto Start
end
It's quite simple as you see. Simply puts all A ports on logic high and loops forever afterwards.
If i look at the machine code MPLAB generates it seems it replaces TRISA with PORTB everywhere. So between the bank changes during the beginning of code execution it actually performs movlw, mowlwf on PORTA (which isnt even in bank1) instead of using the correct address of 85h for TRISA it uses 05h (PORTA) even though the asm explicitly states that i want to use TRISA register.
This is extremely wierd and quite annoying. Why would it replace all references to TRISA (at address 85h) with reference to 05h (address of PORTA). The toolsuite i'm using is the MPASM assembler which comes with MPLAB.
Any help or advice greatly appreciated