Chapter 5: Intelligent Box (IBox) Instructions
Math - BCD (MATHBCD) (IB-521)
1
Math - BCD Format lets you enter complex
mathematical expressions like you would in
230
Visual Basic, Excel, or C++ to do complex
2
calculations, nesting parentheses up to 4 levels
240
deep. In addition to + - * /, you can do Modulo
250-1
3
(% aka Remainder), Bit-wise And (&) Or (|)
260
Xor (^), and some BCD functions - Convert to
BCD (BCD), Convert to Binary (BIN), BCD
4
Complement (BCDCPL), Convert from Gray
DS5 Used
Code (GRAY), Invert Bits (INV), and
N/A
HPP
5
BCD/HEX to Seven Segment Display (SEG).
Example: ((V2000 + V2001) / (V2003 - K100)) * GRAY(V3000 & K001F)
6
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
7
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
8
always fit in 16 bits.
You can reference binary V-memory values by using the BCD conversion function on a V-
9
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
10
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
11
operation to store the result as Binary.
12
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)
13
• 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.
14
A
WORD Result . . . . . . . . . . . . . . . . . . . . . . . . . . V
Expression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B
C
D
5–258
DL205 User Manual, 4th Edition, Rev. B
Parameter
DL205 Range
See DL205 V-memory map - Data Words
Text
Need help?
Do you have a question about the DirectLOGIC DL205 Series and is the answer not in the manual?