----- Original Message ----- From: Jess Hancock To: Sent: Sunday, March 04, 2001 10:08 PM Subject: Re: [PIC]: 12c671 - GPIO vs TRIS Reg > Thanks Bob and Drew for your responses. > > Bob, the documentation indicates the GPIO/TRIS registers are at register > memory locations 0x05/0x85 and therefore it seems the disassembler should > know which register is being addressed. Yes, these registers have the specified addresses. But, where are those addresses stored when the program is running. Well, the low order 7 bits of the address are stored in the instruction itself. But the high order bit is stored in the RP0 bit of the status register. Thus, the disassembler, which only looks at one instruction at a time, can only see the low 7 bits of the address. The designer of the disassembler decided to just use the register that would be referenced if RP0 was zero. In other words, the very same instruction bit pattern can refer to either the GPIO register or the TRISIO register, depending on the value of RP0 (which is not determined by the particular instruction being disassembled. More sophisticated disassemblers do _try_ to keep track of the value of RP0, but in general that cannot be done perfectly. >To test, I modified the source code > below by substituting TRISIO for the first GPIO and then assembled it and > got the following hex code and Message[302]. Excerpts from POLARMD2.LST: > > 0019 3008 00135 ad0019 MOVLW 0x08 > 001A 00A1 00136 MOVWF 0x21 > 001B 1683 00137 BSF STATUS,RP0 > Message[302]: Register in operand not in bank 0. Ensure that bank bits are > correct. > 001C 1205 00138 BCF TRISIO,4 ; ??? RAM > Page TRISIO,4 > 001D 1283 00139 BCF STATUS,RP0 > 001E 1605 00140 BSF GPIO,4 ; ??? RAM > Page TRISIO,4 > 001F 17A1 00141 BSF 0x21,7 > 0020 282E 00142 GOTO ad002E > 00143 ; > 0021 13A1 00144 ad0021 BCF 0x21,7 > 0022 0CA7 00145 ad0022 RRF 0x27,f > 0023 1803 00146 BTFSC STATUS,C > 0024 1205 00147 BCF GPIO,4 ; ??? RAM > Page TRISIO,4 > 0025 1C03 00148 BTFSS STATUS,C > 0026 1605 00149 BSF GPIO,4 ; ??? RAM > Page TRISIO,4 > 0027 1721 00150 BSF 0x21,6 > 0028 282E 00151 GOTO ad002E > > Note: the comments "???RAM Page TRISIO,4" were produced when disassembling > the source HEX code. > > Line 0x001C contains the TRISIO register and line 0x0024 contains the GPIO > register. They both produce a hex code of 1205h. I think I remember that > Msg [302] is not an error but a WARNING ? or at least a caution. It is a warning. Basically the assembler is telling you: "I can't fit the address of this register into the 7 bits I have for a register address in the instruction. You better make sure that RP0 is right for this reference!". > So, when coding in assembly, which register name should one use - the > register name matching the Bank or is it sufficient to use either name and > preselect the correct Bank? Is TRISIO the appropriate name to use for Bank > 1? Logic would say use the matching register name, but either seems to give > the same result here. Is this consistent in other registers? Or am I > missing something obvious? You should use the register name that you are actually trying to access, and you should be very careful to ensure that you have RP0 set appropriately. This happens with all registers that are 'shadows' of each other in the two banks. > > Would you elaborate? > > Thanks, Jess > I hope that makes some sense. Bob Ammerman RAm Systems (contract development of high performance, high function, low-level software) -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics