ST20-C1 STMICROELECTRONICS [STMicroelectronics], ST20-C1 Datasheet - Page 39

no-image

ST20-C1

Manufacturer Part Number
ST20-C1
Description
Instruction Set Reference Manual
Manufacturer
STMICROELECTRONICS [STMicroelectronics]
Datasheet
The subscripts ‘lo’ and ‘hi’, used here and in subsequent text, specify the least and
most significant word respectively of the double word variable with which they are
associated.
Subtraction of two double length values, Y from X giving Z , without overflow signalling
is compiled as
Overflow signalling for signed arithmetic may be added by performing an extra addc or
subc to produce a final w ord which contains only a sign (0 for positive or -1 for
negative) unless an overflow has occurred. For example, the following code could be
used to perform double length signed addition with overflow signalling:
Multiple length multiplication
The umac instruction multiplies two single word unsigned operands in Areg and Breg,
and adds the single word carry operand in Creg to form a double length unsigned
result. The more significant (carr y) word of the result is left in Breg, the less significant
in Areg. No overflow can be signalled by this instruction.
Multiplication of a single length unsigned value X by a double length unsigned value Y
(leaving the ‘carry’ in Areg) can be performed by:
Double length unsigned multiplication is more complex. The product of two unsigned
double length words X and Y can be expressed as:
This can be coded as follows:
ldc 0;
ldl X
ldl X
ldc 0;
ldl X
ldl X
clear carry, overflow and underflow status bits
ld X
ld X
ldc 0; dup; addc;
dup; adc #7ffffff;
rev; adc #8000001;
ldc 0;
ldl X; ldl Y
ldl X; ldl Y
X * Y= (X
ldc 0;
ldl X
ldl X
lo;
hi;
lo
hi
lo
hi
lo
lo
= (X
; ldl Y
; ldl Y
; ldl Y
; ldl Y
; ldl Y
; ldl Y
ld Y
ld Y
hi
hi
lo
hi
lo;
hi;
*2
*Y
lo
hi
lo
hi
; umac; stl Z
; umac; stl Z
lo
hi
addc; st Z
; addc; stl Z
; addc; stl Z
; subc; stl Z
; subc; stl Z
addc; st Z
; umac; stl Z
; umac; rev; stl Z
32
hi
)*2
+ X
64
lo
+ (X
)*(Y
lo;
hi;
lo
hi
lo
hi
lo
hi
hi
hi
;
0
;
*2
*Y
;
32
lo
2
+ X
+ Y
lo
lo
*Y
)
- overflows if and only if carry word > 0
- underflows if and only if carry word < -1
hi
)*2
32
+ (X
4 Using ST20-C1 instructions
lo
*Y
lo
)
39/205

Related parts for ST20-C1