Question

Question: Write down the corresponding MIPS machine language of the following assembly language code. lw $S0,...

Question:

Write down the corresponding MIPS machine language of the following assembly language code.

lw $S0, 64($S1)

add $t0,$S0,$S1

sub $t1,$S3,$S4

sw $t1,100($S1)

addi $S4,$S6,100

Homework Answers

Answer #1

The machine code of mips instruction is of 32 bit. The converstions and machine codes are as below

1) lw $S0, 64($S1)

Syntax:

lw $t, offset($s)

Encoding:

1000 11ss ssst tttt iiii iiii iiii iiii

$s = $S1 = 17 = 10001

$t = $S0 = 16 = 10000

Offset = 64 = 0000000001000000

Machine code = 1000 1110 0011 0000 0000 0000 0100 0000 = 0x8E300040

So the machine code according to above is 0x8E300040

2) add $t0,$S0,$S1

Syntax:

add $d, $s, $t

Encoding:

0000 00ss ssst tttt dddd d000 0010 0000

$s = $S0 = 16 = 10000

$t = $S1 = 17 = 10001

$d = $t0 = 8 = 01000

Machine code = 0000 0010 0001 0001 0100 0000 0010 0000 = 0x02114020

So the machine code according to above is 0x02114020

3) sub $t1,$S3,$S4

Syntax:

sub $d, $s, $t

Encoding:

0000 00ss ssst tttt dddd d000 0010 0010

$s = $S3 = 19 = 10011

$t = $S4 = 20 = 10100

$d = $t1 = 9 = 01001

Machine code = 0000 0010 0111 0100 0100 1000 0010 0010 = 0x02744822

So the machine code according to above is 0x02744822

4) sw $t1,100($S1)

Syntax:

sw $t, offset($s)

Encoding:

1010 11ss ssst tttt iiii iiii iiii iiii

$s = $S1 = 17 = 10001

$t = $t1 = 19 = 01001

Offset = 100 = 0000000001100100

Machine code = 1010 1110 0010 1001 0000 0000 0110 0100 = 0xAE290064

So the machine code according to above is 0xAE290064

5) addi $S4,$S6,100

Syntax:

addi $t, $s, imm

Encoding:

0010 00ss ssst tttt iiii iiii iiii iiii

$s = $S6 = 22 = 10110

$t = $S4 = 20 = 10100

Offset = 100 = 0000000001100100

Machine code = 0010 0010 1101 0100 0000 0000 0110 0100 = 0x22D40064

So the machine code according to above is 0x22D40064

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
This is a homework assignment for Computer Architecture and some question use MIPS Assembly language. 1.    ...
This is a homework assignment for Computer Architecture and some question use MIPS Assembly language. 1.     In the following MIPS assembly code, translate all the instructions to their corresponding machine code in hexadecimal format. This code is stored in the memory from address 0x1fff0000. Loop: sw $t1, 4($s0)        addi $t1, $t1, -1    sll $t1, $t1, 2        bne $t1, $s5, Exit    addi $s0, $s0, 4          j Loop Exit: … 2.     Find the MIPS...
(MIPS Assembly Language): Assume the following piece of MIPS code: label1: .text 0x4000fc lui $t0, 1022...
(MIPS Assembly Language): Assume the following piece of MIPS code: label1: .text 0x4000fc lui $t0, 1022 ori $t0, $t0, 2048 srl $t1, $t0, 18 sw $t0, 101($t1) slti $t2, $t1, 5 beq $t2, $0, label3 label2:... ... label3:... a) The code modifies a word in memory at the following address (circle one): (i) 1022 (ii) 101 (iii) 5 (iv) 10220000 (v) Other (provide your own answer): _________________ b) The following value is stored in memory (circle one): (i) 0x17 (ii)...
I'm trying to write a nested loop in Mips Assembly that prints out, for example, if...
I'm trying to write a nested loop in Mips Assembly that prints out, for example, if user input x was 5: 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 (spaces in between) So far my code is : li $v0, 5   #Ask for integer syscall move $t5, $v0 addi $t0, $zero, 0 For1:    slt $t1, $t0, $t5    beq $t1, $zero, Exit    add $s0, $s0, $t0    addi $t0, $t0, 1...
Consider the following MIPS assembly instructions: andi $s0, $t1, 65 a) What will be the machine...
Consider the following MIPS assembly instructions: andi $s0, $t1, 65 a) What will be the machine code for the assembler instruction? Justify the answer and state it in hexadecimal form. b) In which building blocks in the processor are the pieces in the machine code for the assembler instruction above used?
Loop unroll the following MIPS code loop 4 times. Write the resulting code including any re-ordering...
Loop unroll the following MIPS code loop 4 times. Write the resulting code including any re-ordering necessary for maximum performance. loop: sw $zero, 0($s0) addi $s0, $s0, -4 bne $s0, $zero, loop
(MIPS Assembly Language): Write the following sequence of code using *native* MIPS instructions: x = x...
(MIPS Assembly Language): Write the following sequence of code using *native* MIPS instructions: x = x - y[0] + y[1]; In memory x, y are stored beginning at 0x010000cc. Use registers $s1 for x,  and $s2 for the base address of y. Make sure your code includes all necessary declarations such that it could run in SPIM.
Convert the following assembly language statement into hex representation: lw $T3, 16($S0) Convert the following hex...
Convert the following assembly language statement into hex representation: lw $T3, 16($S0) Convert the following hex representation into a MIPS assembly language statement. 016A8022 hex
We assume the following $s0 = a $s1 = b $s2 = c $s3 = i...
We assume the following $s0 = a $s1 = b $s2 = c $s3 = i $s4 = address of ar[0] Write MIPS assembly code for the following C code. for (i = 10; i < 30; i ++) { if ((ar[i] > b) || (ar[i] <= c)) ar[i] = 0; else ar[i] = a; }
In MIPS assembly, write an assembly language version of the following C code segment: int A[100],...
In MIPS assembly, write an assembly language version of the following C code segment: int A[100], B[100]; for (i=1; i < 100; i++) { A[i] = A[i-1] + B[i]; }
Consider the following MIPS code and a 5 stages processor as discussed in class, and assume...
Consider the following MIPS code and a 5 stages processor as discussed in class, and assume the loop executes 3 times: loop: lw r1,4(r7) lw r2,8(r7) lw r3,12(r7) add r1,r1, r3 sw r1,4(r7) bne r1,r2,loop addi r1,r1,42 c. Draw the execution diagram. (10 points) d. The CPI (cycles per instruction) is obtained by computing the ratio of total cycles to number of instructions. Compute the CPI for the for the pipeline on this code. (5 points)
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT