You are on page 1of 16

Assignment No.

CPE15 – Microprocessor System

Instruction: Research on the topic:

Functional Operations of Microprocessors/Microcontroller

A. Data Movement

The microprocessor follows Fetch-Decode-Execute cycle wherein the

instructions are initially stored in the memory in a sequential order. The

microprocessor fetches those instructions from the memory, then decodes it and

executes those instructions till STOP instruction is reached. Later, it sends the

result in binary to the output port. Between these processes, the register stores

the temporarily data and ALU performs the computing functions.

Data movement instructions move data from one place, called the source

operand, to another place, called the destination operand. The following are

different types of data movement instructions:


 MOV: The function of MOV instruction is to transfer a byte or word of

data from a source location to a destination location. The general form

of MOV instruction is as shown below:

Mnemonic meaning Format Operation Flags affected

MOV move MOV D,S (S)→(D) None

We see that data can be moved between general purpose-registers,

between a general purpose-register and a segment register, between a

general purpose-register or segment register and memory, or between

a memory location and the accumulator. Note that memory-to-memory

transfers are not allowed.

 PUSH/POP: The PUSH and POP instructions are important

instructions that store and retrieve data from the LIFO (Last In First

Out) stack memory. The general forms of PUSH and POP instructions

are as shown below:

Mnem. Meaning Format Operation Flags affected

PUSH Push word PUSH S ((Sp))←(S) None

onto stack (Sp)←(Sp)-2

POP Pop word POP D (D)←((SP)) None

onto stack (Sp)←(SP)+2


a) POPF Instruction – This instruction copies a word from the two

memory location at the top of the stack to flag register and

increments the stack pointer by 2.

b) PUSH Instruction – PUSH instruction decrements the stack

pointer by 2 and copies a word from a specified source to the

location in the stack segment where the stack pointer pointes.

Example:

PUSH BX  ;Decrement SP by 2 and copy BX to stack

PUSH DS ;Decrement SP by 2 and copy DS to stack

PUSH TABLE[BX] ;Decrement SP by 2 and copy word from

memory in DS at

EA = TABLE + [BX] to stack.

c) POP Instruction – POP instruction copies the word at the current

top of the stack to the operand specified by op then increments the

stack pointer to point to the next stack.

Example:

POP DX ;Copy a word from top of the stack to DX and increments

SP by 2.

POP DS ; Copy a word from top of the stack to DS and increments

SP by 2.

POP TABLE [BX] ;Copy a word from top of stack to memory in DS

with

EA = TABLE + [BX].
 LEA, LDS, and LES (load-effective address)

INSTRUCTIONS: These instructions load a segment and general

purpose registers with an address directly from memory. The general

forms of these instructions are as shown below:

The LEA instruction is used to load a specified register with a 16- bit

effective address (EA)

Example:

LEA BX, PRICE             ;Load BX with offset of PRICE in DS

LEA BP, SS:STACK       ;Load BP with offset of STACK in SS

LEA CX, [BX][DI]          ;Load CX with EA=BX + DI

The LDA instruction is used to load a specified register with the

contents of PA and PA+1 memory locations, and load DS with the

contents of PA+2 and PA+3 memory locations.

LDS reg,mem        [reg] <-- [mem] 

                                 [DS] <-- [mem +2]

The LES instruction is used to load a specified register with the

contents of PA and PA+1 memory locations, and load ES with the

contents of PA+2 and PA+3 memory locations.

LES reg,mem        [reg]<--[mem]

                              [ES]<--[mem+2]

 MISCELLANEOUS DATA TRANSFER INSTRUCTIONS:


a) XCHG: The XCHG (exchange) instruction exchanges the contents

of a register with the contents of any other register or memory.

b) XLAT: This instruction used to simplify implementation of the

lookup table operation. The general form of this instruction is as

shown below:

XLAT     [AL] -->[AL]+BX

 LAHF and SAHF: The LAHF and SAHF instructions are seldom used

because they were designed as bridge instructions. These instructions

allowed 8085 microprocessor software to be translated into 8086

software by a translation program.

LAHF instruction copies the value of SF, ZF, AF, PF, CF, into

bits of 7, 6, 4, 2, 0 respectively of AH register. This LAHF instruction

was provided to make conversion of assembly language programs

written for 8080 and 8085 to 8086 easier.

SAHF Instruction - SAHF copies the value of bits 7, 6, 4, 2, 0 of

the AH register into the SF, ZF, AF, PF, and CF respectively. This

instruction was provided to make easier conversion of assembly

language program written for 8080 and 8085 to 8086.

 IN and OUT: There are two different forms of IN and OUT instructions:

the direct I/O instructions and variable I/O instructions. Either of these

two types of instructions can be used to transfer a byte or a word of


data. All data transfers take place between an I/O device and the

MPU’s accumulator register. The general form of this instruction is as

shown below:

 String manipulation group: By string we mean a series of data words

(or bytes) exist sequentially in memory. With string instructions, we use

SI, DI, and DF (direction flag) as shown below:

DS: SI

ES: DI

DI, SI= DI+ (1 or 2), SI+ (1or 2) if DF=0

DI, SI= DI- (1 or 2), SI- (1or 2) if DF=1

The general forms of these instructions are as shown below:

 MOVSB, MOVSW: This instruction transfer data from one memory

location to another. This is the only memory-to-memory transfers

allowed in 8086 MPU.

 CMPSB/CMPSW: This instruction compares two elements in the same

different strings. It subtracts the destination operand from the source

operand and adjusts the flags accordingly. The result of subtraction is

not saved.
a) CSASB/ CSASB W: This instruction is similar to compare string; it

compares the destination string with the contents of AL or AX. It

subtracts the destination operand from AL or AX. The result of

subtraction is not saved.

b) LODSB/LODSW: This instruction loads a byte or word from a string

in memory into AL or AX. The address of the source is specified by

DS:SI.

c) STOSB/STOSW: This instruction stores a byte or word from AL or

AX into memory location(s). The address of the destination is

specified by ES: DI.

REP: In most applications, the basis string operations must be repeated. Inserting a

repeat prefix before the instruction that is to be repeated does this


B. Data Processing

 Data processing refers to manipulation of data by a It includes the

conversion of raw data to machine-readable form, flow of data through

the CPU and memory to output devices, and formatting or transformation

of output. Any use of computers to perform defined operations on data can

be included under data processing. In the commercial world, data

processing refers to the processing of data required to run organizations

and businesses.

 Data processing in computer refers to the transforming raw data into

meaningful output. The data can be done manually using a pen and

paper, mechanically using simple devices (e.g. typewriter)

or electronically using modern data processing toolset computers.

 The microprocessor follows a sequence to process the data gathered:

Fetch, Decode, and then Execute.

a) Fetch

 The first step the CPU carries out is to fetch some data and

instructions from main memory, then store them in its own

internal temporary memory areas. These memory areas are

called 'registers'.
 This is where the Address and the Data buses are used.

b) Decode

 The next step is for the CPU to make sense of the instruction

it has just fetched.

 The CPU is designed to understand a specific set of

commands. These are called the 'instruction set' of the CPU.

Each make of CPU has a different instruction set.

 The CPU decodes the instruction and prepares various

areas within the chip in readiness of the next step.

c) Execute

 This is the part of the cycle when data processing actually

takes place. The instruction is carried out upon the data

(executed). The result of this processing is stored in yet

another register or in the main memory (RAM).

 Once the execute stage is complete, the CPU sets itself up

to begin another cycle.


C. Control

 Microprocessor, as a main control unit inside the CPU, can direct the

operations during the execution of a program. The main function of the

control unit is to fetch and execute instructions from the memory of a

computer. It receives the input instruction/information from the user

and converts it into control signals, which are then given to the CPU for

further execution. It is also responsible for providing the timing signals,

and control signals and directs the execution of a program by the CPU.

 Control Unit is the component which receives the input

signal/information/instruction from the user and converts into control

signals for the execution in the CPU. It controls and directs the main

memory, arithmetic & logic unit (ALU), input and output devices, and

also responsible for the instructions that are sent to the CPU of a

computer. It fetches the instructions from the main memory of a

processor and sent to the processor instruction register, which

contains register contents. The control unit converts the input into

control signals and then sent to the processor and directs the

execution of a program. The operations that have to performed are

directed by the processor on the computer. Mainly Central Processing

Unit (CPU) and Graphical Processing Unit (GPU) require a control unit


as the internal part. The block diagram of the control unit is shown

above.

 Component of control unit

 The components of this unit are instruction registers, control

signals within the CPU, control signals to/from the bus, control

bus, input flags, and clock signals.

 The components of the Hardwired control unit are instruction

register (contains opcode and address field), timing unit, control

state generator, control signal generation matrix, and instruction

decoder.

 The components of the Micro programmed control unit are the

next address generator, a control address register, control

memory, and control data register.

 Function of control unit

 It directs the flow of data sequence between the processor and

other devices.

 It can interpret the instructions and controls the flow of data in

the processor.

 It generates the sequence of control signals from the received

instructions or commands from the instruction register.


 It has the responsibility to control the execution units such as

ALU, data buffers, and registers in the CPU of a computer.

 It has the ability to fetch, decode, handle the execution, and

store results.

 It cannot process and store the data

 To transfer the data, it communicates with the input and output

devices and controls all the units of the computer.


D. Data Storage

 Microprocessor is mainly designed with two different memories which

let the computer to store information comprise from data to be used for

computations, instruction, and computational results.

a) RAM or Random Access Memory is volatile memory that gets

erased when power is switched off. All data and instructions are

stored in RAM.

 Random Access Memory (RAM) is usually used for storing

programs and data in a computer. Most computers also use

some Read Only Memory (ROM) or Erasable-Programmable

Read Only Memory (EPROM). This stores programs (or libraries

of procedures) which do not need to be changed. (This usually

includes the program that is executed when the computer is first

turned on, and the procedures required to access permanently

connected peripherals - such as the keyboard, display, disk

drive, ...).

 Static RAM is composed of D-Type Flip-Flops, and is extremely

fast, however it is also expensive. It is therefore usually

reserved for applications requiring a high speed (such as

graphics display memory or cache memory). The main


computer memory is usually formed from Dynamic RAM

(DRAM), which uses an array of "capacitor" storage elements.

Although slower than SRAM, it is also much cheaper, and

therefore it usually possible to buy many MB of Dynamic RAM

per computer.

b) ROM or Read Only Memory is non-volatile memory whose data

remains intact even after power is switched off. Microprocessor can

read from it any time it wants but cannot write to it. It is

preprogrammed with most essential data like booting sequence by

the manufacturer.

 Mask ROM – It is custom programmed or mask programmed when

manufactured and cannot be altered thereafter. The cost of a

custom built mask for programming is that thousands of ROMs

storing the same information must be produced to pay for the

mask.

 Programmable ROM (PROM) – This type is programmable by the

user (typically by electrically overheating fusible links in selected

manner). Once programmed, the contents cannot be altered. The

memory may be programmed one at a time by the user and is thus


suitable for the cases where small quantities of a ROM are

needed.

 Electrically Alterable ROM (EAROM) – In this type of memory, the

contents can be electrically erased (by applying a large negative

voltage to control gates of memory cells) and the memory can be

then reprogrammed (by applying a large positive voltage to

control gates). This type is convenient when the user is not sure of

the program and may wish to modify it. This is a typical

requirement in prototype development.

 Erasable Programmable ROM (EPROM) – Like EAROM, this type of

memory can also be erased and reprogrammed. However, erasing

is by exposing the memory chips to high intensity ultraviolet light

of a wavelength close to 2537 Å. It has the same application filed

as the EAROM.

REFERENCES:

http://mptuter.blogspot.com/2013/07/data-movement-instructions.html

https://www.d.umn.edu/~gshute/mips/data-movement.xhtml#:~:text=Data%20movement

%20instructions%20move%20data,data%20from%20memory%20to%20registers.
https://www.tutorialspoint.com/microprocessor/

microprocessor_quick_guide.htm#:~:text=The%20microprocessor%20follows%20a

%20sequence,till%20STOP%20instruction%20is%20reached.

https://slideplayer.com/slide/12329604/

https://www.britannica.com/technology/data-processing

https://peda.net/kenya/ass/subjects2/computer-studies/form-3/data-processing

https://www.brainspire.com/blog/what-is-a-microprocessor-and-how-does-it-

work#:~:text=A%20microprocessor%20accepts%20binary%20data,instructions

%20stored%20in%20the%20memory.&text=The%20register%20array%20processes

%20the,temporary%20fast%20access%20memory%20locations.

https://www.elprocus.com/what-is-control-unit-components-its-design/#:~:text=The

%20main%20function%20of%20the,the%20memory%20of%20a%20computer.&text=It

%20is%20responsible%20for%20providing,a%20program%20by%20the%20CPU.

chrome-extension://oemmndcbldboiebfnladdacbdfmadadm/http://

www.science.smith.edu/~jcardell/Courses/EGR328/Readings/uProc%20Ovw.pdf

https://erg.abdn.ac.uk/users/gorry/eg2068/course/mem.html

https://www.tutorialspoint.com/basics_of_computers/

basics_of_computers_microprocessor_concepts.htm

You might also like