SX User’s Manual Rev. 3.1 28 © 2000 Scenix Semiconductor, Inc. All rights reserved. www.scenix.com Chapter 2 Architecture 2.3.4                 Register Access Examples
Here is an example of an instruction that uses direct addressing:
inc $0F ;increment file register 0Fh This instruction increments the contents of file register 0Fh in the global register bank. It does not
matter what is contained in the FSR register.
To gain access to any register outside of the global register bank, it is necessary to use semi-direct or
indirect  addressing. In that case, you  need to make sure that the FSR register contains the correct
value for accessing the desired bank.
Here are 2 examples that use semi-direct addressing:
mov W,#$F0   ;load W with F0h
mov FSR,W
;load W into FSR (Bank F) inc $1F ;increment file register FFh Or, to access bank 0, mov W,#$00   ;load W with 00h
mov FSR,W
;load W into FSR (Bank 0) inc $1F ;increment file register 0Fh In these examples, “FSR” is a label that represents the value 04h, which is the address of the FSR reg-
ister in the global register bank. Note that the FSR register is itself a memory-mapped global register,
which is always accessible using direct addressing.
The “banked” data memory is divided into upper and lower blocks, each consisting of 8 banks of data
memory. The range for the lower block is from $00 to $7F, while the range for the upper block is
from $80 to $FF. Bit 7 of the FSR is used to select the upper or lower block. The BANK instruction is
used to select the bank within that block.
To use the “bank” instruction, in the syntax of the assembly language, you specify an 8-bit value that
corresponds to the desired bank number. The assembler encodes bits 4, 5, and 6 of the specified value
into the instruction opcode and ignores bit 7 and the low-order bits. For example, if another lower
bank was being used to increment file register 2Fh, you could use the following instructions:
bank $20 ;select Bank 2 in FSR inc $1F ;increment register 2F Note that the “bank” instruction only modifies bits 4, 5, and 6 the FSR register. Therefore, to change
from a lower block to an upper block bank, the “bank” instruction will not work. Instead, you need to
write the whole FSR register using code such as the following:
mov W,#$80   ;load W with 80h
mov FSR,W
;select Bank 8 in FSR Another approach is to set bit 7 of the FSR register individually after the “bank” instruction to address
an upper block bank.
bank $80 ;set bits in 4, 5, and 6 FSR setb FSR.7 ;select Bank 8 in FSR