beautypg.com

4 immediate addressing, 5 register indirect with displacement, 6 relative addressing – Maxim Integrated High-Speed Microcontroller User Manual

Page 61: Direct addressing, Register indirect addressing, 7 page addressing

background image

High-Speed Microcontroller User’s Guide

Rev: 062210

61 of 176


The 16-bit Data pointers (DPTRs) can be used as an absolute off-chip reference. This gives access to the
entire 64kB data memory map. An example is as follows.

M

OVX @DPTR, A

;Write the value in the accumulator

;to the address referenced by the
;selected data pointer.

4.4.4 Immediate Addressing

Immediate Addressing is used when one of the operands is predetermined and coded into the software.
This mode is commonly used to initialize SFRs and to mask particular bits without affecting others. An
example is as follows.

ORL

A, #40h

;Logical OR the Accumulator with 40h.

4.4.5 Register Indirect with Displacement

Register Indirect Addressing with Displacement is used to access data in lookup tables in program
memory space. The location is created using a base address with an index. The base address can be either
the PC or the DPTR. The index is the accumulator. The result is stored in the accumulator. An example is
as follows.

M

OVC

A, @A +DPTR

;Load the accumulator with the contents

of program memory
;pointed to by the contents of the DPTR
plus the value in
;the accumulator.

4.4.6 Relative Addressing

Relative Addressing is used to determine a destination address for Conditional branch. Each of these
instructions includes an 8-bit value that contains a two’s complement address offset (–127 to +128) which
is added to the PC to determine the destination address. This destination is branched to when the tested
condition is true. The PC points to the program memory location immediately following the branch
instruction when the offset is added. If the tested condition is not true, the next instruction is performed.
An example is as follows.

JZ

$–20

;Branch to the location (PC+2)–20
;if the contents of the accumulator = 0.

4.4.7 Page Addressing

Page Addressing is used by the Branching instructions to specify a destination address within the same
2kB block as the next contiguous instruction. The full 16-bit address is calculated by taking the five
highest order bits for the next instruction (PC+2) and concatenating them with the lowest order 11-bit
field contained in the current instruction. An example is as follows.

0870h

ACALL100h

;Call to the subroutine at address 100h
plus the
;current page address.

In this example, the current page address is 800h, so the destination address is 900h.