Hello,
I am writing assembly code for the PIC18F24K22 part under MPLAB / MPASM.
I have discovered that MPASM sets the 'a' bit in an instruction automatically in a complex and somewhat disturbing manner, consider the following list file snippet: (intended only to illustrate the assembler behavior- not real code)
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
000138 0101 00706 movlb 1 ;point to bank 1
00013A 0EEA 00707 movlw 0xEA ;load W with value
00013C 6E5F 00708 movwf 0x5F ;A bit =0, BSR ignored!
00013E 6F60 00709 movwf 0x60 ;A bit =1, BSR included!
000140 6F5F 00710 movwf CCPR3H ;A bit =1, BSR included!
000142 6E60 00711 movwf SLRCON ;A bit =0, BSR ignored!
Note how MPASM decides to set the 'a' bit in the instruction differently for
the SAME ADDRESS, depending on if it's specified by a mnemonic
or literal address! Passing the boundary 0x5F-0x60 reverses everything!
I understand that this boundary is where GPR and SFR meet in the access bank in this part, which is a big clue.
How are you supposed to write code that works with sneaky little things like this going on under your nose?
Is there some documentation that explains this?
I am writing assembly code for the PIC18F24K22 part under MPLAB / MPASM.
I have discovered that MPASM sets the 'a' bit in an instruction automatically in a complex and somewhat disturbing manner, consider the following list file snippet: (intended only to illustrate the assembler behavior- not real code)
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
000138 0101 00706 movlb 1 ;point to bank 1
00013A 0EEA 00707 movlw 0xEA ;load W with value
00013C 6E5F 00708 movwf 0x5F ;A bit =0, BSR ignored!
00013E 6F60 00709 movwf 0x60 ;A bit =1, BSR included!
000140 6F5F 00710 movwf CCPR3H ;A bit =1, BSR included!
000142 6E60 00711 movwf SLRCON ;A bit =0, BSR ignored!
Note how MPASM decides to set the 'a' bit in the instruction differently for
the SAME ADDRESS, depending on if it's specified by a mnemonic
or literal address! Passing the boundary 0x5F-0x60 reverses everything!
I understand that this boundary is where GPR and SFR meet in the access bank in this part, which is a big clue.
How are you supposed to write code that works with sneaky little things like this going on under your nose?
Is there some documentation that explains this?