Lazaro, Joven Joseph T.
TUT- Microsy
Pre-Laboratory
Lazaro, Joven Joseph T.
TUT-Microsy
Laboratory Work
Using what was learned from laboratory # 4 and # 5, create a program that will compute
for the sum and difference of two numbers with two digits each.
Save your work as Labass6.asm
Output:
The arithmetic instructions include addition, subtraction, multiplication,
division, comparison, negation, increment, and decrement. The logic instructions
include AND, OR, Exclusive-OR, NOT, shifts, rotates and the logical compare (TEST).
Arithmetic instructions perform several basic operations such as addition, subtraction,
division, multiplication etc. After execution, the result is stored in the first operand. Logic
instructions perform logic operations upon corresponding bits of two registers.
In byte-oriented systems (i.e. most modern computers), the term unpacked
BCD usually implies a full byte for each digit (often including a sign), whereas packed
BCD typically encodes two decimal digits within a single byte by taking advantage of the
fact that four bits are enough to represent the range 0 to 9.
For the representation of numbers:
A. ASCII representation Numbers are stored as a string of ASCII characters.
For example: 1234 is stored as 31 32 33 34H. ASCII for 1 is 31H, for 2 is 32H,
etc.
B. BCD representation
B.1 Unpacked BCD
Example: 1234 is stored as 01 02 03 04H Additional byte is used for sign. Sign
byte: 00H for + and 80H for –
B.1 Packed BCD
Saves space by packing two digits into a byte.
Example: 1234 is stored as 12 34H
For the arithmetic and logic instructions, the MOV CH, AL AND MOV CL,
AL are being used to read high and low digits respectively. Some arithmetic instructions
were also incorporated such as SUB and MUL however for the logic instructions, XOR
and OR are being used.
In performing operations of numbers, bytes are being manipulated using
the arithmetic and logic instructions. In the experiment, the arithmetic instructions that
are used in putting the digits in one byte are SUB and MUL including also the MOV
instruction. The logic instructions are XOR and OR. In performing the addition, the input
numbers are in BCD format and the ADD instruction was used with the DAA for the
decimal adjust. In displaying the number in BCD format, the logic instructions XOR and
AND were used to clear values of AH and AL. The arithmetic instructions DIV is used
for byte manipulation and the ADD instruction is to convert into a character.
Conclusion
Upon performing the experiment, I was able to have a deeper
understanding regarding arithmetic and logic instructions particularly on performing
operations with multiple digits involved. The incorporation of these instructions in one
program are helpful in accomplishing a code which performs addition and subtraction
similar to the experiment. In storing two digits in a byte, the packed BCD representation
can be used. If two BCD digits are stored per byte, it’s called Packed BCD. This occurs
in data transmission where numbers are being transmitted over a communications link.
Packed BCD reduces the amount of time spent transmitting the numbers, as each data
byte transmitted results in the sending of two BCD digits.