• Tidak ada hasil yang ditemukan

INTRODUCTION TO COMPUTING

N/A
N/A
Protected

Academic year: 2024

Membagikan "INTRODUCTION TO COMPUTING"

Copied!
15
0
0

Teks penuh

(1)

INTRODUCTION TO COMPUTING

CPIT 201 WEEK 12 LECTURE 2

(2)

Chapter 5

Computer Organization (Continued)

Faculty of Computing and Information Technology . Rabegh

(3)

Instruction Set

Our simple computer is capable of having a set of sixteen instructions, although we are using only fourteen of these instructions. Each computer instruction consists of two parts: the operation code (opcode) and the operand (s). The opcode specifies the type of operation to be performed code (opcode) and the operand (s). The opcode specifies the type of operation to be performed on the operand (s). Each instruction consists of sixteen bits divided into four 4-bit fields. The

leftmost field contains the opcode and the other three fields contains the operand or address of operand (s), as shown in Figure

(4)

Faculty of Computing and Information Technology . Rabegh

(5)

Processing the Instruction

Our simple computer, like most computers, uses machine cycles. A cycle is made of three phases: fetch, decode and execute. During the fetch phase, the instruction whose address is determined by the PC is obtained from the determined by the PC is obtained from the

memory and loaded into the IR. The PC is then incremented to point to the next instruction.

During the decode phase, the instruction in IR is decoded and the required operands are

fetched from the register or from memory.

(6)

• During the decode phase, the instruction in IR is decoded and the required operands are

fetched from the register or from memory.

Once the third phase is completed, the control unit starts the cycle again, but now the PC is pointing to the next instruction. The process pointing to the next instruction. The process continues until the CPU reaches a HALT

instruction.

Faculty of Computing and Information Technology . Rabegh

(7)

Processing the Instruction An Example:

• Let us show how our simple computer can add two integers A and B and create the result as C. We assume that integers are in two’s

complement format. Mathematically, we show complement format. Mathematically, we show this operation as:

C = A + B

(8)

• We assume that the first two integers are stored in memory locations (40)

16

and (41)

16

and the result should be stored in memory location (42) . To do the simple memory location (42)

16

. To do the simple addition needs five instructions, as shown next:

Faculty of Computing and Information Technology . Rabegh

(9)
(10)

• In the language of our simple computer, these five instructions are encoded as:

Faculty of Computing and Information Technology . Rabegh

(11)

• Storing Program and Data:

We can store the five-line program in

memory starting from location (00) to (04) . memory starting from location (00)16 to (04)16. We already know that the data needs to be

stored in memory locations (40)16, (41)16, and (42)16.

(12)

Cycles:

Our computer uses one cycle per instruction. If we have a small program with five instructions, we need five cycles. We also know that each cycle is normally made up of three steps: fetch, decode, execute. Assume for the moment that we need to add 161 + 254 = 415. The numbers are shown in add 161 + 254 = 415. The numbers are shown in memory in hexadecimal is, (00A1)16, (00FE)16, and (019F)16.

Faculty of Computing and Information Technology . Rabegh

(13)

Processing the instructions

• Our simple computer, like most computers, uses machine cycles. A cycle is made of three phases: fetch, decode and execute. During the fetch phase, the instruction whose address is determined by the PC is obtained from the determined by the PC is obtained from the

memory and loaded into the IR. The PC is then incremented to point to the next instruction.

During the decode phase, the instruction in IR is decoded and the required operands are

fetched from the register or from memory.

(14)

• During the execute phase, the instruction is executed and the results are placed in the

appropriate memory location or the register.

Once the third phase is completed, the control Once the third phase is completed, the control unit starts the cycle again, but now the PC is pointing to the next instruction. The process continues until the CPU reaches a HALT

instruction.

(15)

Referensi

Dokumen terkait

pack both an instruction code and a 15-bit address in the 16-bit instruction format, operations involving memory access will normally be specified in Hack using two instructions:

Decode the data block by following the encoding rules described in the clause of this standard corresponding to the specified encoding method and verify that the decoded data is

The instruction pointer (EIP) register on Intel processors contains the offset in the current code segment for the next instruction to be executed.. It is advanced from one

A general format of an instruction register to register operations is: op r1 r2 r3 means R[r1] = R[r2] op R[r3] To pass values between memory and registers, load/store instructions

Programs and their Execution Program in memory : sequence of instructions known to CPU The processorCPU works as follows, Step A: pick next instruction in the sequence.. Step B: get

Practice: Factorial Write a program reading an integer and printing its factorial ● print an error message if the answer is out of range... Division ● div source source:

START JSR INPUT As the subroutine call instruction is decoded, the CPU saves the address of the next instruction so that the main program can be repeated when the subroutine finishes

If it is a load or store instruction, the memory address computed by the ALU is placed on the address bus and the actual memory access is performed during the second cycle of the