260 likes | 430 Views
ECT 464 . Lecture 23 Siemens Instructions 2. Today’s Quote: When confronted with a Goliath-sized problem, which way do you respond: “He’s too big to hit” or, like David, “He’s too big to miss.”
E N D
ECT 464 Lecture 23 Siemens Instructions 2
Today’s Quote: When confronted with a Goliath-sized problem, which way do you respond: “He’s too big to hit” or, like David, “He’s too big to miss.” The LORD who delivered me from the paw of the lion and the paw of the bear will deliver me from the hand of this Philistine." Saul said to David, "Go, and the LORD be with you." 1 Samuel 17:37
Comparison Instructions The compare instructions are used to compare two values: IN1 = IN2 EQU IN1 >= IN2 GRE IN1 <= IN2 LEQ IN1 > IN2 GRT IN1 < IN2 LES IN1 <> IN2 NEQ Compare Byte operations are unsigned. Compare Integer operations are signed. Compare Double Word operations are signed. Compare Real operations are signed.
Compare String The Compare String instruction compares two strings of ASCII characters: IN1 = IN2 IN1 <> IN2 When the comparison is true, the Compare instruction turns the contact (LAD) or output (FBD) on, or the compare instruction Loads, ANDs or ORs a 1 with the value on the top of the stack (STL).
Numerical Conversions The Byte to Integer (BTI), Integer to Byte (ITB), Integer to Double Integer (ITD), Double Integer to Integer (DTI), Double Integer to Real (DTR), BCD to Integer (BCDI) and Integer to BCD (IBCD) instructions convert an input value IN to the specified format and stores the output value in the memory location specified by OUT. For example, you can convert a double integer value to a real number. You can also convert between integer and BCD formats.
Round & Truncate The Round instruction (ROUND) converts a real value IN to a double integer value and places the rounded result into the variable specified by OUT. The Truncate instruction (TRUNC) converts a real number IN into a double integer and places the whole-number portion of the result into the variable specified by OUT.
Seven Segment The Segment instruction (SEG) allows you to generate a bit pattern that illuminates the segments of a seven-segment display.
ASCII Conversion The ASCII to Hexadecimal instruction (ATH) converts a number LEN of ASCII characters, starting at IN, to hexadecimal digits starting at OUT. The Hexadecimal to ASCII instruction (HTA) converts the hexadecimal digits, starting with the input byte IN, to ASCII characters starting at OUT. The number of hexadecimal digits to be converted is specified by length LEN. The maximum number of ASCII characters or hexadecimal digits that can be converted is 255. Valid ASCII input Valid ASCII input characters are alphanumeric characters 0 to 9 with a hex code value of 30 to 39, and uppercase characters A to F with a hex code value of 41 to 46.
String Conversion Converting Numerical Values to String The Integer to String (ITS), Double Integer to String (DTS), and Real to String (RTS) instructions convert integers, double integers, or real number values (IN) to an ASCII string (OUT). Operation of the Integer to String The Integer to String instruction (ITS) converts an integer word IN to an ASCII string with a length of 8 characters. The format (FMT) specifies the conversion precision to the right of the decimal, and whether the decimal point is to be shown as a comma or a period. The resulting string is written to 9 consecutive bytes starting at OUT.
String Conversion The Substring to Integer (STI), Substring to Double Integer (STD), and Substring to Real (STR) instructions convert a string value IN, starting at the offset INDX, to an integer, double integer or real number value OUT.
Encoder and Decoder Encode The Encode instruction (ENCO) writes the bit number of the least significant bit set of the input word IN into the least significant “nibble” (4 bits) of the output byte OUT. Decode The Decode instruction (DECO) sets the bit in the output word OUT that corresponds to the bit number represented by the least significant “nibble” (4 bits) of the input byte IN. All other bits of the output word are set to 0.