You are on page 1of 55

COMP 231

Microprocessor and
Assembly Language

Course description
General study of both hardware and
software included in the
microcomputer systems.
Intel 8085/8086/8088, and its
associated supporting devices and
software.
Assembly programming language.

Objectives
Introduction to different types of
microprocessors and their
applications.
Different hardware/software that is
supported by microprocessors.
Assembly language programming
and their applications.

Internal evaluation

Lab report: 7
Quiz 1: 3
Quiz 2: 3
Quiz 3: 3
Quiz 4: 3
Assignment 1: 2
Assignment 2: 2

Internal examination 1: 7
Internal examination 2: 7
Lab exam: 5
Viva: 5
Class discipline: 3
Total: 50 marks

Your responsibilities
Understand the lecture slides and do
assignments
Uphold academic honesty in
completing your assignments,
projects, and exams.

Plagiarism, cheating, and other forms


of academic dishonesty will not be
tolerated.
Discipline in the class is counted for
your grading.

Lab assignments in each week


Quiz will be held at the end of each
two chapter.
No written assignment solutions
or lab report will be accepted
late (extreme emergencies will be
dealt with on a case by case basis).
80% attendance

Text book
1. John Uffenbeck, The 80x86 Family
design, programming and Interfacing.
2. Microprocessor Architecture,
Programming, and Application with the
8085- Ramesh Gaonkar.
3. Microprocessor Systems: The
8086/8088 Family architecture,
Programming, and Design - Yu-cheng
Liu, Glenn A. Gibson.

Syllabus
1. Introduction and history of
Microprocessors
2. Basic block diagram of a microcomputer,
Stored program computer (Von Neumann
Architecture) and related terminologies,
Bus system architecture.
3. Introduction of 8085 microprocessor and
its Functional Block Diagram and pin
configuration, 8085 Programming Model.

4. Timing and control unit, Registers,


data and Address Bus, Instructions,
operation code and operands,
Addressing Modes, Interrupts.
5. 8086/8088 CPU architecture &
operation, Programming model, Pins &
signals, Memory
segmentation, Processor bus cycle
(Timing diagram),

6. Assembly instruction format


Instruction types, simple sequence
programs.
7. Stacks and sub Routines
8. Instruction Cycle, Fetch Operation
and
timing diagram Execution Operation
and timing Diagram, Machine cycle
and states.

9. Operating modes. Support chips for


8086/8088 : 8288 bus controller, 8284
clock generator.
10. Latches 8282, Bus transceiver
8286 of
Connections, Instruction set &
programming.
11. Basic I/O and Memory R/W,
Addressing Modes.

12. Interrupt types, Interrupt


processing
sequence, Interrupt controller 8259.
13. Communication Interfaces (serial
and Parallel 8254 programmable
interval timer.
14. DMA operation, DMA controller

Introduction and history of Microprocessors

Development of computer
Computer is the most efficient and
versatile electronic machine is a
development of a calculator.
The development & enhancement in
the calculator leads to the
development of computer.

First mechanical computer named


Difference engine and Analytical
engine.
The Difference engine could
perform the arithmetic operations
like add & subtract.
But it could run only single algorithm
and output system was incompatible.

The Analytical engine provided


more advanced features.
Four components:
1. The store (memory)
2. The mill (Computation unit)
3. Input Section
4. Output Section

Store: hold the variables and results.


Mill: accepts operands from the
store, add, subtract, multiply or
divide and return a result back to the
store.
- Reads the instruction and data
- Fetches the data from the store
- Write the data to punched card

First Gen(1940-56)

Vacuum tubes
First general purpose electronic
digital computer was ENIAC
(Electronic Numerical Integrator And
Calculator).
Enormous in size and consumed very
high power.
Faster than mechanical computer

ENIAC was a decimal machine


Memory consisted of 20
accumulator each capable of
holding 10 digit decimal numbers.
Programmed manually

Second Gen(1956-63)
Transistors
Transistors replaced Vacuum tubes
Smaller, faster, cheaper, energy
efficient and reliable computers.
But generated more heat
Moved from binary machine to
symbolic or assembly language.
Fortran COBOL were also being
developed.

Third Gen(1964-71)
Development of integrated circuit
Transistors were placed on silicon
chips.
Drastically increased the speed and
efficiency.
Users interacts with keyboards and
monitors with user interactive OS.

Fourth Gen (1971-present)


Microprocessor (P) was developed
Thousand of IC on a single silicon
chips.
Intel 4004 was first 4 bit P (1971).
Intel 4004 was followed by 8-bit P
8008 (1972)
8080 was introduced. 8-bit P (1973)

Motorola introduced the 8-bit 6800


processor (1974)
Intel developed 8085, 8086, 80186,
80286, 80386, 80486 and Pentium
Motorola produced 6802, 68000, etc.
Home user computer in 1981 by IBM
P. Apple introduced Macintosh in
1984.

Fifth Gen (present onwards)

Will be based on AI, in development


phase.
Voice recognition developed already.
Parallel processing grid computing
are in practice today.
Will be used on Quantum
computation, molecular and nano
technology, natural language
processing for IO.

Calculator
Data processing device that carries
out logic and arithmetic operations.
Accepts data from a small keyboard,
performs the arithmetic and logical
calculation and show the result on
LCD or LED.
Programs are stored in ROM, data
stored in RAM.

Features
Interface easily with keyboards and
displays.
Handle decimal digits as units.
Execute the standard program stored in
ROM
Mathematical functions
Low cost, small size and low power
consumption.

Von-Neumann Architecture
Known as stored program
concept and was developed by
John Von Neumann.
Computer could get instruction by
reading them from memory and a
program could be set or altered by
setting the values of a portion of
memory.

Uses a single memory to hold both


the instruction and data.
Such machines are also known as
stored program computer.
ALU is capable of performing
arithmetic and logical operations on
binary data.

The memory of the Neumanns


machine consists of 1000 storage
location called words, each capable
of storing 40 bits.
Each number is represented by sign
bit and 39-bit value.
Control unit provides the timing and
control signals to all the operations.

The storage location of the control unit and


ALU are called register.
1. MAR (Memory Address Register):
located in the CPU, connected to the address
lines. Specifies the address in memory.
2. MBR (Memory Buffer Register):
Located in the CPU, connected to the data
lines. Acts as an interface between the CPU
and memory.

IR (Instruction Register): When


the instruction is fetched from the
memory, it is loaded in the instruction
register.
Program Control: Contains the
address of next byte to be fetched
from the memory. The main purpose
is to sequence the execution of the
program.

The contents of the program counter


are copied to the memory address
register before an instruction is
fetched from memory.
When the instruction is fetched, the
control unit updates the program
counter to point to the next
instruction which is to be fetched.

The Accumulator (AC) and the


Multiplier-Quotient (MQ) are
employed to temporarily hold the
operands and result of ALU
operations.
E.g., the result of multiplying the two
40-bit numbers is 80-bit number, the
most significant 40 bit are stored in
AC and the least significant in MQ.

Harvard Architecture

Consists of separate memory for


program and data. Each memory has
its own address and data buses.
Both the instruction and data can be
fetched from memory concurrently.

Consists of separate data and address


buses for program and data memory.
Hence it requires separate block of RAM
chip.
The data memory address bus carries
the memory address of data whereas
program memory address bus carries
the memory address of the instruction.

Similarly, program memory data bus


carries the instruction and data
memory data bus carries the data
required to perform the operations.

Microprocessor
A P is a programmable, clock driven
electronic device, designed with
registers, flip-flops & timing elements
that reads binary instruction from a
storage device called memory,
accept binary data as input and
process data according to those
instruction and provide the results as
output.

It has a set of instructions, designed


to manipulate data and
communicate.
It can be programmed to perform
specific task by selecting necessary
instruction from its set.
It reads one instruction at a time,
matches it with instruction set and
performs the data manipulation as
indicated by the instruction.

Thus P can fetch instruction from


memory, decode and execute them,
perform arithmetic and logical
operations, accept data from input
and send results to the output
device.
The CPU of computer consists of an
ALU, CU and memory.

If all these components can be


organized on a single silicon chip by
means of LSI, VLSI technology, then
such structure is called P.
So the microprocessor is CPU in a
single chip.

Introduction to Assembly
Language
Programming

Overview of Assembly Language


Advantages:
Faster as compared to programs written using high-level languages
Efficient memory usage
Control down to bit level

Disadvantages:
Need to know detail hardware implementation
Not portable
Slow to development and difficult to debug

Basic components in assembly Language:


Instruction, Directive, Label, and Comment

Example of Assembly Language


Program
;NUMOFF.ASM: Turn NUM-LOCK indicator off.

Comments

.MODEL SMALL
.STACK
Assembly directive

.CODE
.STARTUP
MOV
D1: MOV
0040H
MOV
AND
LOCK bit
.EXIT
END
Label

AX,40H

;set AX to 0040H

DS,AX

;load data segment with

SI,17H

;load SI with 0017H

Instructions

BYTE PTR [SI],0DFH ;clear NUMAssembly directive

Instruction Format
General Format of Instructions
Label:

Opcode

Operands

; Comment

Label: It provides a symbolic address that can be used in branch instructions

Opcode: It specifies the type of instructions

Operands: Instructions of 80x86 family can have one, two, or zero operand

Comments: Only for programmers reference

Machine Code Format


Opcode

MOV AL, BL

Mode Operand1Operand2
1000100011000011
MOV

Register
mode

Assembler Directives
Source File
DATA

List File

SEGMENT PARA 'DATA


ORG
SUM

16 DUP(?)

DB

ENDS

CODE

ORG

ASSUME CS:CODE, DS:DATA


ORG

AX,7000H

7000H
POINTS DB

7010

SUM

0000

00

DATA
CODE

DB

SEGMENT PARA 'CODE'

ORG

8000H

8000 B8 7000 TOTAL: MOV

DS,AX

MOV

AL,0

8003 8E D8

MOV

DS,AX

8005 B0 00

MOV

AL,0

END TOTAL

ENDS

MOV

CODE ENDS

16 DUP(?)

ASSUME CS:CODE, DS:DATA

8000H
MOV

SEGMENT PARA 'DATA

7000 0010 [00]


7011

SEGMENT PARA 'CODE

TOTAL:

DATA

7000H

POINTS DB
DATA

0000

AX,7000H

Assembler Directives
SEGMENT directive
ENDS directive
END directive
ORG directive
DB: Define Byte; DW, .
ASSUME directive

Specifies the segment register (segment Register) that will be used to calculate the effective
addresses for all labels and variables defined under a given segment or group name (segment Name

f CS = 1230H and DS = 5678H, what are the physical memory addresses of


abel TOTAL and variable SUM?

Assembler Directives
Simplified Segment Directives

Predefined .Mode Types

.MODEL SMALL
DATA
SEGMENT

CODE
SEGMENT

TINY

one

one

SMALL

one

one

MEDIUM

one

multiple

COMPACT

multiple

one

LARGE

multiple

multiple

HUGE

multiple

multiple

FLAT*

one

one

.DATA
ORG

7000H

POINTS DB
SUM

DB

16 DUP(?)
?

.CODE
ORG
TOTAL:

8000H
MOV

AX,7000H

MOV

DS,AX

MOV

AL,0

RET
END

TOTAL

* Flat is used for 32-bit addressing

Build Executable Programs


library
Source files

Linker

Assembler
Syntax check
Translate source
files into

OBJ
files

machine code
OBJ
files

Executable
files

Question: What is the difference between *.com and *.exe files?


http://www.faqs.org/faqs/msdos-programmer-faq/part2/section-9.html
Assemblers

Microsoft ML, LINK, & DEBUG


8086 Emulator
A86
MASM32 package

Microsoft MASM and Debug


Microsoft MASM and Link Programs
ML /c /Fl

numoff.asm

Link numoff

Syntax check;
Translate assembly instructions into machine codes

Build the executable file

Microsoft Debug Program


C:\> debug
-a
0BDF:0100 MOV AX, 40
0BDF:0103
-t
AX = 0040 BX = 0000 CX = 0000 DX = 0000 SP = .
..
-q

8086/8088 Assembler and Emulator

Difference Between EXE and


Binary
Files
Source File
List File
.model small
.data
org 0010H
Var1 DB 12H
.code
MOV AX, 0000
MOV DS, AX
label1: MOV AL, DS:[0100H]
JMP label1
end

0000
0200
0000
0000
0003
0005
0008

.model small
.data
org 0200H
12
Var1 DB 12H
.code
B8 0000 MOV AX, 0000
8E D8
MOV DS, AX
A0 0100 label1: MOV AL, DS:[0100H]
EB FB
JMP label1
end

7-54

Difference Between EXE and


Binary Files
EXE file

Binary file

You might also like