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

Activity No.

LOGICAL INSTRUCTIONS

Course Code: CPE005 Program: BSIT

Course Title: Computer Systems Organization with Date Performed:


Assembly Language

Section: IT31FB1 Date Submitted:

Sept. 10, 2019

Name: Justin Julius T. Cruz Instructor:

Mr. Jonatahn 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 programming 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
2. Save the program as logic.asm
3. Assemble and execute the program.
4. Analyze the output and record the output in Table 5.1

It has the phrase Proud to be TIPIans.

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?

All characters are become capitalized because of the operation and which
added to the code in which characters from previous saved logig.asm
must be 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?

There are characters that are capitalized and some are not because of the
statement that was added.

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 here, characters are in all lower case after adding the statement or dl,
00100000.
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)’

.model small
.stack 100h
.data
.code
main proc
mov ax, 11111011B
mov bx, 10110100B
mov cx, 01010101B
mov dx, 00110001B

sub ah, bh
add ah, al
sub ah, bl
sub ch, dh
add cl, ch
sub cl, dl
xor ah, cl
mov al, ah
mov ah, 02
Int 21h
Main endp
End main

2. Give a sample problem where the logical instructions can be applied.

Logical instruction can be used as Simple mixing instruction in cryptography.

8. Assessment (Rubric for Laboratory Performance):

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