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

MIC Ch 3

The document provides an overview of various assembly language instructions for the 8086 microprocessor, including logical operations (AND, OR, NOT, XOR), process control instructions (STC, CMC, STD, CLD), and string instructions (MOVS, CMPS, SCAS). It also describes different addressing modes such as immediate, register, direct, and indexed addressing, along with examples for each. Additionally, it differentiates between specific instructions and explains rotation instructions like ROL, ROR, RCL, and RCR.

Uploaded by

pritish8754
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

MIC Ch 3

The document provides an overview of various assembly language instructions for the 8086 microprocessor, including logical operations (AND, OR, NOT, XOR), process control instructions (STC, CMC, STD, CLD), and string instructions (MOVS, CMPS, SCAS). It also describes different addressing modes such as immediate, register, direct, and indexed addressing, along with examples for each. Additionally, it differentiates between specific instructions and explains rotation instructions like ROL, ROR, RCL, and RCR.

Uploaded by

pritish8754
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Program: Computer Engineering

Microprocessors (22415)

1. 8086 –Instruction Set This instruction AND’s each bit in a source


byte or word with the same number bit in a
1. What is role of XCHG instruction in destination byte or word. The result is put in
assembly language program? Give example destination.
Role of XCHG: Example: AND AX, BX
This instruction exchanges the contents of a • AND AL,BL
register with the contents of • AL 1111 1100
another register or memory location. • BL 0000 0011
Example: ---------------------
XCHG AX, BX ; Exchange the word in AX with • AL 0000 0000 (AND AL,BL)
word in BX.
2) OR – Logical OR
2. State the function of process control Sy Syntax :OR destination, source
instruction. Operation
i. STCii. CMCiii. STD iv. CLD Destination OR source
i) STC- Set carry flag: This instruction Set Carry Flags Affected :CF=0,OF=0,PF,SF,ZF
Flag. CF=1, STC does not affect any other flag. This instruction OR’s each bit in a source byte
ii) CMC- Complement carry flag: This or word with the corresponding bit in a
instruction Complement Carry Flag.CMC does destination byte or word. The result is put in a
not affect any other flag. specified destination.
iii) STD- Set direction flag: his instruction is Example :
used to set the direction flag to one so that SI • OR AL,BL
and/or DI can be decremented automatically • AL 1111 1100
after execution of string instructions. STD does • BL 0000 0011
not affect any other flags. This instruction Set ---------------------
Direction Flag. DF=1, • AL 1111 1111
iv) CLD- Clear direction flag: This instruction is 3) NOT – Logical Invert
used to reset the direction flag to zero, so that Syntax : NOT destination
SI and/or DI can be incremented automatically Operation: Destination NOT destination
after execution of string instructions. CLD Flags Affected :None
does not affect any other flag. This instruction The NOT instruction inverts each bit of the
Clear Direction Flag. DF=0 byte or words at the specified destination.
3 .Explain logical instructions of 8086 Example
Logical nstructions. NOT BL
1) AND- Logical AND BL = 0000 0011
Syntax : AND destination, source NOT BL gives 1111 1100
Operation
Destination ←destination AND source 4) XOR – Logical Exclusive OR
Flags Affected : CF=0,OF=0,PF,SF,ZF Syntax : XOR destination, source
Operation : Destination XOR source

Page 1 of 6
Program: Computer Engineering
Microprocessors (22415)

Flags Affected: CF=0,OF=0,PF,SF,ZF MOVS destination, source


MOVSB destination, source
5)TEST MOVSW destination, source
Syntax : TEST Destination, Source Operation: ES:[DI]<----- DS:[SI]
This instruction AND’s the contents of a It copies a byte or word a location in data
source byte or word with the contents of segment to a location in extra segment. The
specified destination byte or word and flags offset of source is pointed by SI and offset of
are updated, , flags are updated as result ,but destination is pointed by DI.CX register
neither operands are changed. contain counter and direction flag (DE) will be
Operation performed: setor reset to auto increment or auto
Flags set for result of (destination AND decrement pointers after one move.
source) Example
Example: (Any 1) LEA SI, Source
TEST AL, BL ; AND byte in BL with byte in AL, LEA DI, destination
no result, Update PF,SF, ZF. CLD
e.g MOV AL, 00000101 MOV CX, 04H
TEST AL, 1 ; ZF = 0 REP MOVSB
3] CMPS /CMPSB/CMPSW: Compare string
byte or Words.
4. Describe any four string instructions of
Syntax:
8086 assembly language.
CMPS destination, source
1] REP:
Operation: Flags affected < ----- DS:[SI]-
REP is a prefix which is written before one of
ES:[DI]
the string instructions. It will cause During
It compares a byte or word in one string with
length counter CX to be decremented and the
a byte or word in another string.
string instruction to be repeated until CX
SI Holds the offset of source and DI holds
becomes 0.
offset of destination strings. CS
Two more prefix.
contains counter and DF=0 or 1 to auto
REPE/REPZ: Repeat if Equal /Repeat if Zero.
increment or auto decrement pointer
It will cause string instructions to be repeated
after comparing one byte/word.
as long as the compared bytesor words Are
Example
equal and CX≠0.
LEA SI, Source
REPNE/REPNZ: Repeat if not equal/Repeat if
LEA DI, destination
not zero.
CLD
It repeats the strings instructions as long as
MOV CX, 100
compared bytes or words are not equal
REPE CMPSB
And CX≠0.
4] SCAS/SCASB/SCASW: Scan a string byte
Example: REP MOVSB
or word.
2] MOVS/ MOVSB/ MOVSW - Move String
Syntax:
byte or word.
SCAS/SCASB/SCASW
Syntax:
Page 2 of 6
Program: Computer Engineering
Microprocessors (22415)

Operation: Flags affected < ----- AL/AX-ES: 5. Describe any 6 addressing modes of
[DI] 8086 with one example each.
It compares a byte or word in AL/AX with a
byte /word pointed by ES: DI. 1. Immediate addressing mode:
The string to be scanned must be in the extra An instruction in which 8-bit or 16-bit
segment and pointed by DI. CX contains operand (data) is specified in the instruction,
counter and DF may be 0 or 1. then the addressing mode of such instruction
When the match is found in the string is known as
execution stops and ZF=1 otherwise Immediate addressing mode.
ZF=0. Example:
Example MOV AX,67D3H
LEA DI, destination 2. Register addressing mode
MOV Al, 0DH An instruction in which an operand (data) is
MOV CX, 80H specified in general purpose registers, then
CLD the addressing mode is known as register
REPNE SCASB addressing mode.
5] LODS/LODSB/LODSW: Example: MOV AX,CX
Load String byte into AL or Load String word 3. Direct addressing mode
into AX. An instruction in which 16 bit effective address
Syntax: of an operand is specified in the instruction,
LODS/LODSB/LODSW then the addressing mode of such instruction
Operation: AL/AX < ----- DS: [SI] is known as direct addressing mode.
It copies a byte or word from string pointed Example: MOV CL,[2000H]
by SI in data segment into AL or AX.CX 4. Register Indirect addressing mode
may contain the counter and DF may be either An instruction in which address of an operand
0 or 1 is specified in pointer register or in index
Example register or in BX, then the addressing mode is
LEA SI, destination known as register indirect addressing mode.
CLD Example: MOV AX, [BX]
LODSB 5. Indexed addressing mode
6] STOS/STOSB/STOSW (Store Byte or An instruction in which the offset address of
Word in AL/AX) an operand is stored in index registers (SI or
Syntax STOS/STOSB/STOSW DI) then the addressing mode of such
Operation: ES:[DI] < ----- AL/AX instruction is known as indexed addressing
It copies a byte or word from AL or AX to a mode.
memory location pointed by DI DS is the default segment for SI and DI.
in extra segment For string instructions DS and ES are the
default segments for SI and DI resp. this is a
special case of register indirect addressing
mode.

Page 3 of 6
Program: Computer Engineering
Microprocessors (22415)

Example: RCR AL, CL1


MOV AX,[SI] Or
6. Based Indexed addressing mode: MOV CL, 04H
An instruction in which the address of an ROR AX, CL
operand is obtained by adding the content of ii) MOV BL,04h
base register (BX or BP) to the content of an MUL BL
index register (SI or (DI) The default segment iii) IDIV BL
register may be DS or ES Example:MOV AX, iv) MOV BX,2000h
[BX][SI] v) INC AX
7. Register relative addressing mode: An vi) CMP AX,BX
instruction in which the address
of the operand is obtained by adding the 7. Differentiate between following
displacement (8-bit or 16 bit) with the instruction.
contents of base registers or index registers i) AAA,AAM
(BX, BP, SI, DI). The default segment register is ii) POP,POPF
DS or ES. Example: MOV AX, 50H[BX] iii) LDS,LES
8. Relative Based Indexed addressing mode iv) ROL,RCL
An instruction in which the address of the
operand is obtained by adding the AAA AAM
displacement (8 bit or 16 bit) with the base ASCII Adjust after ASCII Adjust after
registers (BX or BP) and index Registers (SI or Addition Multiplication
DI) to the default segment. AAM is used adjust AAM is used adjust
Example: MOV AX, 50H [BX][SI] the addition the product to
to two unpacked BCD two unpacked BCD
6. Select assembly language for each of the numbers numbers
following .
i) rotate register AL right 4 times POP POPF
ii) multiply AL by 04H Copies word from the Copies word from the
iii) Signed division of AX by BL stack pointed by the stack to the flag
iv) Move 2000h in BX register stack pointer to the register
v) increment the counter of AX by 1 destination
vi) compare AX with BX Ex: POP CX Ex: LES CX,[391AH]

i) MOV CL, 04H


RCL AL, CL1 LDS LES
Or Load register and DS Load register and ES
MOV CL, 04H with words from with words
ROL AL, CL memory location from memory
Or location
MOV CL, 04H LDS register, memory LES register, memory

Page 4 of 6
Program: Computer Engineering
Microprocessors (22415)

address of the first address of the first Syntax: RCR destination, count
word word Eg:
RCR BL, 1; Rotate all bits in BL right by 1 bit,
copy LSB to CF and CF
ROL RCL

Rotate left byte or Rotate through carry 9.Differentiate RCL and RCR instructions
word left byte or on the basis of
word (i) Syntax
Syntax: ROL Syntax: RCL (ii) Operation
Destination, Count Destination, Count (iii) Example
Can be used to Swap (iv) Status of carry flag
the nibbles Cannot be
used to swap the
nibbles

8.Explain any four rotation instructions


with example

ROL Rotate bits of byte or word left, MSB to


LSB and to CF
Syntax: ROL destination, count
Eg: ROL BL, 2 ; Rotate all bits in BL left by 1
bit ,copy MSB to LSB and to CF IF BL =
11110000 After Execution 11000011, CF= 1
ROR Rotate bits of byte or word right, LSB to
MSB and to CF Syntax: ROR destination,
countEg: ROR BL, 2 ; Rotate all bits in BL right
by 1 bit ,copy LSB to MSB and to CF
IF BL = 11110000
After Execution 00111100, CF= 0
3. RCL Rotate bits of byte or word left, MSB to
CF and CF to LSB.
Syntax: RCL destination, count
Eg: RCL BL, 2 ; Rotate all bits in BL left by 1 bit
,copy MSB to CF and CF to
LSB IF BL = 11110000, CF=0
After Execution 11000001 , CF= 1
4. RCR Rotate bits of byte or word right, LSB
to CF and CF to MSB.

Page 5 of 6
Program: Computer Engineering
Microprocessors (22415)

Page 6 of 6

You might also like