At 03:54 PM 2/12/2012, John Gardner wrote: >If I select "Errorrs, Warnings, & Messages" in >I often get messages like this one after changing the Bank Select >bits - In this case changed from Bank0 to Bank1 the previous >instruction... > >Message[302] C:\ASM\BOO.ASM 89 : Register in operand not in bank 0. >Ensure that bank bits are correct. > >Messages, not warnings or errors. And the bank settings are in fact correc= t, >according to the disassembly listing. > >Anyone know why this happens? Yep. And its easy to fix. The problem is that you have manually changed the bank bits yourself=20 but MPLAB doesn't know that. So: it sees that you are addressing a=20 RAM location that is not in bank 0. Andrew Warren came up with some simple macros many, many years ago=20 that I still use. I'll post them below. You could also use Olin Lathrop's build environment with does=20 something similar to Andy's macros. Olin's environment, though, is=20 sort of a 'All or nothing' solution - it looks to be somewhat painful=20 to use only portions of his environment. That said: lots of people=20 DO use Olin's environment and like it a lot. My version of Andrew Warren's bank macros. These are known to work=20 with 12-bit and 14-bit PICs (10f, 12f, 16f). YMMV Notice that I preface all bits with a leading underscore (_T0IF). I=20 have also created custom versions of Microchip's include files that=20 combine the register name and bit names into single entities: ; INTCON Register Bits page 0 #define _RBIF INTCON,0 ; RB port changed interrupt flag rst in= sw #define _INTF INTCON,1 ; RB0 INT interrupt flag rst in= sw #define _T0IF INTCON,2 ; TMR0 overflow int flag rst in= sw #define _RBIE INTCON,3 ; RBIF interrupt enable active= hi #define _INTE INTCON,4 ; INTF interrupt enable active= hi #define _T0IE INTCON,5 ; TMR0 interrupt enable active= hi #define _PEIE INTCON,6 ; Peripheral Interrupt Enable active= hi #define _GIE INTCON,7 ; global interrupt enable active= hi These allow me to reference any bit by its bit name rather than=20 having to remember which register any particular bit belongs to. The macros themselves: #define BB1(reg,bit) (reg^0x80),(bit) ;bit in bank 1 #define RB1(reg) (reg^0x80) ;reg in bank 1 #define BB2(reg,bit) (reg),(bit) ;bit in bank 2 #define RB2(reg) (reg) ;reg in bank 2 #define BB3(reg,bit) (reg^0x80),(bit) ;bit in bank 3 #define RB3(reg) (reg^0x80) ;reg in bank 3 ;usage is: bcf BB1(_SOMEBIT) ;usage is: movwf RB1(SOMEREG) #define BNUM(reg,bit) (bit) ;bit number within reg #define BIT(reg,bit) 1<<(bit) ;bit within reg #define MASK(reg,bit) ~(1<<(bit)) ;bit mask within reg #define REG(reg,bit) (reg) ;reg ;usage is: movlw BIT(_SOMEBIT) ; do something ; movwf REG(_SOMEBIT) What the BB1, RB1 macros do is 'flip' the MSB of the address. This=20 has 2 possible outcomes: 1) the RAM register really is in bank 1. The macro inverts the MSB,=20 which makes the assembler think that its in bank 0. The assembler is=20 happy, the program is happy (provided that you actually DID set the=20 bank bits properly), you are happy. 2) the RAM register is in bank 0 or 2 and you mistakenly used the=20 macro with it. The assembler complains and you go look to see what=20 the problem is. The other macros (BNUM, BIT, MASK, REG) allow easy manipulation of=20 individual bits or registers. I personally leave all warnings turned ON except for number 224 (and=20 I don't even remember what that one is for). I get clean compiles on=20 all of my programs - if any message shows up in the error log, I go=20 find and fix it before I looking for any other problems. These error messages have been a huge time saver for me - they help=20 stop simple errors for taking a long time to find and fix. Andy's=20 macros help make that fast and easy. dwayne --=20 Dwayne Reid Trinity Electronics Systems Ltd Edmonton, AB, CANADA (780) 489-3199 voice (780) 487-6397 fax www.trinity-electronics.com Custom Electronics Design and Manufacturing --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .