



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!




L1: addi $01, $01, -1 # I- swi 525 # I- bne $02, $11, L1 # I- add $08, $01, $00 # I- div $01, $03 # I- mfhi $06 # I- mflo $07 # I- slt $04, $06, $16 # I- … (many more instructions)
L2: add $01, $01, $05 # I- swi 525 # I- bne $02, $12, L3 # I- add $01, $01, $05 # I- swi 525 # I- bne $02, $13, L3 # I- add $01, $01, $05 # I- swi 525 # I- bne $02, $14, L3 # I- jr $18 # I- L3: add $01, $08, $00 # I- jr $31 # I-
instruction comment
instruction comment
int Key; (^) L-2 Address Data int Value; L-3 6000 struct Link *Next; (^) L-4 6004 } Link; (^) L-5 6008 L-6 6012 typedef struct { (^) L-7 6016 Link *Buckets[NUMBUCKETS]; (^) L-8 6020 7084 Link *FreeLinks; (^) L-9 6024 int Size; L- ... } HashTable; (^) L-11 7056 6 L-12 7060 12 void Remove(HashTable *HT, int Key) { (^) L-13 7064 0 int Index; (^) L- ... Link *ThisLink; (^) L-15 7084 3 Link **TrailingPointer; (^) L-16 7088 17 int Hash(int Key); (^) L-17 7092 7120 void Print_Next_Link(Link *Next); (^) L- ... Index = Hash(Key); (^) L-19 7120 5 ThisLink = HT->Buckets[Index]; (^) L-20 7124 29 TrailingPointer = &(HT->Buckets[Index]); (^) L-21 7128 7056 L- ... while(ThisLink != NULL && ThisLink->Key != Key) { (^) L- TrailingPointer = &(ThisLink->Next); (^) L- ThisLink = ThisLink->Next;} (^) L- if (ThisLink != NULL) { (^) L- *TrailingPointer = ThisLink->Next; (^) L- ThisLink->Next = HT->FreeLinks; (^) L- HT->FreeLinks = ThisLink; (^) L- HT->Size -= 1;}}} (^) L-
instruction example meaning arithmetic add add $1,$2,$3 $1 = $2 + $ subtract sub $1,$2,$3 $1 = $2 - $ add immediate addi $1,$2,100 $1 = $2 + 100 add unsigned addu $1,$2,$3 $1 = $2 + $ subtract unsigned subu $1,$2,$3 $1 = $2 - $ add immediate unsigned addiu $1,$2,100 $1 = $2 + 100 set if less than slt $1, $2, $3 if ($2 < $3), $1 = 1 else $1 = 0 set if less than immediate slti $1, $2, 100 if ($2 < 100), $1 = 1 else $1 = 0 set if less than unsigned sltu $1, $2, $3 if ($2 < $3), $1 = 1 else $1 = 0 set if < immediate unsigned sltui $1, $2, 100 if ($2 < 100), $1 = 1 else $1 = 0 multiply mult $2,$3 Hi, Lo = $2 * $3, 64-bit signed product multiply unsigned multu $2,$3 Hi, Lo = $2 * $3, 64-bit unsigned product divide div $2,$3 Lo = $2 / $3, Hi = $2 mod $ divide unsigned divu $2,$3 Lo = $2 / $3, Hi = $2 mod $3, unsigned transfer move from Hi mfhi $1 $1 = Hi move from Lo mflo $1 $1 = Lo
logic and and $1,$2,$3 $1 = $2 & $ or or $1,$2,$3 $1 = $2 | $ and immediate andi $1,$2,100 $1 = $2 & 100 or immediate ori $1,$2,100 $1 = $2 | 100 nor nor $1,$2,$3 $1 = not($2 | $3) xor xor $1, $2, $3 (^) $1 = $2 ⊕ $ xor immediate xori $1, $2, 255 (^) $1 = $2 ⊕ 255 shift shift left logical sll $1,$2,5 $1 = $2 << 5 (logical) shift left logical variable sllv $1,$2,$3 $1 = $2 << $3 (logical), variable shift amt shift right logical srl $1,$2,5 $1 = $2 >> 5 (logical) shift right logical variable srlv $1,$2,$3 $1 = $2 >> $3 (logical), variable shift amt shift right arithmetic sra $1,$2,5 $1 = $2 >> 5 (arithmetic) shift right arithmetic variable srav $1,$2,$3 $1 = $2 >> $3 (arithmetic), variable shift amt memory load word lw $1, 1000($2) $1 = memory [$2+1000] store word sw $1, 1000($2) memory [$2+1000] = $ load byte lb $1, 1002($2) $1 = memory[$2+1002] in least sig. byte load byte unsigned lbu $1, 1002($2) $1 = memory[$2+1002] in least sig. byte store byte sb $1, 1002($2) memory[$2+1002] = $1 (byte modified only) branch branch if equal beq $1,$2,100 if ($1 = $2), PC = PC + 4 + (1004) branch if not equal bne $1,$2,100 (^) if ($1 ≠ $2), PC = PC + 4 + (1004) jump jump j 10000 PC = 10000* jump register jr $31 PC = $ jump and link jal 10000 $31 = PC + 4; PC = 10000*