Instruction Cycle State Diagram BCDE Instruction Comment SUB





Instruction Cycle State Diagram




เปรยบเทยบคำสงทใชทอยอางอง B)/(C+D*E( Instruction Comment SUB MPY ADD DIV Y , A, B T, D, E T, T, C Y, Y, T Y A – B T D E T T + C Y Y T MOVE SUBY, MOVE MPY ADD DIV Y, A B T, D T, E T, C Y, T Y A Y Y – B T D T T E T T + C Y Y T (a)Three-address instructions (b) Two-address instructions Y=(AInstruction. Comment LOAD D AC D MPY E AC AC E ADD C AC AC + C STOR Y Y AC LOAD A AC A SUB B AC AC – B DIV Y AC AC Y STOR Y Y AC (c) One-address instructions

Number of Addresses (a) จำนวนของทอยอางองในคำสงเครอง • 3 addresses —Operand 1, Operand 2, Result —a = b + c; —May be a forth - next instruction (usually implicit) —Not common —Needs very long words to hold everything

Number of Addresses (b) • 2 addresses —One address doubles as operand result —a = a + b —Reduces length of instruction —Requires some extra work – Temporary storage to hold some results

Number of Addresses (c) • 1 address —Implicit second address —Usually a register (accumulator) —Common on early machines

Number of Addresses (d) • 0 (zero) addresses —All addresses implicit —Uses a stack —e. g. push a — push b — add — pop c —c = a + b

How Many Addresses • More addresses ถาใช Address มาก —More complex (powerful? ) instructions (ซบซอน —More registers (ใช Register มากกวา ( ( – Inter-register operations are quicker —Fewer instructions per program (ใชชดคำสงนอยตอโปรแกรม • Fewer addresses ถาใช ( Address นอย —Less complex (powerful? ) instructions (ซบซอนนอยกวา ( —More instructions per program(ใชชดคำสงมากกวาตอโปรแกรม —Faster fetch/execution of instructions (ประมวลผลเรวกวา ( (


Design Decisions (2) • Registers —Number of CPU registers available จำนวน Register —Which operations can be performed on which registers? • Addressing modes (later…) รปแบบการทำงานทใชกำหนดชนดของท อยของตวถกดำเนนการ • RISC v CISC

Types of Operand ชนดของตวถกดำเนนการ • Addresses ตำแหนงทอย • Numbers ตวเลข —Integer/floating point • Characters ตวอกษร —ASCII etc. • Logical Data ขอมลตรรกะ —Bits or flags • (Aside: Is there any difference between numbers and characters? Ask a C programmer!)

Pentium Data Types • • • 8 bit Byte 16 bit word 32 bit double word 64 bit quad word Addressing is by 8 bit unit A 32 bit double word is read at addresses divisible by 4

Specific Data Types)ชนดขอมลของ • • • Pentium( General - arbitrary binary contents Integer - single binary value Ordinal - unsigned integer Unpacked BCD - One digit per byte Packed BCD - 2 BCD digits per byte Near Pointer - 32 bit offset within segment Bit field Byte String Floating Point

Pentium Floating Point Data Types

Power. PC Data Types (ชนดขอมลใน cpu Power PC( • 8 (byte), 16 (halfword), 32 (word) and 64 (doubleword) length data types • Some instructions need operand aligned on 32 bit boundary • Can be big- or little-endian • Fixed point processor recognises: —Unsigned byte, unsigned halfword, unsigned doubleword, byte string (<128 bytes) • Floating point —IEEE 754 —Single or double precision





Shift and Rotate Operations


Input/Output (คำสงทตดตอกบอปกรณ Input/Output( • May be specific instructions • May be done using data movement instructions (memory mapped) • May be done by a separate controller (DMA)



Branch Instruction

Nested Procedure Calls

Use of Stack

สรปตวอยางชนดของ Type Operation Name Opcode Description Data transfer Move (transfer) Store Load (fetch) Exchange Clear (reset) Set Push Pop Transfer word or block from source to destination Transfer word from processor to memory Transfer word from memory to processor Swap contents of source and destination Transfer word of 0 s to destination Transfer word of 1 s to destination Transfer word from source to top of stack Transfer word from top of stack to destination Arithmetic Add Subtract Multiply Divide Absolute Negate Increment Decrement Compute sum of two operands Compute difference of two operands Compute product of two operands Compute quotient of two operands Replace operand by its absolute value Change sign of operand Add 1 to operand Subtract 1 from operand

สรปตวอยางชนดของ AND OR NOT (Complement) Exclusive-OR Logical Test Compare Set control variables Shift Rotate Opcode Perform the specified logical operation bitwise Test specified condition; set flag(s) based on outcome Make logical or arithmetic comparison of two or more operands; set flag(s) based on outcome Class of instructions to set controls for protection purposes, interrupt handling, timer control, etc. Left (right) shift operand, introducing constants at end Left (right) shift operand, with wraparound end

สรปตวอยางชนดของ Jump (branch) Jump conditional Jump to subroutine Return Execute Transfer Of control Skip conditional Halt Wait (hold) No operation Opcode Unconditional transfer; load PC with specified address Test specified condition; either load PC with specified address or do nothing, based on condition Place current program control information in known location; jump to specified address Replace contents of PC and other register from known location Fetch operand from specified location and execute as instruction; do not modify PC Increment PC to skip next instruction Test specified condition; either skip or do nothing based on condition Stop program execution; test specified condition repeatedly: resume execution when condition is satisfied No operation is performed, but program execution is continued

สรปตวอยางชนดของ Input (read) Input/ output Output (write) Start I/O Test I/O Translate Convert conver sion Opcode Transfer data from specified I/O port or device to destination (e. g. , main memory or processor register) Transfer data from specified source to I/O port or device Transfer instructions to I/O processor to initiate I/O operation Transfer status information from I/O system to specified destination Translate values in a section of memory based on a table of correspondences Convert the contents of a word from one form to another (e. g. , packed decimal to binary)


Byte Order (example) • • • Address 184 185 186 Value (1) 12 34 56 78 Big Endian Value(2) 78 56 34 12 Little Endian

Standard…What Standard? • Pentium (80 x 86), VAX are little-endian • IBM 370, Moterola 680 x 0 (Mac), and most RISC are big-endian • Internet is big-endian —Makes writing Internet programs on PC more awkward! —Win. Sock provides htoi and itoh (Host to Internet & Internet to Host) functions to convert
- Slides: 40