beautypg.com

4 – reading and writing register bits, Reading and writing register bits, Ds4830 user’s guide – Maxim Integrated DS4830 Optical Microcontroller User Manual

Page 181

background image

DS4830 User’s Guide

181

16-bit destination concatenation(8-bit source, 8-bit source)

Two 8-bit source registers can be concatenated and stored into a 16-bit destination by using the prefix register to hold the
high order byte for the concatenated transfer. An additional cycle may be required if either source byte register index is
greater than 0Fh.


move PFX[0], IC

; load high order source byte IC into PFX

move @++SP, AP

; store @DP[0] the concatenation of IC:AP


; 16-bit destination sub-index: dst=08h

; 8-bit source sub-indexes:

; high=10h, low=11h

move PFX[1], #00h

;

move PFX[3], high

; PFX=00:high

move dst, low

; dst=high:low

low(16-bit destination) 8-bit source
To modify only the low byte of a given 16-bit destination, the 16-bit register should be moved into the GR register such
that the high byte can be singulated and the low byte written exclusively. An additional cycle is required if the destination
index is greater than 0Fh.

move GR, DP[0]

; move DP[0] to the GR register

move PFX[0], GRH

; get the high byte of DP[0] via GRH

move DP[0], #20h

; store the new DP[0] value


; 16-bit destination sub-index: dst=10h

; 8-bit source sub-index: src=11h

move PFX[1], #00h

;

move GR, dst

; read dst word to the GR register

move PFX[5], GRH

; get the high byte of dst via GRH

move dst, src

; store the new dst value


high(16-bit destination)
8-bit source
To modify only the high byte of a given 16-bit destination, the 16-bit register should be moved into the GR register such
that the low byte can be singulated and the high byte can be written exclusively. Additional cycles are required if the
destination index is greater than 0Fh or if the source index is greater than 0Fh.

move GR, DP[0]

; move DP[0] to the GR register

move PFX[0], #20h

; get the high byte of DP[0] via GRH

move DP[0], GRL

; store the new DP[0] value


; 16-bit destination sub-index: dst=10h

; 8-bit source sub-index: src=11h

move PFX[1], #00h

;

move GR, dst

; read dst word to the GR register

move PFX[1], #00h
move PFX[4], src

; get the new src byte

move dst, GRL

; store the new dst value

If the high byte needs to be cleared to 00h, the operation can be shortened by transferring only the GRL byte to the 16-bit
destination (example follows):

move GR, DP[0]

; move DP[0] to the GR register

move DP[0], GRL

; store the new DP[0] value, 00h used for high byte


23.4

– Reading and Writing Register Bits

The MOVE instruction can also be used to directly set or clear any one of the lowest 8 bits of a peripheral register in
module 0h-5h or a system register in module 8h. The set or clear operation will not affect the upper byte of a 16-bit
register that is the target of the set or clear operation. If a set or clear instruction is used on a destination register that
does not support this type of operation, the register high byte will be written with the prefix data and the low byte will be
written with the bit mask (i.e. all 0’s with a single 1 for the set bit operation or all ones with a single 0 for the clear bit
operation).

Register bits may be set or cleared individually using the MOVE instruction as follows.


move IGE, #1

; set IGE (Interrupt Global Enable) bit

move APC.6, #0

; clear IDS bit (APC.6)