














Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!















(^) How do we specify memory addresses? (^) This issue is independent of type of ISA (they all need to address memory) (^) We need to specify (^) (1) Operand sizes (^) (2) Address alignment (^) (3) Byte ordering for multi-byte operands (^) (4) Addressing Modes
(^) For multi-byte memory operands An aligned address for an n-byte operand is an address that is a multiple of n (^) Word-aligned: 0, 4, 8, 12, etc. (^) An ISA can require alignment of operands (^) MIPS: all memory operands must be aligned
MIPS requires that all words start at byte addresses that are multiples of 4 bytes
No, we’re not making this up. at word address 100 (assume a 4-byte word) long a = 11223344; (^) big-endian (MSB at word address) layout 100 101 102 103 100 11 22 33 44 (^) little-endian (LSB at word address) layout 103 102 101 100 11 22 33 44 100
(^) What is the location of an operand? Three basic possibilities (^) Register: operand is in a register (^) Register number encoded in the instruction (^) Immediate: operand is a constant (^) Constant encoded in the instruction (^) Memory: operand is in memory (^) Many address modes possibilities
Key Concept: A register can hold any 32-bit value. That value can be a (signed) int, an unsigned int, a pointer (memory address), and so on If you write add $t2,$t1,$t0 then $t0 and $t1 better contain values If you write lw $t2,0($t0) then $t better contain a pointer Don’t mix these up!
14
Instruction Format op rs rt rd shamt funct add R 0 reg reg reg 0 32 sub R 0 reg reg reg 0 34 lw I 35 reg reg address sw I 43 reg reg address
A[300] = h + A[300]; $t1=A, $s2=h lw $t0, 1200($t1) add $t0, $s2, $t sw $t0, 1200($t1) op rs rt rd shamt funct 100011 01001 01000 0000 0100 1011 0000 000000 10010 01000 01000 00000 100000 101011 01001 01000 0000 0100 1011 0000