DL205 User Manual, 4th Edition, Rev. B
5–258
Chapter 5: Intelligent Box (IBox) Instructions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
A
B
C
D
Math - BCD (MATHBCD) (IB-521)
Math - BCD Format lets you enter complex
mathematical expressions like you would in
Visual Basic, Excel, or C++ to do complex
calculations, nesting parentheses up to 4 levels
deep. In addition to + - * /, you can do Modulo
(% aka Remainder), Bit-wise And (&) Or (|)
Xor (^), and some BCD functions - Convert to
BCD (BCD), Convert to Binary (BIN), BCD
Complement (BCDCPL), Convert from Gray
Code (GRAY), Invert Bits (INV), and
BCD/HEX to Seven Segment Display (SEG).
Example: ((V2000 + V2001) / (V2003 - K100)) * GRAY(V3000 & K001F)
Every V-memory reference MUST be to a single-word BCD formatted value. Intermediate
results can go up to 32-bit values, but as long as the final result fits in a 16-bit BCD word, the
calculation is valid. Typical example of this is scaling using multiply then divide, (V2000 *
K1000) / K4095. The multiply term most likely will exceed 9999 but fits within 32 bits. The
divide operation will divide 4095 into the 32-bit accumulator, yielding a result that will
always fit in 16 bits.
You can reference binary V-memory values by using the BCD conversion function on a V-
memory location but NOT an expression. That is BCD(V2000) is okay and will convert
V2000 from Binary to BCD, but BCD(V2000 + V3000) will add V2000 as BCD, to V3000
as BCD, then interpret the result as Binary and convert it to BCD - NOT GOOD.
Also, the final result is a 16-bit BCD number and so you could do BIN around the entire
operation to store the result as Binary.
MATHBCD Parameters
• Result (WORD): specifies the location where the BCD result of the mathematical expression will be
placed (result must fit into 16-bit single V-memory location)
• Expression: specifies the mathematical expression to be executed and the result is stored in specified
Result (WORD). Each V-memory location used in the expression must be in BCD format.
Parameter
DL205 Range
WORD Result . . . . . . . . . . . . . . . . . . . . . . . . . . V
See DL205 V-memory map - Data Words
Expression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Text
DS5 Used
HPP
N/A
ý
ý
þ
þ
230
240
2
5
0
-1
2
6
0