
Commands - 8
BCD
Numeric Fun ction
SYNTAX: n = BCD(m)
PURPOSE: To return four digits in packed BCD format from a number.
REMARK S: The four BCD digits are stor ed in the variable n. Each BC D digit is 4– bits and the four BCD d igits
are stored in 16– bit form . T hese are known as packed BC D num bers. One com mon use is to
convert a count to BCD to send to displays that have BCD inputs.
RELATED: BIN
EXAMPLE: A = 456
PRINT BCD(A)
1110
At first, the answer above appears to be wrong. This is due to the fact that the 4– digit BCD
number has been packed into 16– bits and the print command is treating it as a binary number.
The following converts a 4– digit number and outputs it to two ports:
10 N = BCD(6789)
20 M = N AND 255
30 OUT 1,M
40 N = N \ 256
50 OUT 2,N
ERROR: < Illegal argument> – if m > 9999
< Data negative > – for m
Commentaires sur ces manuels