Computer Organization II: Instruction Execution and Addressing Modes, Lecture notes of Computer Architecture and Organization

An overview of instruction execution, data types, instruction representation, and addressing modes in computer organization ii, taught by teemu kerola during the autumn 2010 semester. Topics include instruction execution, data types, instruction representation, and various addressing modes such as register, memory, and indexed addressing.

Typology: Lecture notes

2017/2018

Uploaded on 09/23/2018

muhammad-waleed-mirz
muhammad-waleed-mirz šŸ‡µšŸ‡°

1 document

1 / 21

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15

Partial preview of the text

Download Computer Organization II: Instruction Execution and Addressing Modes and more Lecture notes Computer Architecture and Organization in PDF only on Docsity!

Instruction sets

( KƤskykannat )

Ch 10-11 [Sta10] Ā„ Operations Ā„ Operands Ā„ Operand references (osoitustavat) Ā„ Pentium / ARM

Lecture 6

Instruction cycle

Ā„ CPU executes instructions ā€œone after anotherā€

Ā„ Execution of one instruction has several phases (see state

diagram). The CPU repeats these phases

Computer Organization II, Autumn 2010, Teemu Kerola 10.11.2010 2

(Sta10 Fig 10.1)

Computer Instructions ( konekƤskyt )

Ā„ Instruction set ( kƤskykanta ) =

Ā„ Set of instructions CPU ā€˜knows’

Ā„ Operation code ( kƤskykoodi )

Ā„ What does the instruction do?

Ā„ Data references ( viitteet ) – one, two, several?

Ā„ Where does the data come for the instruction?

  • Registers, memory, disk, I/O Ā„ Where is the result stored?
  • Registers, memory, disk, I/O

Ā„ What instruction is executed next?

Ā„ Implicit? Explicit?

Ā„ I/O?

„ Memory-mapped I/O € I/O with memory reference operations

Computer Organization II, Autumn 2010, Teemu Kerola 10.11.2010 3

Covered on Comp. Org I

Access time? Access rate?

Instructions and data ( kƤskyt ja data )

Computer Organization II, Autumn 2010, Teemu Kerola 10.11.2010 4

instructions

data

address

value

Symbolic

name

(Sta10 Fig 11.13)

What kind of data?

Ā„ Integers, floating-points

Ā„ Boolean ( totuusarvoja )

Ā„ Characters, strings

Ā„ IRA (aka ASCII), EBCDIC

Ā„ Vectors, tables

Ā„ N elements in sequence

Ā„ Memory references

Ā„ Different sizes

Ā„ 8 /16/32/ 64b, … Ā„ Each type and size has its own operation code

Computer Organization II, Autumn 2010, Teemu Kerola 10.11.2010 7

IBM EAS/390 (Sta10 Table 10.5)

Instruction representation ( kƤskyformaatti )

Ā„ How many bits for each field in the instruction?

Ā„ How many different instructions? Ā„ Maximum number of operands per instruction? Ā„ Operands in registers or in memory? Ā„ How many registers?

Ā„ Fixed or variable size ( vakio vai vaihteleva koko )?

Computer Organization II, Autumn 2010, Teemu Kerola 10.11.2010 8

(Sta10 Table 10.1)

How many registers?

Ā„ Minimum 16 to 32

Ā„ Work data in registers

Ā„ Different register (sets) for different purpose?

Ā„ Integers vs. floating points, indices vs. data, code vs. data Ā„ All sets can start register numbering from 0 Ā„ Opcode determines which set is used

Ā„ More registers than can be referenced?

Ā„ CPU allocates them internally

  • Register window – virtual register names Ā„ Example: function parameters passed in registers
  • Programmer thinks that registers are always r8-r15,
  • CPU maps r8-r15 somewhere to r8-r
  • (We’ll come back to this later)

Computer Organization II, Autumn 2010, Teemu Kerola 10.11.2010 9

Architectures

Ā„ Accumulator-based architecture ( akkukone ) Ā„ Just one register, accumulator, implicit reference to it

Ā„ Stack-based ( pinokone) Ā„ Operands in stack, implicit reference Ā„ PUSH, POP

Ā„ Register-based ( yleisrekisterikone ) Ā„ All registers of the same size Ā„ Instructions have 2 or 3 operands

Ā„ Load/Store architecture Ā„ Only LOAD/STORE have memory refs Ā„ ALU-operations have 3 regs

Computer Organization II, Autumn 2010, Teemu Kerola 10.11.2010 10

LOAD R3, C

LOAD R2,B

ADD R1,R2,R

STORE R1,A

See : Appendix 10A in Ch10 [Sta10]

Example: JVM

Data alignment ( kohdentaminen )

Ā„ 16b data starts with even ( parillinen ) (byte)address

Ā„ 32b data starts with address divisible ( jaollinen ) by 4

Ā„ 64b data starts with address divisible by 8

Ā„ Aligned data is easier to access

Ā„ 32b data can be loaded by one operation accessing the word address ( sanaosoite )

Ā„ Unaligned data would contain no ’wasted’ bytes, but

Ā„ For example, loading 32b unaligned data requires two loads from memory (word address) and combining it

Computer Organization II, Autumn 2010, Teemu Kerola 10.11.2010 13

load r1, 2(r4) shl r1, = load r2, 4(r4) shr r2, = or r1, r

load r1, 0(r4) or

r1: 11 22 33 44 r1: 11 22 33 44

r

r

Computer Organization II

Computer Organization II, Autumn 2010, Teemu Kerola 10.11.2010 14

Memory references

(Muistin osoitustavat)

Ch 11 [Sta10]

Where are the operands?

Ā„ In the memory Ā„ Variable of the program, stack ( pino ), heap ( keko )

Ā„ In the registers Ā„ During the instruction execution, for speed

Ā„ Directly in the instruction Ā„ Small constant values

Ā„ How does CPU know the specific location? Ā„ Bits in the operation code Ā„ Several alternative addressing modes allowed

Computer Organization II, Autumn 2010, Teemu Kerola 10.11.2010 15

Addressing modes ( osoitusmuodot )

Computer Organization II, Autumn 2010, Teemu Kerola 10.11.2010 16

(Sta10 Fig 11.1)

More addressing modes

Ā„ Autoincrement (before/after)

Ā„ Example CurrIndex=i++;

Ā„ Autodecrement (before/after)

Ā„ Example CurrIndex=--i;

Ā„ Autoincrement deferred

Ā„ Example Sum = Sum + (*ptrX++);

Ā„ Autoscale

Ā„ Example Double X; …. X=Tbl[i];

Computer Organization II, Autumn 2010, Teemu Kerola 10.11.2010 19

EA = (R), R m (R) + S

EA = Mem(R), R m (R) + S

R m (R) - S, EA = (R)

operand size

EA = A + (R) * S

Computer Organization II

Computer Organization II, Autumn 2010, Teemu Kerola 10.11.2010 20

Pentium

Pentium: Registers

Ā„ General registers ( yleisrekisterit ), 32-b

Ā„ EAX, EBX, ECX, EDX accu, base, count, data Ā„ ESI, EDI source & destination index Ā„ ESP, EBP stack pointer, base pointer

Ā„ Part of them can be used as16-bit registers

Ā„ AX, BX, CX, DX, SI, DI, SP, BP

Ā„ Or even as 8-bit registers

Ā„ AH, AL, BH, BL, CH, CL, DH, DL

Ā„ Segment registers 16b

Ā„ CS, SS, DS, ES, FS, GS

  • code, stack, data, data, ...

Ā„ Program counter ( kƤskynosoitin)

Ā„ EIP Extended Instruction Pointer

Ā„ Status register

Ā„ EFLAGS

  • overflow, sign, zero, parity, carry,…

Computer Organization II, Autumn 2010, Teemu Kerola 10.11.2010 21

(Sta10 Fig 12.3c)

x86: Data types

Computer Organization II, Autumn 2010, Teemu Kerola 10.11.2010 22

(Sta10Table 10.2)

Single / Double / Extended precision

Ā„ Not aligned Ā„ Little Endian

IEEE 754 standard

Pentium: Addressing modes (muistin osoitustavat)

Computer Organization II, Autumn 2010, Teemu Kerola 10.11.2010 25

(Sta10 Table 11.2)

1, 2, 4, 8B

Registers: 1, 2, 4, 8B

Operand = (R)

x86 Addressing

indexing arrays? arrays in stack? two dimensional arrays?

Pentium: Addressing Mode Calculation

Computer Organization II, Autumn 2010, Teemu Kerola 10.11.2010 26

(Sta10 Fig 11.2)

LA = (SR)+(I)*S+(B)+A

A

B

C

Discussion?

Pentium: Instruction format

Ā„ CISC

Ā„ Complex Instruction Set Computer

Ā„ Lots of alternative fields

Ā„ Part may be present or absent in the bit sequence Ā„ Prefix 0-4 bytes Ā„ Interpretation of the rest of the bit sequence depends on the content of the preceding fields

Ā„ Plenty of alternative addressing modes ( osoitustapa)

Ā„ At most one operand can be in the memory Ā„ 24 different

Ā„ Backward compatibility

Ā„ OLD 16-bit 8086-programs must still work

  • How to handle old instructions: emulate, simulate?

Computer Organization II, Autumn 2010, Teemu Kerola 10.11.2010 27

only op-code always!

Pentium: Instruction format

Computer Organization II, Autumn 2010, Teemu Kerola 10.11.2010 28

Addressing

1. Operand

(register)

2. operand (register)

or form part of the addressing-mode

(Sta10 Fig 11.9)

Pentium: Instruction format

Ā„ Displacement (optional)

Ā„ Certain addressing modes need this

Ā„ 0, 1, 2 or 4 bytes (0, 8, 16 or 32 bits)

Ā„ Immediate (optional)

Ā„ Certain addressing modes need this, value for

operand

Ā„ 0, 1, 2 or 4 bytes

Computer Organization II, Autumn 2010, Teemu Kerola 10.11.2010 31

Computer Organization II

Computer Organization II, Autumn 2010, Teemu Kerola 10.11.2010 32

ARM Instructions

ARM: Instruction set (kƤskykanta)

Ā„ RISC

Ā„ Reduced Instruction Set Computer

Ā„ Fixed instruction length (32b), regular format

Ā„ All instructions have the condition code (4 bits)

Ā„ Small number of different instructions

Ā„ Instruction type (3 bit) and additional opcode /modifier (5 bit) Ā„ Easier hardware implementation, faster execution Ā„ Longer programs?

Ā„ Load/Store-architecture

Ā„ 16 visible general registers (4 bits in the instruction)

Ā„ Fixed data size

Ā„ Thump instruction set uses 16 bit instructions

Computer Organization II, Autumn 2010, Teemu Kerola 10.11.2010 33

ARM Data Types

Ā„ 8 (byte), 16 (halfword), 32 (word) bits - word aligned

Ā„ Unsigned integer and twos-complement signed integer

Ā„ Majority of implementations do not provide floating-

point hardware

Ā„ Little and Big Endian supported Ā„ Bit E in status register defines which is used

Computer Organization II, Autumn 2010, Teemu Kerola 10.11.2010 34

ARM Load/Store Multiple Addressing

Ā„ Load/store subset of general-purpose registers

Ā„ 16-bit instruction field specifies list of registers Ā„ Sequential range of memory addresses Ā„ Base register specifies main memory address

Computer Organization II, Autumn 2010, Teemu Kerola 10.11.2010 37

(Sta10 Fig 11.4)

ARM Instruction Formats

Ā„ S = For data processing instructions, updates condition codes Ā„ S = For load/store multiple instructions, execution restricted to supervisor mode Ā„ P, U, W = distinguish between different types of addressing mode Ā„ B = Unsigned byte (B==1) or word (B==0) access Ā„ L = For load/store instructions, Load (L==1) or Store (L==0) Ā„ L = For branch instructions, is return address stored in link register Computer Organization II, Autumn 2010, Teemu Kerola 10.11.2010 38

(Sta10 Fig 11.10)

Discussion?

ARM Condition codes

Computer Organization II, Autumn 2010, Teemu Kerola 10.11.2010 39

Condition flags:

N, Z, C and V

N – Negative

Z – Zero

C – Carry

V – oVerflow

(Sta10 Tbl 10.12)

RISC vs. CISC

Computer Organization II, Autumn 2010, Teemu Kerola 10.11.2010 40

HW (Pentium) SW (Crusoe)

We’ll return to this later (lecture 8)

RISC

easy to execute

HW

CISC

support high-level languages

difficult to execute

HW

High-level programming language

High-level programming language

HW

CISC

support high-level lang

difficult to execute

RISC

easy to execute

High-level programming language