Вы находитесь на странице: 1из 5

Activity No.

5
LOGICAL INSTRUCTIONS
Course Code: CPE005
Program:
Course Title: Computer Systems Organization with Assembly Date Performed: August 3, 2016
Language
Section: CPE42FA1
Date Submitted: August 3, 2016
Name: Abdon, Aeron Paul B.
Instructor: Engr. Taylar
1. Objective:
This activity aims to demonstrate the logical instructions AND, OR XOR, and NOT.
2. Intended Learning Outcomes (ILOs):
After completion of this activity the students should be able to:
2.1 Compare the different logical instructions
2.2 Create programs applying logical instructions
3. Discussion :
Logical Instructions
Logical instructions are used for performing Boolean Algebra. Boolean Algebra is the algebra that
defines a set of operations on the values TRUE and FALSE. It be used to describe the design of digital
circuits . At the same time, boolean expressions are used in programming to express logical operations.
Boolean Expression
A boolean expression involves a boolean operator and one or more operands. Each boolean expression
implies a value of true or false. The set of operators includes: AND,OR, XOR and NOT.
The AND
AND syntax:
AND REGISTER1, REGISTER2
AND REGISTER, VALUE
AND returns 1 (TRUE) only if BOTH operands are 1 (TRUE)
The AND operation is useful for CLEARING particular bits in an operand ('0' AND anything ='0'). For
example, the operation: AND AL, 0Fh will set bits B7-B4 to '0', and leave bits B3-B0 unaffected.
The OR
OR syntax:
OR REGISTER1, REGISTER2
OR REGISTER, VALUE
OR returns 1 (TRUE) if either operand is 1 (TRUE)
The OR operation is useful for SETTING particular bits in an operand ('1' OR anything = '1'). For example,
the operation: OR AL, 0Fh will set bits B3-B0 to '1', and leave bits B7-B4 unaffected.
The XOR
XOR syntax:
XOR REGISTER1, REGISTER2
XOR REGISTER, VALUE
XOR returns 1 (TRUE) if one or the other operand is 1 (TRUE), but not both

The XOR operation is useful complementing bits in an operand ('1' XOR anything =not(anything)). For
example, the operand XOR AL, 0Fh will complement bits B3-B0 and leave bits B7-B4 unaffected. The XOR
operation can also be used to clear a register to zero the operation XOR AX, AX will set AX to zero (this
requires less machine code than MOV AX,0000).
The NOT
NOT syntax:
NOT REGISTER
NOT VALUE
The NOT reverses or complements the value it follows.
4. Resources:
Computer with 32-bit Operating System
TASM
5. Procedure:
Sample Problem 1:
Type the following program in Notepad.
TITLE logic.asm
.model small
.stack 100h
.data
myString db "Proud to be TIPians","$"
.code
main proc
mov ax,@data
mov ds,ax
mov bx,offset myString
LP1: mov dl,[bx]
Cmp dl, '$'
Je exit
Inc bx
;insert code here
mov ah,02
int 21h
jmp lp1
Exit: Mov ax, 4c00h
Int 21h
Main endp
End main
Save the program as logic.asm
Assemble and execute the program.
Analyze the output and record the output in Table 5.1

Sample Problem 2:
1. Modify program logic.asm.
2. Replace the line ; insert code here , with " and dl, 11011111B " .
3. Save the program as and.asm.
4. Assemble and execute the program.
5. Observe and record the output in Table 5.2
6. How is your output different from before? Why?
The second output differ from the first in terms of Capitalization. Because in the first output
the only capitalized letters are the P and TIP. While in the second output all the letters
became capitalized.
Sample Problem 3:
1. Modify logic.asm again, this time replace the line ;insert code here , with xor dl, 00100000B ".
2. Save the program as xor.asm.
3. Assemble and execute the program.
4. Observe and record the output in Table 5.2.
How is your output different from before? Why?
The third output is the reverse of the first output. The small letters became the capitalized
and the Capitalized letters became small letters.
Sample Problem 4:
1. Modify logic.asm once again, this time place the line ;insert code here, with "or dl, 00100000B".
2. Save the program as or.asm.
3. Assemble and execute the program.
4. Observe and record the output in Table 5.3.
5. How is your output different from before? Why?
In the fourth output all the letters became small which is the reverse of the second output
that has all capitalized letters.

6. DATA ANALYSIS:

Table 5.1-Output of logic.asm

Table 5.2- Output of and.asm

Table 5.1-Output of xor.asm

Table 5.2- Output of or.asm

PROBLEMS:
1. Write an assembly program that will simulate the given Boolean expression using assembly
programming.
AL = (AH BH + AL BL) xor (CL+(CH DH) DL)
Mul ah, bh
Mul al,bh
Add ah,al
Neg ah
Mul ch,dh
Neg ch
Mul ch,dl
Add cl,ch
Xor cl,ah
Mov al,cl
2. Give a sample problem where the logical instructions can be applied.
8. Assessment (Rubric for Laboratory Performance):

Вам также может понравиться