0% found this document useful (0 votes)
113 views62 pages

COMP 231 Microprocessor and Assembly Language

Uploaded by

Aarush Timalsina
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)
113 views62 pages

COMP 231 Microprocessor and Assembly Language

Uploaded by

Aarush Timalsina
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/ 62

COMP 231

Microprocessor and Assembly


Language
Dr. Gajendra Sharma
Associate Professor
Department of Computer Science and
Engineering

[email protected]
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
• First Internal: 10
• Second Internal: 10
• MCQ: 10
• Assignment: 15
• Mini Project: 5

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.
• Class discipline
• Mobile Switch OFF
• No written assignment solutions or reports
will be accepted late (extreme emergencies
will be dealt with on a case by case basis).
• 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
Chapter 1: Introduction and history of
Microprocessors, Basic block diagram of a
microcomputer, Stored program computer (Von
Neumann Architecture) and related
terminologies, Bus system architecture.
Chapter 2: Introduction of 8085 microprocessor
and its Functional Block Diagram and pin
configuration, 8085 Programming Model.
Timing and control unit, Registers, data and
Address Bus, Instructions, operation code and
operands, Addressing Modes, Interrupts.
Chapter 3: 8086/8088 CPU architecture &
operation, Programming model, Pins & signals,
Memory segmentation, Processor bus cycle
(Timing diagram),
Assembly instruction format Instruction types,
simple sequence programs.
Chapter 4: Stacks and sub Routines
Instruction Cycle, Fetch Operation and
timing diagram Execution Operation and timing
Diagram, Machine cycle and states.
Chapter 5: Operating modes. Support chips for
8086/8088 : 8288 bus controller, 8284 clock
generator, Latches 8282, Bus transceiver 8286 of
Connections, Instruction set & programming,
Basic I/O and Memory R/W, Addressing Modes.
Chapter 6: Interrupt types, Interrupt processing
sequence, Interrupt controller 8259.
Chapter 7: Communication Interfaces (serial and
Parallel 8254 programmable interval timer.
Chapter 8: DMA operation, DMA controller
Mini Project
• Form groups of six people and choose any one of the
Following tasks as a mini-project for the course.
• No more than two groups may work on the same task.
Each group is supposed to develop a visual
demonstration of the solution.
• The submission of the Project would include a report
containing the codes of the implementation,
documentation on the code, Relevant screenshots of the
demo application.

.
Mini Project Task
1. Store the data byte 32H into memory location
4000H.
2. Write a program to shift an eight bit data four
bits right. Assume data is in register C.
3. Add the contents of memory locations
4000H and 4001H and place the result in
memory location 4002H. Also write program
description.
4. Find the square of the given numbers from
memory location 6800H and store the result from
memory location 8000H.
5. Search the given byte in the list of 50 numbers
stored in the consecutive memory locations and
store the address of memory location in the
memory locations 2800H and 2801H. Assume
byte is in the C register and starting address of
the list is 2500H. If byte is not found store 00 at
2800H and 2801H.
6. Write an assembly language program to
separate even numbers from the given list of
50 numbers and store them in the another list
starting from 2200H. Assume starting address
of 50 number list is 2100H.
7. Write a program to shift a 16 bit data, 1 bit
right. Assume that data is in BC register pair.
8. Write a program to find smallest of two 8-bit
numbers.
9. Write a program to subtract two 16 bit
numbers with Borrow.
10. Write a program to add Two 16 bit numbers
with carry.
• Mini-Project selection deadline: April 25, 2019
• Mini-Project submission deadline: July 10,
2019
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 Electronic Numerical Integrator
and Calculator (ENIAC).
• 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 (IC)
• 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 or MP) 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.
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 Neumann’s 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. Memory Address Register (MAR): located in
the CPU, connected to the address lines.
Specifies the address in memory.
2. Memory Buffer Register (MBR): Located in
the CPU, connected to the data lines. Acts as an
interface between the CPU and memory.
• Instruction Register (IR ): When the
instruction is fetched from the memory, it is
loaded in the instruction register.
• Program Control (PC): 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 AX,40H ;set AX to 0040H
D1: MOV DS,AX ;load data segment with 0040H Instructions
MOV SI,17H ;load SI with 0017H
AND BYTE PTR [SI],0DFH ;clear NUM-LOCK bit
.EXIT
Assembly directive
END

Label
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 Mode Operand1 Operand2

MOV AL, BL 1000100011000011


Register
MOV
mode
Assembler Directives
❑ Source File ❑ List File

0000 DATA SEGMENT PARA 'DATA’


DATA SEGMENT PARA 'DATA‘
ORG 7000H ORG 7000H
POINTS DB 16 DUP(?) 7000 0010 [00] POINTS DB 16 DUP(?)
SUM DB ? 7010 00 SUM DB ?
DATA ENDS 7011 DATA ENDS

CODE SEGMENT PARA 'CODE‘


0000 CODE SEGMENT PARA 'CODE'
ASSUME CS:CODE, DS:DATA
ASSUME CS:CODE, DS:DATA
ORG 8000H
ORG 8000H
TOTAL: MOV AX,7000H
8000 B8 7000 TOTAL: MOV AX,7000H
MOV DS,AX
MOV AL,0 8003 8E D8 MOV DS,AX
••••••••• 8005 B0 00 MOV AL,0
CODE ENDS •••••••••
END TOTAL
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).

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


label TOTAL and variable SUM?
Assembler Directives
❑ Simplified Segment Directives ❑ Predefined .Mode Types
.MODEL SMALL
.DATA DATA CODE
SEGMENT SEGMENT
ORG 7000H
TINY one one
POINTS DB 16 DUP(?)
SMALL one one
SUM DB ?
MEDIUM one multiple

.CODE COMPACT multiple one


LARGE multiple multiple
ORG 8000H
TOTAL: MOV AX,7000H HUGE multiple multiple

MOV DS,AX FLAT* one one


MOV AL,0
* Flat is used for 32-bit addressing
•••••••••
RET
END TOTAL
Build Executable Programs

library
Assembler Linker
Source files
Syntax check OBJ
Translate source files
files into
machine code Executable
OBJ files
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

Syntax check;
ML /c /Fl numoff.asm Translate assembly instructions into machine codes

Link numoff 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 .model small


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

7-61
Difference Between EXE and Binary Files
❑ EXE file

❑ Binary file

You might also like