230 likes | 383 Views
Chapter 2:. 22444 - Computer Architecture & Organization (1). Instructions: Language of the Computer. Basic Computer Organization. The 5 Classic Components of a Computer The Basic Hardware/Software Interface The Stored-Program Concept. Instructions. Assembly Language Instruction:
E N D
Chapter 2: 22444 - Computer Architecture & Organization (1) Instructions: Language of the Computer
Basic Computer Organization • The 5 Classic Components of a Computer • The Basic Hardware/Software Interface • The Stored-Program Concept
Instructions • Assembly Language Instruction: Perform: a = b + c ADD a, b, c ; a b + c What are ‘a’, ‘b’ and ‘c’? • The storage concept: • Registers (R1, R2 …) • Memory • Sequence of Instructions: Perform: a = (b + c) – (d + e)
Memory Operands • Data Transfer Instructions • Memory Address (Location) • Slower than registers • Lower bandwidth than registers • Load and Store Instructions Memory 0 1 2 • •
Constant Operands • Memory Operand Performa = b + 4 • Immediate Operand Memory b 4 • • 21 22 • •
Memory Access • Height and Width 1 KB 4 KB • Address & Data 16 Locations 1 K Locations 1 M Locations • Read & Write 8 bit Memory 4 3 0 1 • • 21 22 • • 1024 1 KB
Opcode Operands Stored Program Architecture Memory 1024 x 32 Instructions (Program) Operands (Data) Binary Operand
Memory Organization • Byte Access • Word Access • • 20 Byte 21 Byte • • • • 20 Byte Byte Byte Byte 24 Byte Byte Byte Byte • • • • 20 Byte Byte 22 Byte Byte • •
Memory Organization • Mixed Access • Little Endian • Odd/EvenAlignment • • 20 Byte Byte 22 Byte Byte • • MSB DATA BUS LSB
Memory Organization • Mixed Access • Alignment! • • 20 Byte Byte Byte Byte 24 Byte Byte Byte Byte • • MSB DATA BUS LSB
Opcode Operands Instruction Representation • Instruction Format • Machine Language & Machine Code Sequence of instructions AssemblyLanguage ADD R1, R2, 47 5 1 2 2F 0101 0001 0010 00101111 5 1 2 2 F MachineLanguage
Operations (Opcodes) • Arithmetic • Add, Sub, Mul, Div, Inc, Dec … • Logic • Shift • Logical & Arithmetic • Right & Left • Bitwise AND, OR, XOR • Complement (NOT) 1 0 1 0 0 1 1 1 1 0 1 0 0 1 1 1
Operations (Opcodes) • Shift Operation for Multiplication • Multiply by 2 • Shift Left 1 bit • Unsigned Binary • 2’s Complement • Multiply by 10 • BCD • Shift Left 4 bits 0 0 0 0 0 1 0 0 1 1 1 1 1 1 0 1 0 0 0 0 0 1 0 0 1 0 0 1
Control Instructions • Making Decisions (Conditional Branches) Performif (i == j) then a = b + c else a = b – c i == j ? a = b + c a = b – c
Control Instructions • Transferring Execution • Unconditional Branch or Jump • Call Subroutine • Software Interrupt • • • • • • • • • • • • • •
RISC & CISC • Reduced Instruction Set Computer • 32-Bit Storage: • Registers (R1, R2 … R31) • Memory • Arithmetic operations: • Simple • Limited to registers • Complicated Instruction Set Computer • IA-32
Intel Architecture IA-32 • General-Purpose Registers (GPRs) • Segment Registers Segmented Memory Addressing(Real Mode) Also: “Accumulator” EAX AX AL “Base” EDI ESI ECX EDX EAX EBX DX CX DI AX BX SI AL CL BL DL “Count” “Division” “String Source” “String Destination” CS SS DS
Intel Architecture IA-32 • Variable Length Instruction Format
Chapter 2 The End
Chapter 2 Exercise 1 • Write an assembly language program to perform a+2b where ‘a’ and ‘b’ are stored in R1 and R2. • Write an assembly language program to swap two locations at memory addresses 10 and 20. • Rewrite the following program to run faster:SUB R1, R1, R1INC R1ADD R2, R3, R1 • A memory has 4 bits of address and 4 bits of data. Determine the total number of bits inside it.
Chapter 2 Exercise 2 • Determine the value of R1:LD R1, M [ 43 ] • Write the assemblyinstruction at 44. • Assuming 8-bit registers, determine the value of R1:Load Immediate R1, Binary ‘11110010’Arith Shift Right R1 • Assuming iandjare integers,R1= i and R2 = j, write the C-language statement for:Compare R1, R2 Jump Equal Label_1 Clear R1Label_1: Clear R2