# PIC (18 series) 12-bit Instruction Addressing?

I'm trying to find the 12-bit address in hex -- as well as the memory bank being used -- by the last instruction in the sequences listed below.

Before I list the sequences, it is my understanding that the 12-bit address used should be 00da ffff ffff, where d is either 1 (result stored back in register), or 0 (result stored in WREG), and a is either 1 (uses BSR), or 0 (ignores BSR). However, I've also read that the 12-bit address is comprised of the 4 BSR bits and 8 bits from the instruction..so which is it? Is the address being used 00da ffff ffff, or bbbb ffff ffff (where the b's indicate the bank)?

The first sequence is:

MOVLW  H'08'
MOVWF BSR
MOVF  H'10',W


Because I didn't include A (MOVF f,d,a), I believe this ignores the BSR, so I would say the address is 0000 0001 0000, or 0x010. This would be stored in Bank 0.

The next sequence is

MOVLW H'08'
MOVWF BSR
MOVF  H'10',W,A


Since I included A here, this should use the BSR bits to determine the bank, meaning the instruction should use Bank 8. That being said, does this mean the address is 00da ffff ffff = 0001 0001 0000 = 0x110, or that the address is 1000 0001 0000 = 0x810?

The d and a bits are fields in the instruction encoding, but not part of the 8­-bit address field in the instruction. If we want to be academic about it, we could say that the a bit is an addressing mode field in the instruction. The d bit can be analyzed as a destination addressing mode or as part of the opcode, but the 00 you start by quoting are not part of addressing at all; they are simply the last two bits of the MOVF opcode.
The 12-bit effective address used is constructed as the 8 address bits from the instruction, prepended by 4 bits that either come from the BSR or are derived from the first few of the explicit address bits, as selected by the a field. But the value of the a bit itself doesn't become part of the address.
Finally (but I may be misreading the documentation I could find here), the ,A in the assembler syntax seems to stand for "use the Access bank", so when (upper-case) A is present in the assembler instruction, it means that (lower-case) a in the binary instruction encoding is zero and the BSR is not used.