BS2824 Holtek Semiconductor Inc., BS2824 Datasheet - Page 21

no-image

BS2824

Manufacturer Part Number
BS2824
Description
Touch Key Mcu
Manufacturer
Holtek Semiconductor Inc.
Datasheet
Rev. 1.00
Memory Pointers - MP0, MP1
Accumulator - ACC
Program Counter Low Register - PCL
Indirect Addressing Program Example
Two Memory Pointers, known as MP0 and MP1 are provided. These Memory Pointers are
physically implemented in the Data Memory and can be manipulated in the same way as normal
registers providing a convenient way with which to indirectly address and track data. MP0 can only
be used to indirectly address data in Bank 0 while MP1 can be used to address data in Bank 0 and
Bank1. When any operation to the relevant Indirect Addressing Registers is carried out, the actual
address that the microcontroller is directed to, is the address specified by the related Memory
Pointer. The following example shows how to clear a section of four Data Memory locations already
defined as locations adres1 to adres4.
The important point to note here is that in the example shown above, no reference is made to specific
Data Memory addresses.
The Accumulator is central to the operation of any microcontroller and is closely related with
operations carried out by the ALU. The Accumulator is the place where all intermediate results from
the ALU are stored. Without the Accumulator it would be necessary to write the result of each
calculation or logical operation such as addition, subtraction, shift, etc., to the Data Memory
resulting in higher programming and timing overheads. Data transfer operations usually involve the
temporary storage function of the Accumulator; for example, when transferring data between one
user defined register and another, it is necessary to do this by passing the data through the
Accumulator as no direct transfer between two registers is permitted.
To provide additional program control functions, the low byte of the Program Counter is made
accessible to programmers by locating it within the Special Purpose area of the Data Memory. By
manipulating this register, direct jumps to other program locations are easily implemented. Loading
a value directly into this PCL register will cause a jump to the specified Program Memory location,
however, as the register is only 8-bit wide, only jumps within the current Program Memory page are
permitted. When such operations are used, note that a dummy cycle will be inserted.
data .section
adres1 db ?
adres2 db ?
adres3 db ?
adres4 db ?
block db ?
code .section at 0 code
org
start:
mov a,04h
mov block,a
mov a,offset adres1
mov mp0,a
loop:
clr IAR0
inc mp0
sdz block
jmp loop
continue:
00h
data
; setup size of block
; Accumulator loaded with first RAM address
; setup memory pointer with first RAM address
; clear the data at address defined by MP0
; increment memory pointer
; check if last memory location has been cleared
21
BS2824/BS2854/BS2868
Touch Key MCU
January 27, 2010

Related parts for BS2824