I am writing some routines in assembly for an 18F458 that I want to operate correctly regardless of what bank they were called from. I'm trying to save as many instructions as possible, so this is preferred over context saving for these particular routines. To accomplish this goal, I am attempting to use the access bank. My plan is to place all variables that these routines use in the access bank and then specify the access bank on all relevant instructions in these routines. The problem I am experiencing is that my code works fine when I DON'T specify the access bank, and doesn't work when I DO specify the access bank. It is okay to specify the access bank even if the BSR is 0, correct? Because that is the situation that my code is failing under. I haven't tried calling the routine with the BSR set to anything other than 0 yet. Has anybody experienced this problem before?? The offending code is at the bottom of this email. As shown, the code works great. The routine is called MAX3110_WRITEHEX and simply writes an 8-bit number out over serial in ASCII format (i.e. sends the characters 'a' and '1' instead of the binary value 0xa1). If I add ", A" to the end of the instructions that access HEX_NUM and HEX_HIGH, the MAX3110_WRITEHEX routine does not work. Thanks, Eric Christensen #define HEX_NUM 0x014 #define HEX_HIGH 0x015 MAX3110_WRITEHEX dw 0xffff ; work-around for silicon rev B4 errata #5 movff HEX_NUM, HEX_HIGH ; use swap & and to save two instr maybe rrncf HEX_HIGH ; shift upper nibble of HEX_NUM to rrncf HEX_HIGH ; the lower nibble of HEX_HIGH rrncf HEX_HIGH rrncf HEX_HIGH movlw 0x0f ; clear the upper nibble of HEX_NUM andwf HEX_NUM movlw 0x0f ; clear the upper nibble of HEX_NUM andwf HEX_HIGH ; (shound't need this, but... just in case for now) movlw 0x09 ; if the upper nibble is greater than 9, output a-f (for hex) cpfsgt HEX_HIGH goto byte_one_low ; else we can just output the number movlw asc_0 + 0x07 addwf HEX_HIGH MAX3110_PUTCHARf HEX_HIGH goto byte_two byte_one_low dw 0xffff ; work-around for silicon rev B4 errata #5 movlw asc_0 addwf HEX_HIGH MAX3110_PUTCHARf HEX_HIGH byte_two dw 0xffff ; work-around for silicon rev B4 errata #5 movlw 0x09 ; if the upper nibble is greater than 9, output a-f cpfsgt HEX_NUM goto byte_two_low ; else we can just output the number movlw asc_0 + 0x07 addwf HEX_NUM MAX3110_PUTCHARf HEX_NUM goto byte_two_done byte_two_low dw 0xffff ; work-around for silicon rev B4 errata #5 movlw asc_0 addwf HEX_NUM MAX3110_PUTCHARf HEX_NUM byte_two_done dw 0xffff ; work-around for silicon rev B4 errata #5 return dw 0xffff ; work-around for silicon rev B4 errata #5 MAX3110_PUTCHARf macro fADDRESS SPI_CONFIG 0x40, 0x00 ; configure the spi module for the MAX3110 bcf MAX3110_CS, A ; select the MAX3110 SPI_SEND_16 0x00, 0x00 ; get the MAX3110 status register bsf MAX3110_CS, A ; de-select the MAX3110 btfss SPI_RXDATA1, 6, A ; see if the transfit buffer is full goto $-30 ; jump back 15 instructions if it is bcf MAX3110_CS, A ; select the MAX3110 SPI_SEND_16if 0x80, fADDRESS ; send out BYTE bsf MAX3110_CS, A ; de-select the MAX3110 endm -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu