Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Microcontrollers and Embedded Systems ( MTS - 311 ) LAB REPORT

Microcontrollers and Embedded


Systems
(MTS-311)

DE-43 Mechatronics
Syndicate – B

LAB REPORT # 5
LOGIC AND COMPARE INSTRUCTION SETS

Names of Group Members:


 PC Talha Aftab CMS ID #398492
 NS Rayyan Naveed CMS ID #365733

Submitted to: LD Qasim

Page PAGE 3 of NUMPAGES 3


Microcontrollers and Embedded Systems ( MTS - 311 ) LAB REPORT

Introduction:
The objectives for our lab was to gain a comprehensive understanding of the logical
instructions in assembly language and employ them to address real-world challenges through
assembly programming, utilizing rotate instructions within the assembly language
framework and use compare instructions in assembly language programming.

Objective:
Compare instructions are indispensable for enabling conditional branching and
decision-making within program structures. logical instructions include operations such as
bitwise AND, OR, XOR, and bit shifting. Our primary objective is to understand and use
these operations to understand the practical utility of these instructions in terms of optimizing
code performance and providing control over microprocessor execution.

Logical AND (ANL):


The ANL (And Logical) assembly language instruction is a fundamental operation used in
low-level programming to perform bitwise logical AND operations between two binary
values. It is a crucial operation for data manipulation and decision-making in the context of
microprocessor programming. The ANL instruction operates by taking two binary inputs,
typically provided as operands, and computes their logical AND result on a bit-by-bit basis.

Truth Table for ANL Instruction:

R1 1 0 1 0 1 1 0 1
R2 1 1 1 0 0 1 0 1
Result 1 0 1 0 0 1 0 1

Logical OR (ORL):

Page PAGE 3 of NUMPAGES 3


Microcontrollers and Embedded Systems ( MTS - 311 ) LAB REPORT

The ORL (OR Logical) assembly language instruction is a fundamental operation used in
low-level programming to perform bitwise logical OR operations between two binary values.
The ORL instruction operates by taking two binary inputs, typically provided as operands,
and computes their logical OR result on a bit-by-bit basis.

The truth table for ORL is as follows:

R1 1 0 1 0 1 1 0 1
R2 1 1 1 0 0 1 0 1
Result 1 1 1 0 1 1 0 1

Logical NOT Instruction (CPL):


The CPL (Complement) assembly language instruction is a fundamental operation in low-
level programming used to perform bitwise logical NOT (complement) operations on binary
values. The CPL instruction operates by taking a single binary input, typically provided as an
operand, and flipping (inverting) all the bits.

The truth table for CPL is:

R1 1 0 1 0 1 1 0 1
Result 0 1 0 1 0 0 1 0

Logical XOR (XRL):


The XRL assembly language instruction is used to perform bitwise logical XOR operations
between two binary values. When Operand A and Operand B are different (one is 0, and the
other is 1), the result is 1; when they are the same (both 0 or both 1), the result is 0.

R1 1 0 1 0 1 1 0 1
R2 1 1 1 0 0 1 0 1
Result 0 1 0 0 1 0 0 0

Rotate Right (RR):


The RR (Rotate Right) assembly language instruction is used to perform a bitwise rotation of
binary values to the right. It's a useful operation for shifting the bits of a binary value The RR

Page PAGE 3 of NUMPAGES 3


Microcontrollers and Embedded Systems ( MTS - 311 ) LAB REPORT

instruction operates by taking a binary input, typically provided as an operand, and rotates its
bits to the right, with the rightmost bit becoming the new leftmost bit.

Operand: 11011010B

Result after RR: 01101101B

Rotate Left (RL):


The RL (Rotate Left) assembly language instruction used to perform a bitwise rotation of
binary values to the left. The RL instruction takes a binary input, typically provided as an
operand, and rotates its bits to the left, with the leftmost bit becoming the new rightmost bit.
It is the opposite of the RR instruction.

Operand: 11011010B

Result after RL: 10110101B

Rotate Left Through Carry (RRC):


The RLC (Rotate Left through Carry) instruction performs bitwise rotation of binary values
to the left, while considering the carry bit The RLC instruction takes a binary input, typically
provided as an operand, and rotates its bits to the left. The leftmost bit is moved to the
rightmost position, and the carry flag is involved in this rotation.

Operand: 11011010B

Carry Flag: 1

Result after RLC:

Operand: 01101100B

Carry Flag: 1

Rotate Left Through Carry (RLC):

Page PAGE 3 of NUMPAGES 3


Microcontrollers and Embedded Systems ( MTS - 311 ) LAB REPORT

The RRC (Rotate Right through Carry) instruction which is used for bitwise rotation of
binary values to the right while considering the carry flag. The RRC instruction takes a binary
input, typically provided as an operand, and rotates its bits to the right. The rightmost bit
moves to the leftmost position.

Operand: 11011010B

Carry Flag: 1

Result after RRC:

Operand: 01101101B

Carry Flag: 0

Compare Jump if NOT Equal (CJNE):


The CJNE (Compare and Jump if Not Equal) instruction is used to compare two values and
conditionally branch to a different part of the program if they are not equal. The CJNE
instruction takes two binary inputs, compares them, and based on the comparison result, it
may trigger a jump to a specific memory address.

CJNE A, #17H, NEXT

CJNE R1, #50H, OVER

CJNE A, P1, WAIT

Lab Task 1:

Page PAGE 3 of NUMPAGES 3


Microcontrollers and Embedded Systems ( MTS - 311 ) LAB REPORT

Lab task 2:

Page PAGE 3 of NUMPAGES 3

You might also like