0% found this document useful (0 votes)
142 views

CMPSB Instruction in Assembly Language of 8086 Microprocessor

The document discusses the CMPSB instruction in 8086 assembly language, which compares bytes in two strings to see if they are equal. CMPSB subtracts the second operand from the first and sets flags like the Zero Flag to indicate if the results are equal. No operands are used with CMPSB as it uses the DS:[SI] and ES:[DI] registers. Loops can be created using prefixes like REP to repeatedly compare bytes and determine the number of loops with the CX register.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
142 views

CMPSB Instruction in Assembly Language of 8086 Microprocessor

The document discusses the CMPSB instruction in 8086 assembly language, which compares bytes in two strings to see if they are equal. CMPSB subtracts the second operand from the first and sets flags like the Zero Flag to indicate if the results are equal. No operands are used with CMPSB as it uses the DS:[SI] and ES:[DI] registers. Loops can be created using prefixes like REP to repeatedly compare bytes and determine the number of loops with the CX register.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

REPORT TITLE:

CMPSB Instruction in
Assembly Language of
8086 Microprocessor

2019-2020

Department: ‫قسم هندسة الحاسوب‬


Student Name: ‫ى‬
‫مرتض‬ ‫جنة تمار‬
Stage: ‫المرحلة الثانية‬
Study: ‫الدراسة الصباحية‬
College of Engineering
Class: A Mustansiriyah University
Course Name: Microprocessor
Email: [email protected]
‫الحاسوب‬ ‫قسم الهندسة‬ ‫كلية الهندسة – الجامعة المستنصرية‬

A : ‫ الشعبة‬/ ‫الثانية‬ :‫المرحلة‬ ‫جنة تمار مرتضى‬ : ‫االسم‬

Introduction:
A string is a series of the same type of data items in sequential memory
locations. There are many string instructions, one of them is CMPSB which
stands for “Compare String Byte”.

Page 2 of 6
‫الحاسوب‬ ‫قسم الهندسة‬ ‫كلية الهندسة – الجامعة المستنصرية‬

‫‪A‬‬ ‫‪ /‬الشعبة ‪:‬‬ ‫الثانية‬ ‫المرحلة‪:‬‬ ‫جنة تمار مرتضى‬ ‫االسم ‪:‬‬

‫‪Page 3 of 6‬‬
‫الحاسوب‬ ‫قسم الهندسة‬ ‫كلية الهندسة – الجامعة المستنصرية‬

‫‪A‬‬ ‫‪ /‬الشعبة ‪:‬‬ ‫الثانية‬ ‫المرحلة‪:‬‬ ‫جنة تمار مرتضى‬ ‫االسم ‪:‬‬

‫‪Page 4 of 6‬‬
‫الحاسوب‬ ‫قسم الهندسة‬ ‫كلية الهندسة – الجامعة المستنصرية‬

‫‪A‬‬ ‫‪ /‬الشعبة ‪:‬‬ ‫الثانية‬ ‫المرحلة‪:‬‬ ‫جنة تمار مرتضى‬ ‫االسم ‪:‬‬

‫‪Page 5 of 6‬‬
‫الحاسوب‬ ‫قسم الهندسة‬ ‫كلية الهندسة – الجامعة المستنصرية‬

A : ‫ الشعبة‬/ ‫الثانية‬ :‫المرحلة‬ ‫جنة تمار مرتضى‬ : ‫االسم‬

Notes:
1- We can use STD instruction to set the Direction Flag, or CLD instruction to
clear it.

2- JMP instruction stands for (Jump), and JNZ stands for (Jump if the Zero Flag
is cleared).

Summary:
The operation of comparing two strings to see if they are equal, as might be
suspected, can be done with a loop and an if structure, but the code for this is rather
ungainly. Instead of showing this option, it is much easier to go straight to the
instruction designed for this task, which is the CMPSB instruction used to compare a
string of bytes. [3] We don’t put any operand with this instruction because it already
uses DS:[SI] and ES:[DI]. Many flags are affected by the comparison, but neither
operand is affected.

The second operand is subtracted from the first. If the result is zero (ZF gets set), the
operands were identical.

We can use a prefix with this instruction like REP (Repeat), REPE (Repeat till equal)
or REPZ (Repeat till zero), they all refer for loop, so we can determine the number of
the loop in CX register.

References:
1- A. P. Godse, D. A. Godse, (2009). Microprocessors and Interfacing
Techniques, Technical Publications Pune.

2- Mathul S. (2011). Microprocessor 8086 – Architecture, Programming and


Interfacing, New Delhi – 110001.

3- Streib J. T. (2020). Guide to Assembly Language, Gewerbestrasse 11, 6330


Cham, Switzerland.

Page 6 of 6

You might also like