0% found this document useful (0 votes)
88 views6 pages

Assembly Instruction Guide

This document discusses different types of computer instructions including: 1) Data movement instructions like LOAD, STORE, PUSH, and POP that move data between registers and memory. 2) Arithmetic and logical instructions that perform math operations. 3) Sequencing instructions like branches that change the program counter to alter the flow of execution. 4) Input/output instructions like INPUT and OUTPUT that transfer data between devices and memory-mapped I/O. The document provides examples of using different instruction types to add numbers in memory, sort a list, search a list, and pass parameters on a stack.

Uploaded by

Mido Much
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)
88 views6 pages

Assembly Instruction Guide

This document discusses different types of computer instructions including: 1) Data movement instructions like LOAD, STORE, PUSH, and POP that move data between registers and memory. 2) Arithmetic and logical instructions that perform math operations. 3) Sequencing instructions like branches that change the program counter to alter the flow of execution. 4) Input/output instructions like INPUT and OUTPUT that transfer data between devices and memory-mapped I/O. The document provides examples of using different instruction types to add numbers in memory, sort a list, search a list, and pass parameters on a stack.

Uploaded by

Mido Much
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/ 6

Lecture

INSTRUCTION-TYPES
1-

Data Movement Instructions

MOVE

Move

LOAD
STORE
PUSH Store
POP

data (a word or a block) from a given source


(a register or a memory) to a given destination
Load data from memory to a register

Store

data into memory from a register


data from a register to stack
Retrieve data from stack into a register

Destinations are override and source ate not changed


Ex.
LOAD 25838, Rj

M (25838)--------------> Ri

STORE Ri, 1024

Ri ----------------------> M(1024)

2-

content of M (25838) is
unchanged
content of M is Ri
unchanged

Arithmetic and Logical Instructions

3- Sequencing

Instructions

They take the form of CONDITIONAL BRANCHING


(CONDITIONAL JUMP), UNCONDITIONAL BRANCHING (JUMP), or CALL
instructions.
A common characteristic among these instructions is that their execution changes the
program counter (PC) value.
For example jump instructions. In this case, the earlier value of the PC is lost and
execution of the program starts at a new value specified by the instruction.

CONDITION CODE (CC) REGISTER. The values of flags are set based on the results of
executing different instructions.

LOAD #100, R1
Loop: ADD (R2) , R0
DECREMENT R1
BRANCH-IF-GREATER-THAN Loop
If the result of decrementing the contents of register R1 is greater than zero,
i.e. the Z flag is not set,
then the next instruction to be executed is that labeled by
Loop.

EX. Write a segment program that sums up a number of values, N, and stores the
result into memory location SUM. The values to be added are stored in N consecutive
memory locations starting at NUM.
The subroutine, called ADDITION, is used to perform the actual addition of values
while the main program stores the results in SUM.

4- Input/Output

Instructions

They are used to transfer data between the computer and peripheral devices.

The two basic I/O instructions used are the INPUT and OUTPUT instructions.

The INPUT instruction is used to transfer data from an input device to the
processor. Examples of input devices include a keyboard or a mouse.

Input devices are interfaced with a computer through dedicated input ports.
Each port has a dedicated address.

Suppose that the input port through which a keyboard is connected to a computer
carries the unique address 1000.
Therefore, execution of the instruction INPUT 1000 will cause the data stored in a
specific register in the interface between the keyboard and the com puter, call it the
input data register, to be moved into a specific register (called the accumulator) in the
computer. Similarly,
OUTPUT 2000 causes the data stored in the accumulator to be moved to the data
output register in the output device whose address is 2000.
Alternatively, the com puter can address these ports in the usual way of addressing
memory locations. In this case, the com puter can input data from an input device by
executing an instruction such as
MOVE Rin, R0.
This instruction moves the content of the register Rin into the register R0.
Similarly, the instruction MOVE R0, Rin moves the contents of register R0 into the
register Rin, that is, performs an output operation. This latter scheme is called
memory-mapped Input/Output
Among the advantages of memory-mapped I/O is
Elimination of the need for dedicated I/O instructions.
Disadvantage is the need to dedicate part of the memory address space for I/O devices

Example 1
Write a program segment that can be used to perform the task of adding 100 num bers
stored at consecutive m emory locations starting at location 1000. The results should
be stored in memory location 2000.

Example 2 In this exam ple autoincrem ent addressing will be used to perf
same task performed in Example 1.

orm the

Example 3 This example illustrates the use of a subroutine, SORT, to sort N values in
ascending order. The num bers are originally stored in a list starting at location 1000 .
The sorted values are also stored in th e same list and again starting at location 1000.
The subroutine sorts the data using th e well-known Bubble Sort technique. The
content of register R3 is checked at the end of every loop to find out whether the list is
sorted or not.

Example 4 This example illustrates the use of a subroutine, SEARCH, to search for a
value VAL in a list of N values (Fig. 2.14). W e assume that the list is not originally
sorted and therefore a brute force search is used. In this search, the value VAL is
compared with every elem ent in the list from top to bottom . The content of register
R3 is used to indicate whether VAL was f ound. The first element of the list is located
at address 1000.

Example 5 This example illustrates the use of a subroutine, SEARCH, to search for a value VAL in

a list of N values (as in Example 4) (Fig. 2.15). Here, we make use of the stack to send the parameters
VAL and N.

You might also like