MOVLW 0x40 // portb = 0b01000000; MOVWF _portb
Now when I compile/assemble the program, I find that the compiler insists on setting the register bank to zero. Doing this adds two extra instructions! And the wasted lines are added again and again, just in case I sneaked a bank change in when the compiler wasn't looking. Like this, in the "View Disassembly Listing":
117: MOVLW 0x40 // portb = 0b01000000; 054 3040 MOVLW 0x40 118: MOVWF _portb 055 1283 BCF 0x3, 0x5 056 1303 BCF 0x3, 0x6 057 0086 MOVWF 0x6
I'd have thought that if I'm willing to use assembly, it's my responsibility to set the bank. Or at least, there should be a command to lock out helpful behavior by the compiler. But I'm not encouraged by the manual, where it says "Bank switching and code page switching code should NOT be added to inline assembly code. The linker will add the appropriate Bank switching and code page switching code." If there were a way to stop it happening, wouldn't this be the place to tell the user?
This isn't a positive feature, in my humble opinion.