Skip to main content
deleted 3 characters in body
Source Link
Fabio
  • 41
  • 4
sll $at,  $8,   2   # at = j << 2;
add $at,  $at,  $9  # at = at + &A; (add base adress of A)
lw  $tmp, ($at)     # tmp = A[at];
sll $tmp, $tmp, 6   # tmp = tmp << 6;
sll $at,  $7,   2   # at = i << 2;
add $at,  $at,  $10 # at = at + baseD;&D; (add base adress of D)
sw  $tmp, ($at)     # D[at] = tmp;
sll $at,  $8,   2   # at = j << 2;
add $at,  $at,  $9  # at = at + &A; (add base adress of A)
lw  $tmp, ($at)     # tmp = A[at];
sll $tmp, $tmp, 6   # tmp = tmp << 6;
sll $at,  $7,   2   # at = i << 2;
add $at,  $at,  $10 # at = at + baseD; (add base adress of D)
sw  $tmp, ($at)     # D[at] = tmp;
sll $at,  $8,   2   # at = j << 2;
add $at,  $at,  $9  # at = at + &A; (add base adress of A)
lw  $tmp, ($at)     # tmp = A[at];
sll $tmp, $tmp, 6   # tmp = tmp << 6;
sll $at,  $7,   2   # at = i << 2;
add $at,  $at,  $10 # at = at + &D; (add base adress of D)
sw  $tmp, ($at)     # D[at] = tmp;
added code
Source Link
Fabio
  • 41
  • 4
sll $at,  $8,   2   # at = j << 2;
add $at,  $at,  $9  # at = at + baseA;&A; (add base adress of arrayA)
lw  $tmp, ($at)     # tmp = A[at];
sll $tmp, $tmp, 6   # tmp = tmp << 6;
sll $at,  $7,   2   # at = i << 2;
add $at,  $at,  $10 # at = at + baseD; (add base adress of arrayD)
sw  $tmp, ($at)     # D[at] = tmp;
lw  $at, 20($10)     # at = D[5]; (5 * 4 bytes = 20, base address for D: $10)
sll $at, $at,    2   # at = at << 2;
add $at, $at,    $9  # at = at + baseA;&A; (add base adress of arrayA)
lw  $at, ($at)       # at = A[at];
sub $5,  $6,     $at # f = g - at;
sll $at,  $8,   2   # at = j << 2;
add $at,  $at,  $9  # at = at + baseA; (add base adress of array)
lw  $tmp, ($at)     # tmp = A[at];
sll $tmp, $tmp, 6   # tmp = tmp << 6;
sll $at,  $7,   2   # at = i << 2;
add $at,  $at,  $10 # at = at + baseD; (add base adress of array)
sw  $tmp, ($at)     # D[at] = tmp;
lw  $at, 20($10)     # at = D[5]; (5 * 4 bytes = 20, base address for D: $10)
sll $at, $at,    2   # at = at << 2;
add $at, $at,    $9  # at = at + baseA; (add base adress of array)
lw  $at, ($at)       # at = A[at];
sub $5,  $6,     $at # f = g - at;
sll $at,  $8,   2   # at = j << 2;
add $at,  $at,  $9  # at = at + &A; (add base adress of A)
lw  $tmp, ($at)     # tmp = A[at];
sll $tmp, $tmp, 6   # tmp = tmp << 6;
sll $at,  $7,   2   # at = i << 2;
add $at,  $at,  $10 # at = at + baseD; (add base adress of D)
sw  $tmp, ($at)     # D[at] = tmp;
lw  $at, 20($10)     # at = D[5]; (5 * 4 bytes = 20, base address for D: $10)
sll $at, $at,    2   # at = at << 2;
add $at, $at,    $9  # at = at + &A; (add base adress of A)
lw  $at, ($at)       # at = A[at];
sub $5,  $6,     $at # f = g - at;
added code
Source Link
Fabio
  • 41
  • 4

EDIT: now, that actual code has been posted I will add some too:
a)

subi $5, $0, 20 # f = a - 20
add  $5, $5, $1 # f = f - b
add  $5, $5, $2 # f = f + c
sub  $5, $5, $3 # f = f - d

b)

sll $at,  $8,   2   # at = j << 2;
add $at,  $at,  $9  # at = at + baseA; (add base adress of array)
lw  $tmp, ($at)     # tmp = A[at];
sll $tmp, $tmp, 6   # tmp = tmp << 6;
sll $at,  $7,   2   # at = i << 2;
add $at,  $at,  $10 # at = at + baseD; (add base adress of array)
sw  $tmp, ($at)     # D[at] = tmp;

c)

lw  $at, 20($10)     # at = D[5]; (5 * 4 bytes = 20, base address for D: $10)
sll $at, $at,    2   # at = at << 2;
add $at, $at,    $9  # at = at + baseA; (add base adress of array)
lw  $at, ($at)       # at = A[at];
sub $5,  $6,     $at # f = g - at;

EDIT: now, that actual code has been posted I will add some too:
a)

subi $5, $0, 20 # f = a - 20
add  $5, $5, $1 # f = f - b
add  $5, $5, $2 # f = f + c
sub  $5, $5, $3 # f = f - d

b)

sll $at,  $8,   2   # at = j << 2;
add $at,  $at,  $9  # at = at + baseA; (add base adress of array)
lw  $tmp, ($at)     # tmp = A[at];
sll $tmp, $tmp, 6   # tmp = tmp << 6;
sll $at,  $7,   2   # at = i << 2;
add $at,  $at,  $10 # at = at + baseD; (add base adress of array)
sw  $tmp, ($at)     # D[at] = tmp;

c)

lw  $at, 20($10)     # at = D[5]; (5 * 4 bytes = 20, base address for D: $10)
sll $at, $at,    2   # at = at << 2;
add $at, $at,    $9  # at = at + baseA; (add base adress of array)
lw  $at, ($at)       # at = A[at];
sub $5,  $6,     $at # f = g - at;
completely reformatted after having discovered that there actually is a formatting toolbar, now that my scriptblocker is not blocking it any more!
Source Link
Fabio
  • 41
  • 4
Loading
added 37 characters in body
Source Link
Fabio
  • 41
  • 4
Loading
corrected and added formatting
Source Link
Fabio
  • 41
  • 4
Loading
Source Link
Fabio
  • 41
  • 4
Loading