DMC-1500
Chapter 7 Application Programming
•
99
Bit-Wise Operators
The mathematical operators & and | are bit-wise operators. The operator, &, is a Logical And. The
operator, |, is a Logical Or. These operators allow for bit-wise operations on any valid DMC-1500
numeric operand, including variables, array elements, numeric values, functions, keywords, and
arithmetic expressions. The bit-wise operators may also be used with strings.
Bit-wise operators are useful for separating characters from an input string. When using the input
command for string input, the input variable holds 6 bytes of data. Each byte is eight bits, so a number
represented as 32 bits of integer and 16 bits of fraction. Each ASCII character is represented as one
byte (8 bits), therefore the input variable can hold a six character string. The first character of the
string will be placed in the top byte of the variable and the last character will be placed in the lowest
significant byte of the fraction. The characters can be individually separated by using bit-wise
operations as illustrated in the following example:
Instruction Interpretation
#TEST
Begin main program
IN "ENTER",LEN{S6}
Input character string up to 6 characters into variable ‘LEN’
FLEN=@FRAC[LEN]
Define variable ‘FLEN’ as fractional part of variable ‘LEN’
FLEN=$10000*FLEN Shift
FLEN
by 32 bits (Convert fraction, FLEN, to integer)
LEN1=(FLEN&$00FF)*$1000000 Set
4
th
byte of FLEN = 1
st
byte of variable LEN1
LEN2=(FLEN&$FF00)*$10000 Set
3
rd
byte of FLEN = 1
st
byte of variable of LEN2
LEN3=(LEN&$000000FF)*$1000000 Set
1
st
byte of variable LEN3 = 4
th
byte of LEN
LEN4=(LEN&$0000FF00)*$10000 Set
1
st
byte of variable LEN4 = 3
rd
byte of LEN
LEN5=(LEN&$00FF0000)*$100 Set
1
st
byte of variable LEN5 = 2
nd
byte of LEN
LEN6=(LEN&$FF000000) Set
1
st
byte of variable LEN6 = 1
st
byte of LEN
MG LEN6 {S1}
Display ‘LEN6’ as string message of 1 char
MG LEN5 {S1}
Display ‘LEN5’ as string message of 1 char
MG LEN4 {S1}
Display ‘LEN4’ as string message of 1 char
MG LEN3 {S1}
Display ‘LEN3’ as string message of 1 char
MG LEN2 {S1}
Display ‘LEN2’ as string message of 1 char
MG LEN1 {S1}
Display ‘LEN1’ as string message of 1 char
EN
This program will accept a string input of up to 6 characters, parse each character, and then display
each character. Notice also that the values used for masking are represented in hexadecimal (as
denoted by the preceding ‘$’). For more information, see section
Summary of Contents for DMC-1510
Page 6: ......
Page 18: ...6 Chapter 1 Overview DMC 1500 THIS PAGE LEFT BLANK INTENTIONALLY...
Page 88: ...76 Chapter 6 Programming Motion DMC 1500 Figure 6 7 Motion intervals in the Home sequence...
Page 90: ...78 Chapter 6 Programming Motion DMC 1500 THIS PAGE LEFT BLANK INTENTIONALLY...
Page 137: ...DMC 1500 Chapter 7 Application Programming 125 THIS PAGE LEFT BLANK INTENTIONALLY...
Page 157: ...DMC 1500 Chapter 10 Theory of Operation 145 THIS PAGE LEFT BLANK INTENTIONALLY...
Page 160: ...148 Appendices DMC 1500 Card Level Layout...
Page 180: ...168 Appendices DMC 1500...
Page 198: ...186 Appendices DMC 1500 THIS PAGE LEFT BLANK INTENTIONALLY...