Lecture 6 Updated

Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

COMPUTER

ORGANIZATION
Dr. Zahraa Salaheldin Ismail
Lecture 6: Basic Computer Instructions
PROGRAM

❑The user of a computer can control the process by means of a program.

❑A program is a set of instructions that specify the operations, operands, and the sequence by which processing has to
occur.

❑ Program: a sequence of (machine) instructions.


INSTRUCTIONS

▪ (Machine) Instruction: a group of bits that tell the computer to perform a specific operation (a sequence of micro-
operation)

▪ The CPU reads the next instruction from the memory

▪ It is placed in an Instruction Register (IR)

▪Control circuitry in the control unit → translates the instruction into the sequence of microoperations necessary
to implement it.
INSTRUCTION FORMAT
❑Computer instruction is often divided into three parts
◦ An opcode (Operation Code) that specifies the operation for that instruction
◦ An address that specifies the registers and/or locations in memory to use for that operation
◦ 1-bit for Addressing mode

▪ 12-bit to specify which memory address this instruction will use.


▪bit 15 of the instruction specifies the addressing mode (0: direct addressing, 1: indirect addressing)
▪ hence the instruction is 16-bits long, which leaves 3 bits for the instruction’s opcode.
ADDRESSING MODE

 The address field of instruction can represent either

◦ Direct address: the address in memory of the data to use (the address of the operand). or

◦ Indirect address: the address in memory of the address in memory of the data to use.

 Effective Address (EA)


◦ The address of the target data.
ADDRESSING MODE

 What is the effective address of the following instruction ?


(a) 457
(b) 1350
INDIRECT ADDRESSING MODE

 e: …..

….. Jmp e

 int a[12]; // array

ADD AR  a+12

read M[AR]
BASIC COMPUTER INSTRUCTIONS (EXAMPLE)

 For the following 16-bit instruction, 1011 0001 0010 0100

 Give the equivalent hexadecimal code and explain what the instruction is going to perform.

 Sol:
HEXADECIMAL NUMBER SYSTEM (BASE 16)
BASIC COMPUTER INSTRUCTION FORMAT
BASIC COMPUTER INSTRUCTIONS
BASIC COMPUTER INSTRUCTIONS

▪ A computer should have a set of instructions so that the user can construct machine language programs to evaluate any
function that is known to be computable.

▪ Instruction Types
◦ Functional Instructions
Arithmetic, logic, and shift instructions
◦ Transfer Instructions
Data transfers between the main memory and the processor registers
◦ Control Instructions
Program sequencing and control
◦ Input/Output Instructions
Input and output
BASIC COMPUTER INSTRUCTIONS

o Functional Instructions
Arithmetic instructions ADD, CMA, INC
 There is one arithmetic instruction, ADD, and two related instructions, complement AC(CMA) and increment AC(INC). With
these three instructions we can add and subtract binary numbers when negative numbers are in signed-2's complement
representation. Multiplication and division can be performed using addition, subtraction, and shifting.

Logic instructions AND, CMA


 The AND and complement provide a NAND operation. It can be shown that with the NAND operation. it is possible to
implement all the other logic operations with two variables

Shift instructions CIR, CIL


 The circulate instructions, CIR and CIL, can be used for arithmetic shifts as well as any other type of shifts desired.
USING NAND GATES TO IMPLEMENT SUM-OF-PRODUCTS
BASIC COMPUTER INSTRUCTIONS (EXAMPLE)

 Write a program using basic computer microoperations to increment data stored in the memory location 12C
REGISTER-REFERENCE INSTRUCTIONS
REGISTER-REFERENCE INSTRUCTIONS (EXAMPLE)

 PC = 021, AC = A937, and E = 1.


 Determine the contents of AC, E, PC, AR, and IR after each register-reference instruction. Start each of the
instructions from the initial values of PC, AC, and E.
MEMORY-REFERENCE INSTRUCTIONS
COMMON BUS SYSTEM

 AND INSTRUCTION

 MICRO-OPERATIONS

 DR  M[AR]

 AC  DR and AC
MEMORY-REFERENCE INSTRUCTIONS (EXAMPLE)

 An instruction at address 021 in the basic computer has I = 0, an operation code of the
 AND instruction, and an address part equal to 083.
 M[083] = B8F2 and the content of AC is A937.
 Go over the instruction cycle and determine the contents of the following registers after the execution phase.
Repeat the problem six more times starting with an operation code of another memory-reference instruction.
INPUT-OUTPUT INSTRUCTIONS

 FGI = 1 if there is an input character


 FGO = 1 if there is an output character

The branch instruction is not skipped if the flag is 0. If the flag is 1, the branch instruction is skipped and an input or
output instruction is executed.
BASIC COMPUTER INSTRUCTIONS (EXAMPLE)
BASIC COMPUTER INSTRUCTIONS (EXAMPLE)

You might also like