0% found this document useful (0 votes)
20 views13 pages

Microprocessors L2

Uploaded by

Ivy Walobwa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views13 pages

Microprocessors L2

Uploaded by

Ivy Walobwa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

INSTITUTE: DEDAN KIMATHI UNIVERSITY OF

TECHNOLOGY
COURSE: ELECTRICAL AND ELECTRONICS
ENGINEERING
DEPARTMENT: EEE
UNIT: MICROPROCESSORS
TASK: MICROPROCESSOR PROGRAMMING
DATE OF EXPERIMENT:04/04/2024
DATE OF SUBMISSION: 05/04/2024

GROUP MEMBERS
NAME REG. NO
IVY WALOBWA E021-01-2763/2020
ROBERT NDUNG’U E021-01-0995/2020
ROSE MAINA E021-01-0944/2020
RONAN ANGIRA E021-01-2437/2020
FIDELIS NJOROGE E021-01-0965/2020
AIMS AND OBJECTIVES

1. To understand the different types of programming languages.


2. To understand the types of addressing modes that is, immediate addressing
modes, register addressing mode and direct in memory addressing mode.
3. To gain familiarity with the microprocessor’s instructions.

INSTRUMENTS AND APPARATUS


 32-bit microprocessor development board
 Power supply unit
 Experimentation module mod. Z3/EV
 Module holder mod.MU/EV
 Individual management unit
THEORY
PROGRAMMING LANGUAGES
These are languages used for writing computer programs.

A computer program is a set of instructions or statements given to a computer to perform a certain job.
They guide the computer through orderly set of actions specified by computer programmers.

There are three levels of programming languages:

i. Low-level Languages (Machine Languages).


ii. Symbolic Languages (Assembly Languages).
iii. High-level Languages.

Low-Level Languages (Machine Languages):


Low-level languages (Machine languages) are the only languages that a computer can understand. These
instructions are written in the form of binary strings of 1’s and 0’s which can be immediately obeyed by
a computer without translation. In a strict sense, in a low-level language each instruction has a single
corresponding machine code equivalent.

Advantages of using machine language: it is fast in execution

Disadvantages:

 Difficult to learn as it requires detailed knowledge of hardware.


 It is tedious because one must determine the hex code for each instruction used.
 It is time consuming and prone to error.
 Machine language is computer dependent.
Symbolic Languages (Assembly Languages):
Assembly language is a set of instructions for a particular microprocessor.
It provides a direct correspondence between symbolic operation codes and machine language, for
which it is termed “Symbolic language”.
Like machine languages each microprocessor or microprocessor family has a different Assembly
language, because the design of the microprocessor influences the instructions it can execute.

Assembly language uses two-, three-, or four letters “mnemonics” to represent each instruction type.
The letters in mnemonics are usually initials or shortened forms of the English words for the operation
performed by the instruction, e.g., the mnemonics for subtract is SUB

Assembly language statements are usually written in standard form consisting of four fields.

Label field is the first in each Assembly language statement (i.e., the left-hand column of the statement)
and it is not essential to have an entry in this field for each instruction. Labels are followed by a colon (:).
An entry here is treated as a name, which can be used to identify the specific line of the program and
hence its memory address.
Usually labels are used as addresses within program control instructions (JUMP, BRANCH etc.) to cause
control to pass to an instruction bearing a specific label.

Op-code field contains the mnemonics for the instructions to be performed. Op-code is an acronym for
“Operation Code”.

The Operand field contains data, memory address (A binary numeric code given to a memory location in
order that location can be selected for reading or writing under program control), port address, or the
registers (special storage locations of the microprocessor concerned) on which operations are to be
performed. An instruction may contain zero, one, or two operands. The choice of the operand is usually
determined by the “Addressing Mode”. The addressing mode tells the Assembler where to find the data
in each operand e.g.,

PUSH AX; one register


MOV AX, BX; two registers
ADD BX, 1000H ; register, immediate value

The Comment field starts with a semicolon (;). Comments, annotation or narrative are written notes
which are included in the coding of a program in order to clarify operations but have no effect on the
program itself, i.e., are not translated into machine language.

High-Level Languages:
In contrast to a low-level language in a high-level language, each instruction has several corresponding
machine code instructions. These languages are very close to human languages, i.e.; these languages
provide more familiar notation rather than machine codes of the computer e.g., mathematical notation
in FORTRAN and English in COBOL etc.
Each language has its own rules (which govern the structure of the language statements) for writing
source programs/codes. These rules are called “Syntax” of the language.
Features which high-level languages have in common are the fact that they are “problem-oriented”
rather than “machine-oriented” and also myriad of compilers are available for converting the high-level
language programs into the machine codes of different types of computers.
Programs can be written faster in high-level languages than their counterparts (either low-level
languages or Assembly languages), because they work with larger building blocks.
However, these program always almost execute more slowly and require more memory than programs
written in their counterparts.
Unlike Assembly and machine languages high-level languages are designed to keep them as much
computer independent as possible.
A high-level language program is generally “portable”, i.e.; it may be executed on any computer with
some minor amendment to cater for any differences of configuration or idiosyncrasies of translators.

Some of the high-level languages include:

FORTRAN: is an acronym for FORmula TRANslation. It is a high-level language for scientific and
mathematical use; introduced in 1957.
COBOL: is an acronym for COmmon Business Oriented Language. It was developed in 1959.
It is primarily used for commercial applications that require precise and efficient manipulations of large
amount of data. Today more than half of all business software is still programmed in COBOL.

BASIC: is an abbreviation for Beginners All-purpose Symbolic Instruction Code. It was introduced in 1965
and originally designed for developing programs in “Conversational/Interactive Mode”, an on-line
programming environment (An operational method in which the user is in direct communication with
the computer and obtains immediate response to his/her input messages).
Because of its simplicity and comparative power it is used a lot on personal computers.

PASCAL: was named after Blaise Pascal (seventeenth century mathematician); introduced in 1971 as
derivative of ALGOL.

C: was introduced after the language B in 1972. It was developed for system programming.

C++: an extension of C was developed in the early 1980s. It provided the capabilities for “object-oriented
programming”. Today most operating systems are written in C and /or C++.

C and C++ are among the most powerful and most widely used high-level languages. Programs that
involve a lot of hardware such as robots and control systems or programs that must run quickly are
usually best written in low-level or Assembly languages. Complex data processing problems that
manipulate massive amount of data employ high- level languages. Now-a-days Assembly languages are
also interspersed with C/C++ and Pascal to perform machine control functions efficiently.

ADDRESSING MODES
These are the different modes used to access data.
Types of addressing modes;
i. Immediate addressing mode
An immediate addressing mode takes place when the data to be manipulated/ work on, is a
number n specified directly in the instruction.

Example;

MOV AX, 02FH; Charges in the AX the number 02FH

ii. Register addressing mode


A register-addressing mode is when a register of the microprocessor is the source of the
operation of the instruction.

Example;
MOV AX, BX; copies the register BX into register AX.
iii. Direct addressing mode into memory
It indicates the effective address as a number of 16-bit directly into the instruction.
Example;
MOV AX, [0421H]; charges in Ax the data to the site 0421
The square parentheses indicate that the contents of the memory locations have shifted
with respect to the base segment of 0421H bytes.
When the instruction is followed, the microprocessor executes the following operations:
a) Takes the present value of the register DS, for example 1234
b) Shifts it 4 bit to the left; 12340
c) Adds the value of the effective address; 0421
d) The result of the sum is; 12761 (this is the physical memory address of the 20 bit)
e) Takes the data to address 12761 and saves it in AL
f) Takes the data to address 12762 and saves it in AH

THE INSTRUCTIONS OF THE MICROPROCESSOR


Operations of a microprocessor correspond to its instructions.
1. Instructions of data transfer
MOV Copies a byte or word from a source to a
destination
PUSH Copies a word specified on the stack
POP Copies a word from the stack to the specified site
PUSHA Copies all the registers on the stack
POPA Copies from the stack to all the registers
XCHG Exchanges bytes or words
XLAT Transforms a byte in AL using a table in the
memory
IN Copies a byte or a word from the specified I/O
port to the accumulator
OUT Copies a byte or a word from the accumulator to
the specified I/O port
LEA Charges the effective address of an operation in
the specified register
LDS Charges the register DS and other specified
registers from the memory
LES Charges the register ES and other specified
registers from the memory
LAHF Charges AH with the least significant byte of the
flags register
SAHF Memorizes AH in the least significant byte of the
flags register
PUSHF Copies the flags register on the stack
POPF Copies a word from the stack to the flags register

2. Arithmetic instructions

ADD Sums the specified byte/word to a


byte/word

ADC Sums considering also the value of the


carry flag
INC Increments the byte or the specified
word in 1
AAA Adjusting ASCII after an addition
DAA Adjusting decimal after an addition
SUB Subtracts the specified byte/ word to a
byte/word
SBB Subtracts considering also the value of
the carry flag
DEC Decrements the byte or the specified
word in 1

NEG Calculates the complement to 2 of the


specified byte/word

CMP Compares two byte or two words


AAS Adjusting ASCII after a subtraction

DAS Adjusting decimal after a subtraction

MUL Multiplies bytes or words without sign


IMUL Multiplies bytes or words with sign

AAM Adjusting ASCII after the multiplication

DIV Divides a word without sign by a byte,


or a double word
without sign by a word

IDIV Divides a word with sign by a byte, or a


double word with
sign by a word

ADD Adjusting ASCII before the division


CWB Fills the superior byte of a word with
copies of the bit of
sign of the inferior byte

CWD fills the superior word of a double


word with the bit of
sign of the inferior word

3. Bit handling instructions

NOT Inverts each bit of a byte or of a


word
AND Follows an AND of each bit of
a byte or of a word with
the corresponding bit of a
byte or of a word

OR Follows an OR of each bit of a


byte or of a word with the
corresponding bit of a byte or
of a word
XOR Follows an XOR of each bit of
a byte or of a word with
the corresponding bit of a
byte or of a word
TEST Follows the same operations
of an AND, but doesn’t
change the value of the
operands

SHL/SAL Shifts to the left the bit of a


word or of a byte, puts 0 in
the MSB

SHR Shifts to the right the bit of a


word or of a byte, puts 0 in
the MSB

SAR Shifts to the right the bit of a


word or of a byte, puts the
old MSB in the new MSB

ROL Rotates to the left the bit of a


word or of a byte, puts the
MSB in LSF and CF
ROR Rotates to the right the bit of
a word or of a byte, LSB in
MSB and CF

RCL Rotates to the left the bit of a


word or of a byte, MSB in
CF and CF in LSB

RCR Rotates to the right the bit of


a word or of a byte, LSB in
CF and CF in MSB

4. Stringing instructions
A string is a series of bytes or words in sequential locations of the memory.
Normally a string is formed of ASCII characters.

REP Instruction prefix. Repeat the


following instruction until
CX = 0

REPE Instruction prefix. Repeat the


REPZ instruction until CX = 0 or
the zero flag ZF ≠1

REPNE Instruction prefix. Repeat the


REPNZ instruction until CX = 0 or
the zero flag ZF =1
MOVS Move byte or word from a
MOVSB string to another
MOVSW
COMPS Compares two byte strings or
COMPSB two word strings
COMPSW
INS Input from a port of a byte string or
INSB of a word
INSW
OUTS Output to a port of a string of byte
OUTSB or of words
OUTSW
SCAS Compares a string of byte
SCASB with a
SCASW byte in AL, or a string of words with
a word in AX
LODS Charges a byte of a string in
LODSB AL of a word of a string in
LODSW AX

STOS Memorizes a byte from AL or


STOSB a word from AX in a string
STOSW

5. Skipping instructions and call


6. Control instructions of the processor
Exercise on instruction of conditioned jump
Aim: to develop a program that simply waits for a well-defined time, and then returns the
control to the monitor of the system.
Procedure
1) All switches we set in the OFF position
2) The code below was then inserted and ran.
Data analysis

How much time goes by from the beginning of the program until the return
to the monitor?

1.5 seconds

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy