Microprocessors L2
Microprocessors L2
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
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.
Disadvantages:
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.,
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.
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;
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
2. Arithmetic instructions
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.
How much time goes by from the beginning of the program until the return
to the monitor?
1.5 seconds