Docsity

8086/8088 Addressing Modes, Instruction Set & Machine Codes - Prof. Azad, Cheat Sheet of Electrical Engineering

Partial preview of the text

Download 8086/8088 Addressing Modes, Instruction Set & Machine Codes - Prof. Azad and more Cheat Sheet Electrical Engineering in PDF only on Docsity!

Week 3

8086/8088 Addressing Modes,

Instruction Set & Machine Codes

Addressing Modes

•^

When the 8088 executes an instruction, it performs the specified functionon data

-^

These data, called operands,^ –

May be a part of the instruction

-^

May reside in one of the internal registers of the microprocessor

-^

May be stored at an address in memory

•^

Register Addressing Mode^ –

MOV AX, BX

-^

MOV ES,AX

-^

MOV AL,BH

•^

Immediate Addressing Mode^ –

MOV AL,15h

-^

MOV AX,2550h

-^

MOV CX,

Register Indirect Addressing Mode

MOV AX,

BXDISI^ BEED

Example for Register Indirect Addressing •^

Assume that DS=1120, SI=2498 and AX=17FE show the memorylocations after the execution of:

MOV [SI],AX

DS (Shifted Left) + SI = 13698.With little endian convention:

Low address 13698

Æ

FE

High Address 13699

Æ

17

Indexed Relative Addressing Mode

MOV AH, [

] + 1234h SIDI

Example: What is the physical address MOV [DI-8],BL if DS=200 & DI=30h ?DS:200 shift left once 2000 + DI + -8 = 2028

Based-Indexed Relative Addressing Mode •^

Based Relative + Indexed Relative

-^

We must calculate the PA (physical address)

CSSS

BX

SI

8 bit displacement

PA=

DS

:^

BP

  • DI

16 bit displacement

ES

MOV AH,[BP+SI+29]

or

MOV AH,[SI+29+BP]

or

MOV AH,[SI][BP]+

The register order doesnot matter

Summary of the addressing modes

Addressing Mode

Operand

Default Segment

Register

Reg

None

Immediate

Data

None

Direct

[of

fset]

DS

Register Indirect

[BX][SI][DI]

DSDSDS

Based Relative

[BX]+disp [BP]+disp

DSSS

Indexed Relative

[DI]+disp[SI]+disp

DSDS

Based IndexedRelative

[BX][SI or DI]+disp [BP][SI or DI]+disp

DSSS

16 bit Segment Register Assignments Type ofMemoryReference

DefaultSegment

AlternateSegment

Offset

Instruction Fetch

CS

none

IP

StackOperations

SS

none

SP,BP

General Data

DS

CS,ES,SS

BX, address

String Source

DS

CS,ES,SS

SI, DI, address

StringDestination

ES

None

DI

Brey

Example for default segments •^

The following registers are used as offsets. Assuming that thedefault segment used to get the logical address, give the segmentregister associated?

a)

BP

b)DI

c)IP

d)SI,

e)SP, f) BX

-^

Show the contents of the related memory locations after theexecution of this instruction MOV [BP][SI]+10,DX if DS=2000, SS=3000,CS=1000,SI=4000,BP=7000,DX=1299 (allhex)

Assembly Language

-^

There is a one-to-one relationship between assembly and machinelanguage instructions

-^

What is found is that a compiled machine code implementation of aprogram written in a high-level language results in inefficient code^ –

More machine language instructions than an assembled version of anequivalent handwritten assembly language program

-^

Two key benefits of assembly language programming^ –

It takes up less memory

-^

It executes much faster

Converting Assembly Language Instructions to Machine Code

OPCODE

D

W

MOD

REG

R/M

-^

An instruction can be coded with 1 to 6 bytes

-^

Byte 1 contains three kinds of information:^ –

Opcode field (6 bits) specifies the operation such as add, subtract, or move

-^

Register Direction Bit (D bit)

-^

Tells the register operand in REG field in byte 2 is source or destination operand

-^

1:Data flow to the REG field from R/M

-^

0: Data flow from the REG field to the R/M

–^

Data Size Bit (W bit)

-^

Specifies whether the operation will be performed on 8-bit or 16-bit data

-^

0: 8 bits

-^

1: 16 bits

-^

Byte 2 has two fields:^ –

Mode field (MOD) – 2 bits

-^

Register field (REG) - 3 bits

-^

Register/memory field (R/M field) – 2 bits

Continued •^

REG field is used to identify the register for the first operand

REG

W = 0

W = 1

AL

AX

CL

CX

DL

DX

BL

BX

AH

SP

CH

BP

DH

SI

BH

DI

Examples

•^

MOV BL,AL

•^

Opcode for MOV = 100010

-^

We’ll encode AL so^ –

D = 0 (AL source operand)

•^

W bit = 0 (8-bits)

-^

MOD = 11 (register mode)

-^

REG = 000 (code for AL)

-^

R/M = 011

OPCODE

D

W

MOD

REG

R/M

100010

0

0

11

000

011

MOV BL,AL => 10001000 11000011 = 88 C3h ADD AX,[SI] => 00000011 00000100 = 03 04 h ADD [BX][DI] + 1234h, AX =>

00000001 10000001 __ __ h

=> 01 81 34 12 h

Software

-^

The sequence of commands used to tell a microcomputer what to do iscalled a

program

-^

Each command in a program is called an

instruction

-^

8088 understands and performs operations for

117 basic instructions

-^

The native language of the

IBM PC

is the machine language of the

-^

A program written in machine code is referred to as

machine code

-^

In 8088 assembly language, each of the operations is described byalphanumeric symbols instead of just 0s or 1s.

ADD AX, BX

Opcode

Source operand

Destination operand