Loading an 8-bit register with an immediate value, Moving values between registers of the same size, Moving values between registers of different sizes – Maxim Integrated DS4830 Optical Microcontroller User Manual

Page 180: Ds4830 user’s guide

Advertising
background image

DS4830 User’s Guide

180


23.3.1

– Loading an 8-bit register with an immediate value

Any writeable 8-bit register with a sub-index from 0h to 7h within its module can be loaded with an immediate value in a
single cycle using the MOVE instruction.


move AP, #05h

; load accumulator pointer register with 5 hex

Writeable 8-bit registers with sub-indexes 8h and higher can be loaded with an immediate value using MOVE as well, but
an additional cycle is required to set the prefix value for the destination.

move WDCN, #33h

; assembles to: move PFX[2], #00h

; move (WDCN-80h), #33h

23.3.2

– Loading a 16-bit register with a 16-bit immediate value

Any writeable 16-bit register with a sub-index from 0h to 07h can be loaded with an immediate value in a single cycle if the
high byte of that immediate value is zero.


move LC[0], #0010h

; prefix defaults to zero for high byte

If the high byte of that immediate value is not zero or if the 16-bit destination sub-index is greater than 7h, an extra cycle is
required to load the prefix value for the high byte and/or the high order register index bits.


; high byte <> #00h

move LC[0], #0110h

; assembles to: move PFX[0], #01h

; move LC[0], #10h


; destination sub-index > 7h

move A[8], #0034h

; assembles to: move PFX[2], #00h

; move (A[8]-80h), #34h

23.3.3

– Moving values between registers of the same size

Moving data between same-size registers can be done in a single-

cycle MOVE if the destination register’s index is from

0h to 7h and the source register index is between 0h and Fh.


move A[0], A[8]

; copy accumulator 8 to accumulator 0

move LC[0], LC[1]

; copy loop counter 1 to loop counter 0

If the destination register’s index is greater than 7h or if the source register index is greater than Fh, prefixing is required.


move A[15], A[0]

; assembles to: move PFX[2], #00h

; move (A[15]-80h), A[0]

23.3.4

– Moving values between registers of different sizes

Before covering some transfer scenarios that might arise, a special register must be introduced that will be utilized in
many of these cases. The 16-bit General Register (GR) is expressly provided for performing byte singulation of 16-bit
words. The high and low bytes of GR are individually accessible in the GRH and GRL registers respectively. A read-only
GRS register makes a byte-swapped version of GR accessible and the GRXL register provides a sign-extended version of
GRL.

8-bit destination
low byte(16-bit source)
The simplest transfer possibility would be loading an 8-bit register with the low byte of a 16-bit register. This transfer does
not require use of GR and requires a prefix only if the destination or source register are outside of the single cycle write or
read regions, 0-7h and 0-Fh, respectively.


move OFFS, LC[0]

; copy the low byte of LC[0] to the OFFS register

move IMR, @DP[1]

; copy the low byte @DP[1] to the IMR register

move WDCN, LC[0]

; assembles to: move PFX[2], #00h

; move (WDCON-80h), LC[0]

8-bit destination high byte(16-bit source)

If, however, we needed to load an 8-bit register with the high byte of a 16-bit source, it would be best to use the GR
register. Transferring the 16-bit source to the GR register adds a single cycle.


move GR, LC[0]

; move LC[0] to the GR register

move IC, GRH

; copy the high byte into the IC register

Advertising