Instruction Encoding: - The ISA Defines
Instruction Encoding: - The ISA Defines
Opc rs rt immed
8 12 4 33
Bit position 31 25 20 15 0
In hex: 0x21840021
(binary 001000 01100 00100 0000 0000 0010 0001)
sub $7,$8,$9
0 8 9 7 0 34
Unused bits
• Create a mask of all 1’s for the low-order byte of $6. Don’t
care about the other bits.
ori $6,$6,0x00ff #$6[7:0] set to 1’s
• Clear high-order byte of register 7 but leave the 3 other
bytes unchanged
lui $5,0x00ff #$5 = 0x00ff0000
ori $5,$5,0xffff #$5 = 0x00ffffff
and $7,$7,$5 #$7 =0x00…… (…whatever was
#there before)
• Need for
– Opcode (6 bits)
– Register destination (for Load) and source (for Store) : rt
– Base register: rs
– Offset (immed field)
• Example
lw $14,8($sp) #$14 loaded from top of
#stack + 8
35 29 14 8