Assembly
Language ProgrammingBarcode scanners convert stripes of varying thickness to a sequence of characters. Many barcode symbologies incorporate internal check characters (characters added to the actual symbol string) to determine if the scan was correct, or if some of the characters were interpreted incorrectly. In a properly designed decoder, the decoder calculates the check character(s) and makes a comparison to the character(s) embedded in the symbol string. If there is a match, the check characters are usually stripped and the actual data is what remains. If there is no match, the decoder indicates a "no read" condition.
Two checkcode algorithms are described below. This information comes from SmartTronics, a manufacturer of barcode readers.
Standard LRC AlgorithmThe LRC algorithm is an extremely simple error detection method which yields any character from 00h (0) through 0FFh (255). LRC stands for Longitudinal Redundancy Check, an old method based on longitudinal parity. There are two major disadvantages of this method. The first problem is that the resulting check character may be a control character which could interfere with data communications. The second problem is that it is not highly effective, particularly with long transmissions. Calculating the check sum:
Example: ABC123 LRC: p
|
Smartronics Communications - SmartChek AlgorithmThe SmartChek algorithm is an extension of the QuikChek with substantially lower probability of error. This algorithm is suitable for essentially all applications. The computed check characters are never control characters, so it may be easily implemented in any system. The math involved refers to the ASCII value of each of the characters. Calculating the check sum:
Example: ABC123 SmartChek: +(
NOTE for ASSEMBLY LANGUAGE PROGRAMMERSYou need to use 16-bit values when you perform these calculations. The Modulo 64 value is simply the low order six bits of the sum. The Modulo 4096 value is the low order 12 bits of the sum. In step 6, you use bits 6-11 to compute the first check character. Bits 0-5 are used to calculate the second. No division is required for either method. |
Your task is to implement a checksum generator. Given a sequence of up to 16 characters, determine the proper checksum for each algorithm. Output the LRC checkcode in Hex, and the SmartChek algorithm's checkcode as a pair of ASCII characters. Sample output is shown here:
C:\>marg2 ?ABC123 LRC: 70h Smartchek: +( ?723-0094AB LRC: ??h Smartchek: ?? (I will wait for someone to tell me the right answers!) ? C:\>
Your program is to read from the keyboard and write to the screen. You will be expected to process a series of inputs, one input per line. You may assume no input will contain more than 16 characters. When an input consists of zero characters, your program should stop.
You must utilize functions in your solution. You must use call-by-reference and call-by-value. You must use a stack-frame for passing arguments in some of your functions. Do not use the Irvine library. Avoid using global variables in your functions. Only the main procedure should make use of the variable names in the data segment.
Function suggestions (strongly suggested):
Write an input function that is passed the address of an array and the maximum length of the input. The function should read one line of input into the array and return the number of characters stored.
Write a function to compute the LRC value (pass the address of the array and the number of characters in the data - return the result in a register in AL).
Write a function that will convert a byte value (perhaps the value in AL) into two hex characters, storing them into an array of 2 bytes. You would pass the address of this array.
Write another function that will compute the SmartChek value (pass the address of the array and the number of characters in the data and the address of a pair of bytes where the result is to be stored).
These last two functions can store directly into your output string (where the ??'s appear above) and then a single application of the DOS function to display a string should be sufficient to produce the output for each input case.
Be sure to organize your solution so it is easy to understand and document it adequately. Submit the executable and source files (zipped). The subject of the mail message should identify the submission as Assembly Language Program 2. Your source and executable should be named with the first 4 letters of your last name followed by the digit 2.