3 operation examples – Toshiba H1 Series User Manual

Page 635

Advertising
background image

TMP92CZ26A

92CZ26A-632

3.26.3 Operation Examples

(1) Unsigned multiply-accumulate operation

The following shows a setting example for calculating “33333333

+ 11111111 × 22222222”:

ld

(MACCR), 0x08

; Unsigned multiply-accumulate mode

Start calculation by write to MACMB.

ld

xde, 0x00000000

ld

xhl, 0x33333333

ld

xix, 0x11111111

ld

xiy, 0x22222222

ld

(MACORL), xhl

; Write 33333333 to MACORL.

ld

(MACORH), xde

; Clear MACORH.

ld

(MACMA), xix

; Write 11111111 to MACMA.

ld

(MACMB), xiy

; Write 22222222 to MACMB.

ld

xhl, (MACORL)

; Read lower result 0x41FDB975.

bit

7, (MACCR)

; Check over-flow error

jp

nz, ERROR

; Go to error routine, if there is over-flow error

ld

xde, (MACORH)

; Read upper result 0x02468ACF.

(2) Signed multiply-subtract operation

The following shows a setting example for calculating “33333333

− 11111111 × −22222222”:

ld

(MACCR), 0x25

; Signed multiply-subtract mode

Start calculation by write of “1” to <MOPST>.

ld

xde, 0x00000000

ld

xhl, 0x33333333

ld

xix, 0x11111111

ld

xiy, 0xDDDDDDDE

;

22222222

ld

(MACORL), xhl

; Write 33333333 to MACORL.

ld

(MACORH), xde

; Clear MACORH.

ld

(MACMA), xix

; Write 11111111 to MACMA.

ld

(MACMB), xiy

; Write

22222222 to MACMB.

set

5,

(MACCR) ;

ld

xhl, (MACORL)

; Read lower result 0x41FDB975.

bit

7, (MACCR)

; Check over-flow error

jp

nz, ERROR

; Go to error routine, if there is over-flow error

ld

xde, (MACORH)

; Read upper result 0x02468ACF.

(3) Unsigned multiply-accumulate operation (two multiply-accumulate operations)

The following shows a setting example for calculating “(33333333

+ 11111111 Ч 22222222) +

(11111111

Ч 44444444)”:

ld

(MACCR), 0x08

; Unsigned multiply-accumulate mode

Start calculation by write to MACMB.

ld

xde, 0x00000000

ld

xhl, 0x33333333

ld

xix, 0x11111111

ld

xiy, 0x22222222

ld

xiz, 0x44444444

ld

(MACORL), xhl

; Write 33333333 to MACORL.

ld

(MACORH), xde

; Clear MACORH.

ld

(MACMA), xix

; Write 11111111 to MACMA.

ld

(MACMB), xiy

; Write 22222222 to MACMB.

ld

(MACMB), xiz

; Write 44444444 to MACMB.

ld

xhl, (MACORL)

; Read lower result 0x5F92C5F9.

bit

7, (MACCR)

; Check over-flow error

jp

nz, ERROR

; Go to error routine, if there is over-flow error

ld

xde, (MACORH)

; Read upper result 0x06D3A06D.

Calculation start

Calculation start

Calculation start

Calculation start

Advertising
This manual is related to the following products: