Pacific-Design.com

    
Home Index

1. MIPS

MIPS /

MIPS - Table of Registers

 +---+-----+ 
 | f | $s0 | 
 +---+-----+
 | g | $s1 |
 +---+-----+
 | h | $s2 |
 +---+-----+
 | i | $s3 |
 +---+-----+
 | j | $s4 |
 +---+-----+
 | A | $s6 |
 +---+-----+
 | B | $s7 |
 +---+-----+

f = - g – A[4]

 lw $s0, 16($s6)      ... f = A[4]

 add $s0, $s0, $s1    ... f = f + g

 sub $s0, $zero, $s0  ... f = 0 - f = -f

B[8] = A[i-j]


 sub $s3, $s3, $s4    ... i = i - j

 sll $s3, $s3, 2      ... shift 2 multiple by 4

 add $s3, $s3, $s6    ... i = address of A[i-j] - A + (i-j)

 lw $t0, 0($s3)       ... load A[i-j] to $t0

 sw 32($s7), $t0      ... save $t0 in B[8]


f = -g + h + B[1]


 lw $s0, 4($s7)       ... f = B[1]

 add $s0, $s0, $s2    ... f = f + h

 add $s0, $s0, $s1    ... f = f + g


B[8] = A[i] + A[j]


 sll $s3, $s3, 2      ... shift 2 multiple by 4

 add $t0, $s3, $s6    ... $t0 = address A[i] = A + i

 lw $t0, 0($t0)       ... load A[i] to $t0

 sll $s4, $s4, 2      ... shift 2 multiply by 4

 add $t1, $s4, $s6    ... $t0 address of A[j] = A + j

 lw $t1, 0($t1)       ... load A[i] to $t0

 add $t0, $t0, $t1    ... $t0 = A[i] + A[j]

 sw $t0, 32($s7)      ... $t0 = B[8]


Using in hex using UNSIGNED MAGNITUTE?


Decimal = 234 Decimal = 60125

Binary = 1110 1010 Binary = 1110 1010 1101 1100

Hex = EA Hex = EADD