Presentation is loading. Please wait.

Presentation is loading. Please wait.

Machine Instructions Instruction Formats. Machine Instructions u Internal Signals in computer have high and low voltages which represent values 0 and.

Similar presentations


Presentation on theme: "Machine Instructions Instruction Formats. Machine Instructions u Internal Signals in computer have high and low voltages which represent values 0 and."— Presentation transcript:

1 Machine Instructions Instruction Formats

2 Machine Instructions u Internal Signals in computer have high and low voltages which represent values 0 and 1 (bits) u Computer memory will store strings of bits in some standard length (word size) u Typically, a machine instruction is represented as one or more words -- e.g. a string of bits u Complex computers often have instructions with different lengths u RISC computers -- fixed instruction length

3 Assembly Instructions -- review u arithmetic and logical –use three registers –e.g. add $s0, $s1, $s2 u Memory access -- load/store –use two registers and a constant address –e.g. sw $s0, 8($s5)

4 Assembly Instructions -- new u arithmetic and logical with constant –use two registers and constant –e.g. addi $s0, $t0, 16 u jump instructions –use address, should be as long as possible »on MIPS address can be up to 26 bits –e.g. j 0x4f00024

5 Instruction Format -- MIPS u Instruction is 32 bits u Different fields (substrings) of bits represent different parts of instruction u What needs to be represented? the operation opcode registers used register field constant values immediate field addresses address field

6 Instruction Format -- Principles u Keep to as few different formats as possible u Keep patterns of formats the same -- regular u Keep corresponding parts of format in the same location in the bit string when possible –matches up to hardware more easily –keeps instructions and register/memory designations orthogonal -- that is, non-interfering

7 MIPS Instruction Formats u R-type (register) –instructions which designate three registers –includes most arithmetic/logical instructions u I-type (immediate) –instructions which use two registers and a constant –arithmetic/logical with immediate operand –load and store u J-type –jump instructions with a 26 bit address

8 Exercise -- A 16 bit instruction format We have a 16 bit word. We have 16 general purpose registers. We want to represent three register arithmetic instructions. We want to represent load/store functions with MIPS format. We want to represent arith/log instruction with two registers and immediate operand. How can we do it? How many bits for registers? How many bits can be used for immediate operand? How many bits to indicate operations?

9 MIPS R-type instruction 6 bits 5 bits opcodereg rsreg rtreg rdshamtfunct

10 MIPS I-type instruction 6 bits 16 bits 5 bits opcodereg rsreg rtimmediate value/addr

11 MIPS J-type instruction 6 bits 26 bits opcodeaddress

12 Instruction to hardware 6 bits 5 bits opcodereg rsreg rtreg rdshamtfunct The machine instruction is stored in a register as high and low voltages, which can be switched onto wires to control the operation of the CPU. For example the values for the ADD instruction are given below: ADD $16, $12, $13 00000010000011000110100000100000


Download ppt "Machine Instructions Instruction Formats. Machine Instructions u Internal Signals in computer have high and low voltages which represent values 0 and."

Similar presentations


Ads by Google