CPU instructions MIPS architecture
1 cpu instructions
1.1 loads , stores
1.2 alu
1.3 shifts
1.4 multiplication , division
1.5 jump , branch
1.6 exception
cpu instructions
loads , stores
mips has instructions load , store 8-bit bytes, 16-bit halfwords, , 32-bit words. 1 addressing mode supported: base + displacement. since mips 32-bit architecture, loading quantities fewer 32 bits requires datum either signed- or zero-extended 32 bits. load instructions suffixed unsigned perform 0 extension; otherwise sign extension performed. load instructions source base contents of gpr (rs) , write result gpr (rt). store instructions source base contents of gpr (rs) , store data gpr (rt). load , store instructions compute memory address summing base sign-extended 16-bit immediate. mips requires memory accesses aligned natural word boundaries, otherwise exception signaled. support efficient unaligned memory accesses, there load/store word instructions suffixed left or right . load instructions followed load delay slot. instruction in load delay slot cannot use data loaded load instruction. load delay slot can filled instruction not dependent on load; nop substituted if such instruction cannot found.
alu
mips has instructions perform addition , subtraction. these instructions source operands 2 gprs (rs , rt), , write result third gpr (rd). alternatively, addition can source 1 of operands 16-bit immediate (which sign-extended 32 bits). instructions addition , subtraction have 2 variants: default, exception signaled if result overflows; instructions unsigned suffix not signal exception. overflow check interprets result 32-bit 2 s complement integer.
mips has instructions perform bitwise logical and, or, xor, , nor. these instructions source operands 2 gprs , write result third gpr. and, or, , xor instructions can alternatively source 1 of operands 16-bit immediate (which zero-extended 32 bits).
the set on relation instructions write 1 or 0 destination register if specified relation true or false. these instructions source operands 2 gprs or 1 gpr , 16-bit immediate (which sign-extended 32 bits), , write result third gpr. default, operands interpreted signed integers. variants of these instructions suffixed unsigned interpret operands unsigned integers (even source operand sign-extended 16-bit immediate).
the load immediate upper instruction copies 16-bit immediate high-order 16 bits of gpr. used in conjunction or immediate instruction load 32-bit immediate register.
shifts
mips has instructions perform left , right logical shifts , right arithmetic shifts. operand obtained gpr (rt), , result written gpr (rd). shift distance obtained either gpr (rs) or 5-bit shift amount (the sa field).
multiplication , division
mips has instructions signed , unsigned integer multiplication , division. these instructions source operands 2 gprs , write results pair of 32-bit registers called hi , lo, since may execute separately (and concurrently with) other cpu instructions. multiplication, high- , low-order halves of 64-bit product written hi , lo (respectively). division, quotient written lo , remainder hi. access results, pair of instructions (move hi , move lo) provided copy contents of hi or lo gpr. these instructions interlocked: reads of hi , lo not proceed past unfinished arithmetic instruction write hi , lo. pair of instructions (move hi or move lo) copies contents of gpr hi , lo. these instructions used restore hi , lo original state after exception handling. instructions read hi or lo must separated 2 instructions not write hi or lo.
jump , branch
all mips control flow instructions followed branch delay slot. unless branch delay slot filled instruction performing useful work, nop substituted. mips branch instructions compare contents of gpr (rs) against 0 or gpr (rt) signed integers , branch if specified condition true. control transferred address computed shifting 16-bit offset left 2 bits, sign-extending 18-bit result, , adding 32-bit sign-extended result sum of program counter (instruction address) , 810. jumps have 2 versions: absolute , register-indirect. absolute jumps ( jump , jump , link ) compute address control transferred shifting 26-bit instr_index left 2 bits , concatenating 30-bit result 2 high-order bits of instruction in branch delay slot address s. register-indirect jumps transfer control instruction @ address sourced gpr (rs). address sourced gpr must word-aligned, else exception signaled after instruction in branch delay slot executed. branch , jump instructions link (except jump , link register ) save return address gpr 31. jump , link register instruction permits return address saved writable gpr.
exception
mips has 2 instructions software signal exception: system call , breakpoint. system call used user mode software make kernel calls; , breakpoint used transfer control debugger via kernel s exception handler. both instructions have 20-bit code field can contain operating environment-specific information exception handler.
Comments
Post a Comment