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
For the MIPS assembly instructions below, what is the corresponding C statement? Assume that the variables...
For the MIPS assembly instructions below, what is the corresponding C statement? Assume that the variables f, g, h, and I are assigned to registers $s0 - $s3, respectively. Assume that the base address of arrays X, Y, and Z are in registers $s4 - $s6, respectively. Be conservative and use a single temp register as possible. It is a C arithmetic command with two source operands and a destination. Each part is 3 points. Add $t0, $s0, $s1 addi...
2.     Explain each line of the following MIPS assembly language code segment. Write the corresponding C...
2.     Explain each line of the following MIPS assembly language code segment. Write the corresponding C language code and indicate the content of each register with the corresponding variable in C-code. muli $t2, $s1, 4    add $t2, $t4, $t2    lw $t15, 0($t2)    lw $t16, 4($t2)    sw $t16, 0($t2)    sw $t15, 4($t2)
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...
1a. Using the MIPS program below (with bugs intact), determine the instruction format for each instruction...
1a. Using the MIPS program below (with bugs intact), determine the instruction format for each instruction and write the decimal values of each instruction field. addi $v0, $zero, 0 loop: lw $v1, 0($a0) sw $v1, 0($a1) sll $a0, $a0, 2 add $a1, $a1, $a0 beq $v1, $zero, loop 1b. Translate the following C/Java code to MIPS assembly code. Assume that the values of a, i, and j are in registers $s0, $t0, and $t1, respectively. Assume that register $s2 holds...
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
Consider the following C statement:           a = (b + d) + (b – c) +...
Consider the following C statement:           a = (b + d) + (b – c) + (c + d) Which of the following assembly instructions can be used to replicate all or part of this statement in MIPS, without changing or reducing the equation. Assume variables a, b, c, and d are assigned to registers $s0, $s1, $s2 and $s3 respectively. sub $t0, $s2, $s3 sub $t0, $s0, $s3 sub $t1, $s1, $s2 add $t2, $s1, $s3 add $t2, $s0,...
(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)...
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?
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...
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
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT