Sie sind auf Seite 1von 30

Ganesh Iyer

http://ganeshniyer.com/

EE2007
Microprocessor systems
Tutorial 1 Semester 1 AY 2010-11

Ganesh Iyer
ganesh.vigneswara@gmail.com (facebook, gtalk)

http://ganeshniyer.com

Ganesh Iyer

http://ganeshniyer.com/

About Me
I have 3 years of Industry work experience in Bangalore, India.
I have finished my masters from NUS in 2008.
Currently doing PhD under the guidance of Assoc/Prof. Bharadwaj Veeravalli.
Research interests: Cloud computing, Game theory, Wireless Networks
Office: Computer Networks and Distributed Systems Lab, E4, Level 6, Room 12

Appointment: Details are available in my webpage: http://ganeshniyer.com


Interests: Kathakali, Teaching, Travelling, Photography

Ganesh Iyer

http://ganeshniyer.com/

Ganesh Iyer

http://ganeshniyer.com/

(1a) Typical CPU architecture Macro view.

Ganesh Iyer

http://ganeshniyer.com/

Introduction

Bus

Address bus Used to specify a physical address (memory and I/O)

Data bus Carries data between CPU/memory, 8086 is 16 bit


processor means data bus is 16 bit wide in 8086

Ganesh Iyer

http://ganeshniyer.com/

Introduction

Register

High speed storage area inside


CPU
All data must be kept in register
before processing
16 bit CPU means registers are
16-bit wide
e.g. 8086 16-bit CPU, each
register is 16 bit wide and each
CPU instruction can manipulate
16 bit data

Ganesh Iyer

http://ganeshniyer.com/

Introduction

Executing a high level program


High-level program
(e.g. C, C++, JAVA)

void main()
{
int a=10,b=20;
--}

Object code

Assembly code
(e.g. 8086, pentium)

Executable Binary
(0s and 1s)

MOV AX, 10
MOV BX,20
----01010100011
10011101010
----

Ganesh Iyer

http://ganeshniyer.com/

(2) Memory components

Ganesh Iyer

http://ganeshniyer.com/

(1b) Typical CPU architecture Micro view.

Ganesh Iyer

http://ganeshniyer.com/

(7) Instruction Execution

Fetching the instruction


Store in Instruction Queue
Decode the instruction
Execute the instruction

(3) Memory map of IBM PC

Vendors Firmware

ROM-BIOS

64+ kbytes

No installed memory
Video-ROM

Video Display Memory


Top of RAM (= 0x000A0000)

Volatile Program Memory

0x00007E00
0x00007C00
0x00000500
0x00000400
0x00000000

VRAM

128 kbytes

Extended BIOS Data

RAM

Different
Segments
(CS,DS,ES,
SS) are
created
here

BOOT_LOCN 512 bytes


RBDA
IVT

256 bytes
1024 bytes

1-MB

Ganesh Iyer

http://ganeshniyer.com/

(5,12,13) Registers
General Purpose Data Registers:
AX
BX
CX
DX

Accumulator, interrupt, general use;


Base addressing;
Counter; and
Data in I/O operations

Segment Registers:
CS Code segment : Program Instructions

Pointers and Index Registers:


SP Stack pointer : Current stack offset (SS)
BP Base pointer : Base for referencing values
stored on stack (SS)
SI Source index : General addressing, source
offset in string ops (DS)
DI Destination index : General addressing,
destination in string ops (ES)

SS Stack segment : Stack


DS Data segment : Data area
ES Extra segment : General addressing,
destination segment in string ops

AX 16 bit
AH 8 bits MSB
AL 8 bits LSB

Ganesh Iyer

http://ganeshniyer.com/

(4) Segments

Code Segment (CS): Program


instructions
Data Segment (DS): Data residing Area
Stack Segment (SS): Used as Stack
Extra Segment (ES): Special purposes,
usually with data in string
manipulations

1MB of space is divided evenly into 16 logical segments


(220 / 24 )= 216 = 26 . 210 = 64Kbytes => each segments length

Ganesh Iyer

http://ganeshniyer.com/

(9) How much memory can be active at a given time in


the 8088 microprocessor ?

4 x 64K
4 segments = CS, DS, SS, and ES each of size 64K

Ganesh Iyer

http://ganeshniyer.com/

(15) A data segment is to be located from address


A0000 to AFFFF; what value must be loaded into
DS ?

A000h

Ganesh Iyer

http://ganeshniyer.com/

(6) If CS = 1253H, what is the starting physical address of your


code/program? What will be loaded into the IP register prior to
the execution of the first instruction? Describe the function of IP
Starting Physical address = CS*10h+Offset
= 1253*10h+0000h
= 12530h
IP: 0000H (IP is the offset)
IP works on CS space by pointing to the instruction to be executed next;
After an instruction is fetched by the CPU, during the execution of the
current instruction, IP is incremented to point to the next instruction to be
executed.

Ganesh Iyer

http://ganeshniyer.com/

(10) If the current values in CS and IP are 0200 and 01AC


respectively, what is the address of the next instruction?

CS*10h+IP
= 0200h*10h+01ACh
= 02000+01AC = 021ACh

Ganesh Iyer

http://ganeshniyer.com/

(8) Show how the double word 12345678 will be


stored in memory starting at address A001.

A004

12

A003

34

A002

56

A001

78

Ganesh Iyer

http://ganeshniyer.com/

(14a) Flags in 8086

Ganesh Iyer

http://ganeshniyer.com/

(14b) How are status flags used by software ?

Use as decision to branch to other parts of the program


Eg: JC
JNZ

Jump Carry

jump if CF = 1

Jump No Zero

jump if ZF = 0

Ganesh Iyer

http://ganeshniyer.com/

(16 & 17) Addressing Modes in 8086 with MOV example

Ganesh Iyer

http://ganeshniyer.com/

(18) Load 1234H and 1200H in data registers and add


them. Store the result in the register DX, Also store the
result in a location whose offset is 1279H.
-----MOV AX, 1234H
MOV BX, 1200H
ADD AX,BX
MOV DX,AX
MOV [1279H],AX
------

Ganesh Iyer

http://ganeshniyer.com/

(11) What is stored at address FFFF0 and what is so


important about this address?

Reset Address

Reset Address - is a pre-set address that all processors will point to


each time the reset pin is active. There is a jump instruction
at this location (ROM BIOS CHIP) that will point to the
beginning of the ROM BIOS program.

Ganesh Iyer

http://ganeshniyer.com/

DUP operator
If you need to declare a large array you can use DUP operator. The syntax for DUP:

number DUP ( value(s) )


number - number of duplicate to make (any constant value).
value - expression that DUP will duplicate.
Data1 db 6 DUP(10h)
Fill 6 bytes with 10
Data2 db 10 DUP(?)
Reserve 10 bytes
Data4 db 3 DUP(00,01)
6 bytes of alternate 00,01

Ganesh Iyer

http://ganeshniyer.com/

BONUS!!!!
If the current values in CS and IP are 0200h and
01AEh respectively, what is the address of the
next instruction?

Address of next instruction = 10h*0200h + 01AEh = 021AEh where


10h* operation represents a left-shift of 1 hexadecimal digit
or a left-shift of 4 bits.
(16 in decimal = 10 in
hexa)

Ganesh Iyer

http://ganeshniyer.com/

BONUS!!!
The last stored items in the stack are the
following hexadecimal values: 08, FA, 14, 92, 5E,
38 (very last), etc. Assume SS=00E0h and
SP=01CBh. What is the physical address of the
location containing 38?

Item 38 is at the top of the stack since it is stored very last. The
physical address of top of the stack = SS: SP or 10h*SS + SP =
00E00 + 01CB = 00FCBh.

Ganesh Iyer

http://ganeshniyer.com/

BONUS!!!
The size of your memo.txt file on your 8088based PC is 365 bytes. Suppose this file is placed
at the memory address DS:SI = 1200:25FF, what
should be the address of last byte of this file?
The starting address of the file is 12000+25FF = 145FFh.
365 bytes in Hex is 16D bytes.
The last byte of this file should locate at
145FF + 16D 1 = 1476Bh.

Ganesh Iyer

http://ganeshniyer.com/

BONUS!!!
Which flag determines whether the address for a
string operation is incremented or decremented?
And which flag determines if interrupt to the
micro-processor is enabled?

Direction flag DF, and the interrupt flag IF

Ganesh Iyer

http://ganeshniyer.com/

BONUS!!!
What are the word sizes of the 8086/8088 and
the 80386?
16-bit and 32-bit, respectively.

Thank you!

http://ganeshniyer.com

Das könnte Ihnen auch gefallen