Microprocessor and
Assembly Language
Chapter-1: Introduction to
Microprocessors and Microcomputer
Systems
Prepared By
Ashebir K
Lecturer, Department of Computer Science
Jinka University(JKU)
1.1 Overview
Why study computer organization and
architecture?
– Design better programs, including system software
such as compilers, operating systems, and device
drivers.
– Optimize program behavior.
– Evaluate (benchmark) computer system performance.
– Understand time, space, and price tradeoffs.
2
1.1 Overview
• Computer organization
– Encompasses all physical aspects of computer systems.
– E.g., circuit design, control signals, memory types.
– How does a computer work?
• Computer architecture
– Logical aspects of system implementation as seen by the
programmer.
– E.g., instruction sets, instruction formats, data types,
addressing modes.
– How do I design a computer?
3
1.1 Overview
What is Microprocessor?
The term micro means extremely small and processor
means the thing that accelerates tasks.
So in general sense the term microprocessor means an
extremely small thing that can accelerate different tasks as
ordered. But the actual definition of microprocessor is
slightly different than this.
A microprocessor is a tiny electronic chip containing
transistors found inside a computer’s central processing
unit and other electronic devices. Its basic function is to
take input, process it and then provide appropriate output.
4
Microcomputer Systems
Overview
Introduction to the architecture of microcomputers
and IBM PC
Peripherals and their relations to the software or
Programs
What computer does while executing instructions
Advantages and disadvantages of assembly language
programming
**As a microcomputer user, you already know most of these terms
Components of
Microcomputer System
• SYSTEM UNIT
• I/O DEVICES OR PERIPHERALS
Keyboard
Display Unit
Disk drives
• INTEGRATED-CIRCUIT (IC)
Contains transistors. Digital circuits
[0’s& 1’s]
Binary Digits/ Bits: 0 or 1
Components (cont’d…)
• CPU:
Brain of the computers
Controls all the operations
A single chip processor (microprocessor)
• MEMORY CIRCUITS : Stores information
• I/O CIRCUITS : Communicate with I/O devices
The System Board
• System Board/motherboard resides in the system unit
• It contains microprocessors and memory circuits
• It has expansion slots to connect additional circuit
boards called add-in cards/add-in boards
• I/O circuits are located in add-in cards.
A Glimpse of Motherboard
Memory
Bytes and Words:
Information processed is stored in memory
A memory circuit element can store one bit of data [i.e.
0 or 1]
Memory circuits are organized as a group of 8 bits of
data
8 bits of string = 1 Byte
Memory bytes are known as address( i.e. street
address of a house).
Address Vs Contents
• Address of the first memory byte = 0
• The stored data in a memory byte are called
contents/value.
Address Contents
The address of a memory byte Contents are NOT unique as
is FIXED and different from they deal with current data.
other addresses( unique).
The number of bits in an Contents of memory byte are
address depend on the always 8 bits
processor
[ i.e. Intel 8086 = 20-bit &
Intel 80286=24-bit ]
Memory byte addressing
• Suppose a processor uses 20 bits for an address. How
many memory bytes can be addressed using this
processor?
A bit can have two possible values (i.e. 0 or 1)
So, in a 20-bit address, we can have 220 or
10,48,576
• In computer terminology 220 = 1 Mega
• Therefore, 20-bit address can be used to address 1 MB.
Memory Word
• In a Microcomputer, Two bytes = a word
• So to store a word data, IBM PC needs :
A pair of successive memory bytes
A pair of memory bytes = Memory word
• The lower address of the two memory bytes is the
memory address.
i.e. a memory word with address 2 is made up of
address 2 and 3
• A microprocessor can detect memory byte or memory
word from memory location/address.
Bit Positions in byte and
Word
• Bit positions are numbered from Right to left
• Bit 0-7 = low byte [ Lower address of word]
• Bit 8-15 = high byte [ Higher address of
word]
Memory Operations
• The processor can perform two operations on memory
Read or fetch the contents from a location
•Processor only gets a copy of the data
•Original contents of the location are unchanged
Write or Store data at a location
•The data written become the new contents
•The Original/previous contents are lost
RAM and ROM
• RAM: Random Access Memory
RAM locations can be read and written
Program instructions and data are stored
RAM memory are lost when the machine is
turned off
• ROM: Read Only Memory
Once initialized can’t be changed (Read Only)
Retain values unlike RAM [example]
ROM based programs are known as firmware
Responsible for loading start-up programs
BUSES
• A processor communicates with memory and I/O devices
by using signals.
• Signals are travelled along set of wires or connections
called buses.
• There are three kinds of signals and buses
Address & Address Buses
Data & Data Buses
Control & Control Buses
BUSES(cont’d…)
• Address Bus: The CPU places the address of memory
location on address bus to read the contents.
• Data Bus: CPU receives the data, sent by memory
circuits on the data bus.
• Control Bus: CPU sends control signals on control bus
perform read operation in memory.
CPU
• CPU is the brain of computer.
• CPU controls computer by executing programs (i.e.
system or application).
• Each instruction CPU executes, is a bit string.
• Machine language: The language of 0’s and 1’s
Instructions are designed to be simple
Sequence of very basic operations
• Instruction Set: The instructions performed by CPU.
The instructions set for each CPU is unique
Architecture Models
Von Neumann model Harvard
architecture
Any stored-program computer in Physically separate
which an instruction fetch and a storage and signal
data operation cannot occur pathways for
at the same time because they instructions and data.
share a common bus.
Intel 8086
Microprocessor
Organization
Execution Unit (EU)
•EU contains ALU circuits.
•ALU performs arithmetic and logical operations.
•Data operations are stored in registers.
•A register is like memory location, however, we refer to it by
name not number.
i.e. AX, BX, CX, DX, SI, DI, SP, BP
• Also, EU Contains temporary registers for holding
operands for the ALU and FLAGS registers.
•FLAG register’s individual bits reflect the result of
computation
Bus Interface Unit (BIU)
• BIU enables communication between the EU and
memory or I/O circuits.
• Primarily responsible for transmitting address, data and
control signals on the buses.
• BIU registers are: CS,DS, ES and IP
BIU registers hold the addresses of the memory
locations
EU and BIU
•EU and BIU are connected by internal bus and they
work together.
•While EU executes an Instruction, BIU fetches up to six
bytes of the next instruction and places instructions in
instruction queue (IQ).
•The overall process is called instruction prefetch and
it’s purpose is to speed up the processor.
•However, if EU needs to communicate with memory,
BIU suspends instruction prefetch and performs
required operations.
I/O Ports
• I/O ports functions as transfer points between the CPU
and I/O devices.
• I/O devices are connected through I/O ports
Serial Parallel
Transfers 1 bit at a time Transfers 8 or 16 bits at a time
Serial ports tend to be slowerRequires more wiring
connection
Slow devices are connected to Fast devices are connected to
serial port. (i.e. Keyboard) parallel port. (i.e. disk drive)
Instruction Execution
• How the CPU is operated?
• Machine language has two parts
Opcode: Type of operation
Operands: Data to be operated on (Memory addresses are
used)
• The fetch- execute cycle
• Fetch
Fetch an instruction from memory
Decode the instruction to determine the operation
Fetch data from memory if necessary
• Execute cycle
Perform operation on the data
Store the result if needed
Timing
• To ensure execution steps are carried out in an orderly fashion,
a clock circuit controls the processor by generating a train of
clock pulses
• Clock Period: The time interval between two pulses.
• Clock rate/speed: Number of Pulses per second.
Measured in Megahertz (MHz)
1 MHz = 1000000 (1 million) pulses per second
1.6 The Computer Level Hierarchy
• Computers consist of many things besides
chips.
• Before a computer can do anything worthwhile, it
must also use software.
• Writing complex programs requires a “divide and
conquer” approach, where each program
module solves a smaller problem.
• Complex computer systems employ a similar
technique through a series of virtual machine
layers.
30
1.6 The Computer Level Hierarchy
• Each virtual machine layer
is an abstraction of the
level below it.
• The machines at each
level execute their own
particular instructions,
calling upon machines at
lower levels to perform
tasks as required.
• Computer circuits
ultimately carry out the
work.
31
1.6 The Computer Level Hierarchy
• Level 6: The User Level
– Program execution and user interface level.
– The level with which we are most familiar.
• Level 5: High-Level Language Level
– The level with which we interact when we write
programs in languages such as C, Pascal, Lisp, and
Java.
32
1.6 The Computer Level Hierarchy
• Level 4: Assembly Language Level
– Acts upon assembly language produced from
Level 5, as well as instructions programmed
directly at this level.
• Level 3: System Software Level
– Controls executing processes on the system.
– Protects system resources.
– Assembly language instructions often pass
through Level 3 without modification.
33
1.6 The Computer Level Hierarchy
• Level 2: Machine Level
– Also known as the Instruction Set Architecture
(ISA) Level.
– Consists of instructions that are particular to the
architecture of the machine.
– Programs written in machine language need no
compilers, interpreters, or assemblers.
34
1.6 The Computer Level Hierarchy
• Level 1: Control Level
– A control unit decodes and executes instructions
and moves data through the system.
– Control units can be microprogrammed or
hardwired.
– A microprogram is a program written in a low-level
language that is implemented by the hardware.
– Hardwired control units consist of hardware that
directly executes machine instructions.
35
1.6 The Computer Level Hierarchy
• Level 0: Digital Logic Level
– This level is where we find digital circuits (the
chips).
– Digital circuits consist of gates and wires.
– These components implement the mathematical
logic of all other levels.
36
1.7 The von Neumann Model
• On the ENIAC, all
programming
was done at the
digital logic level.
• Programming the
computer
involved moving
plugs and wires.
37
Programming Languages
• Machine Language: Bit strings (i.e. 0 & 1)
• Assembly language:
Symbolic names are used to represent operations, registers and
memory locations(i.e. MOV AX, A)
Assembly program must be converted into machine language using
assembler.
• High-Level language:
Allows programmer to write program in more natural language text.
A Compiler is needed to translate high-level programs into machine
language
Example of Languages
Advantages
High-level Assembly
• So close to the machine
• Closer to natural language. language. So programs are
So, algorithm conversion in faster and shorter.
easier.
• Reading or writing to specific
• Less instruction and time memory location, I/O ports is
required than assembly easy.
language.
• It can be a sub program of a
• Programs can be executed in high-level language.
any machine
• Going into more details like
how computer thinks.
Adding Two numbers
.MODEL SMALL ; Size of the program
.STACK 100H ; Stack segment [ Temporary storage of addresses]
.DATA ; Define data
A DW 2 ; initialize variables [A=2]
B DW 5
SUM DW ? ; Uninitialized values
.CODE ; Code segments
MAIN PROC ; main procedure starts
MOV AX,@DATA ; initialize DS
MOV DS, AX
; add numbers
MOV AX,A ; instruction. AX has A
ADD AX,B ; AX has A+B
MOV SUM, AX ; SUM = A+B
; exit to DOS
MOV AX, 4CH
INT 21H
MAIN ENDP
ENDP MAIN