Hi, Roy J. Gromlich wrote: >Now obviously the 256 bytes of Bank 0 can't handle any >variables beyond 0x0FF (in Microchip's format). So what >happens to a variable which is addressed as (say) 0x130 >or 0x430 with the BSR=0? Which GPRs are accessed? >Likewise if the change the BSR=1 and access a GPR at >0x130, which GPR is actually being accessed? > >I have been unable to find any information in the PIC docs >which would clarify this. Well, again I can only point you to the datasheet, maybe it's not written out in bold with 72p font size but it's there :). If you look at the instructions and how they are coded you will see that, any instruction taking 1 instruction cycle, is decoded as 16 bits or 1 word. Now this limits the amount of information you can decode and it turns out that for memory access they can only store 8 adress bits *within* the actual instruction. The reason that Microchip tells you to always use the 12 bit adress in your program is that it also has the access ram feature, when provided with an full 12 bit adress, the assembler/linker knows if it needs to use the BSR or not (one bit in the instruction). For example an ram adress of 0x0020 will *not* use the BSR as it is within the access ram, however using the adress 0x0120 will use it (or be decoded to use it). So to summarize, the 4 top bits of the 12 bit adresses for ram is used to include BSR =YES/NO information in the coded instruction. The low 8 bits is encoded into the instruction. Hence that leaves us with 4 bits that are missing (*which* bank), these bits comes from the BSR during execution, and the programmer (he/she/compiler) is required to handle them. There are a few instructions that takes 2 instruction cycles to execute and are 2 words in size, these are an special case as they will include the full 12 bit adress/es, for example MOVFF, these instructions ignore the BSR all togehter. >The reason this is significant to me is that I am trying to set up >a program with multiple serial I/O buffers. These buffers don't >need to be gigantic, but there are 4 of them -- 2 send and >2 receive buffers. Now an obvious way to do this is to assign Well normally an buffer requires an 'in' pointer, 'out' pointer and number of bytes in buffer. I like to place all my buffers in the same bank (if possible), then the pointers and counter can be in any bank then I normally use the FSR's to access the buffer. Remember I said: >An thoughtful placing of your variables and using the FSR's >as much as possible will make this essentially an non-issue. The key point here is the FSR's as they can access all ram banks and have alot of neat features such as postincrement etc. very usefull for moving data or buffers. /Tony ########################################### This message has been scanned by F-Secure Anti-Virus for Microsoft Exchange. For more information, connect to http://www.F-Secure.com/ -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body