Jonathan A Titus Microcomputer Pioneer
 
Mark-8 Design Microcomputer According to Titus Microcontroller Project Postscriptum Lessons Home



Lesson 7: Addressing Modes

For most casual programming on the SX-28, sidestepping addressing and using global registers will suffice. For programs with larger memory requirements, accessing additional registers across banks is necessary. This module discusses registers and instructions pertinent to addressing on the SX-28. First the registers used will be covered and then addressing will be covered.


Instruction Parameters Meaning
BANK dest Prepares for RAM access across a bank boundary.
PAGE addr11 Prepares for a jump or call across a page boundary.
dest = destination, addr11= 11-bit address
Figure 7-1: BANK and PAGE instructions

File Select Register (FSR, $04)
On the SX-28 chip, instructions that specify a register as an operand can only express 5 bits of the register address. This means that only registers from $00 to $1F can be expressed. The FSR along with the 5-bit register operand is used to provide the ability to access registers beyond $1F.

The FSR is modified by the BANK instruction, which prepares for RAM access across a bank boundary. Bit 7 of the FSR is used to select between upper and lower block of banks. This bit is not affected by the BANK instruction. It must be set or cleared by a separate SETB FSR.7 or CLRB FSR.7 following the BANK instruction.


Status Register ($03)
The status register is very important as it includes not only the bits modified by the PAGE instruction, but the Zero and Carry flags as well as a few other special flags. Addressing is focused upon in this module so the focus will be on bits 5-7 of the status register, the page select bits.

The PAGE instruction writes upper address bits into status register in preparation for a jump or call across a page boundary. Address bits 10 and 9 are written into status registers bits 6 and 5, also known as PA0 and PA1.


Indirect Register (IND, $00)
IND is the register which is used for indirect addressing. An instruction using IND as its operand actually performs the operation on the register pointed to by the contents of FSR.


Direct Addressing
Global registers can be directly accessed at any time but general purpose registers can only be accessed within the current bank. The global registers are numbered $01 through $0F. General purpose registers can only be accessed within one bank at a time. The general purpose registers are numbered $10 through $1F. To ensure that you are writing to the desired register, you must first write the correct value to the FSR to select the proper bank. The following code demonstrates how to clear some registers on some banks:

MOV	FSR, #$20	; Select Bank 1
CLR	$20	; Clear register $20 on Bank 1 
MOV	FSR, #$A0	; Select Bank 5
CLR	$30	; Clear register $30 on Bank 5
Figure 7-2: Direct Addressing Code Examples


Indirect Addressing
To access any register by using indirect addressing simply move the 8-bit address of the register you wish to access into the FSR and use IND ($00) as the operand. This example clears every general purpose ram register on every bank using indirect addressing.



Init	MOV	FSR, #$10		; FSR = addr of 1st RAM register
Loop	CLR	IND		; Clear register
	INC	FSR		; Point to next register
	SETB	FSR.4		; Stay within general purpose RAM
	CJNE	FSR, #$10, Loop	; Repeat until all register have been cleared
Figure 7-3: Indirect Addressing Code Examples


Copywrite Florida Gulf Coast University 2007
Validate CSS Validate XHTML