lab 4
TRANSCRIPT
![Page 1: LAB 4](https://reader036.vdocuments.us/reader036/viewer/2022083112/577cc9e81a28aba711a4e9ce/html5/thumbnails/1.jpg)
Object#4
In this experiment we perform four logical operations:
1. AND instruction to convert ASCII encoded number to BCD form.
2. OR instruction to round up data to an odd number.
3. XOR instruction to compare if two numbers are equal.
4. Complement instruction to find the 2’s complement of a number.
1. AND instruction to convert ASCII encoded number to BCD form.
An AND instruction result is 1 only if both bits of the two numbers operated on are logic 1
Procedure
-Switch to the 8080 mode by Pressing F4
-Enter the following Routine beginning at RAM location 1000h to Use the AND logic function.
CODE Mnemonics PSEUDOCODE
3E 38 MVI A,38 Load ASCII encoded number into the Register
E6 0F ANI 0Fh AND immediate data
D7 RST 2 Restart
-Press Enter after hexadecimal byte.
-Press the Esc key after D7
-Enter (D 1000) and verify that the program has been entered properly.
-Press the Esc key to return to the Command prompt.-Enable the Trace function (“g” and select Trace into)-Type “R 1000” and press enter to execute the first instruction. And result of ASCII is displayed
The ASCII value for the BCD Number 8 Is 38
![Page 2: LAB 4](https://reader036.vdocuments.us/reader036/viewer/2022083112/577cc9e81a28aba711a4e9ce/html5/thumbnails/2.jpg)
< AND Instructions on GNU Simulator>Our Program with Hex Code3EC 3E 38 MVI A,38h3EE E6 0F ANI 0Fh3F0 76 hlt Snapshot of GNU Simulator
Figure AND Instruction convert ASCII to BCD Number
2. OR instruction to round up data to an odd number.
The OR logic instructions in 0.if both bits of the two binary numbers operated on are 0.
14=00001110
01=00000001
15= 00001111
Procedure
-Switch to the 8080 mode by Pressing F4
-Enter the following Routine beginning at RAM location 1100h to Use OR logic function.
CODE Mnemonics PSEUDOCODE
3E 14 MVI A,14H Load 14 into register A
F6 01 ORI 01h Logic OR data 01 with A
D7 RST 2 Restart
![Page 3: LAB 4](https://reader036.vdocuments.us/reader036/viewer/2022083112/577cc9e81a28aba711a4e9ce/html5/thumbnails/3.jpg)
-Press Enter after hexadecimal byte.-Press the Esc key after D7-Enter (D 1100) and verify that the program has been entered properly.-Press the Esc key to return to the Command prompt.-Enable the Trace function (“g” and select Trace into)-Type “R 1100” and press enter to execute the first instruction. And result of OR instruction is displayed
This program used the OR instruction and a bit mask to round up an even number to an odd number. If the number was already odd,it would stay the same.
< OR Instructions on GNU Simulator>Our Program with Hex Code
44C C3 4F 4 jmp start ;data ;code 44F 00 start: nop 450 3E 14 MVI A,14h 452 F6 01 ORI 01h 454 76 hlt
Snapshot of GNU Simulator
Figure: OR Instruction
![Page 4: LAB 4](https://reader036.vdocuments.us/reader036/viewer/2022083112/577cc9e81a28aba711a4e9ce/html5/thumbnails/4.jpg)
3. XOR instruction to compare if two numbers are equal.
THE XOR instruction results is 0 if both of the two numbers operated on are alike
Procedure
-Switch to the 8080 mode by Pressing F4
-Enter the following Routine beginning at RAM location 1200h to Use XOR logic function.
CODE Mnemonics PSEUDOCODE
3E 55 MVI A,55 Load 55 into register A
EE 01 XRI 56 XOR 56H WITH A
D7 RST 2 Restart
-Press the Esc key after D7-Enter (D 1200) and verify that the program has been entered properly.-Press the Esc key to return to the Command prompt.-Enable the Trace function (“g” and select Trace into)-Type “R 1200” and press enter to execute the first instruction. And result of XOR instruction is displayed
This program compared the two hexadecimal bytes 55h and 56h using the logic XOR instruction. If they are identical a result of zero would occur. If they were not identical ,a non-zero result would occur.
< XOR Instructions Result on GNU Simulator>
![Page 5: LAB 4](https://reader036.vdocuments.us/reader036/viewer/2022083112/577cc9e81a28aba711a4e9ce/html5/thumbnails/5.jpg)
Figure XOR Instruction Result
4. Complement instruction to find the 2’s complement of a number
The Complement instruction inverts each bit of a word
Procedure
-Switch to the 8080 mode by Pressing F4
-Enter the following Routine beginning at RAM location 1300h to Use Complement logic function.
CODE MNEMONIC PSEUDOCODE
3E D5 MVI ,D5h Load D5h into A
D3 40 OUT 40 Output A to port 40
2F CMA Complement A
D3 40 OUT 40 Output A to Port 40
3C INR A Increment A by 1
D3 40 Out 40 Output A to Port 40
D7 RST 2 Restart
The immediate data D5h was loaded into the accumulator and then written to port 40.
Snapshot of GNU Simulator
![Page 6: LAB 4](https://reader036.vdocuments.us/reader036/viewer/2022083112/577cc9e81a28aba711a4e9ce/html5/thumbnails/6.jpg)