Description

Describe the most interesting thing you learned in Chapter 3: MIPS Assembly Part 2

The most interesting topic I learned was 3.5 Machine Instructions. It was also very confusing converting Assembly Language into Machine Language. It was fascinating to be shown how each instruction (lw, sw, add, etc) can be translated into just 0s and 1s. Converting jump/branch instructions was extremely confusing because it is different from the others and requires more manipulation.

Write/ask a question that you have about any topic in Chapter 3. The question can be a question you know the answer to or don’t know.

How do you convert a label from Assembly Language to Machine language for a Jump instruction?

Answer the question in your own words the best you can.

  1. Take the address that you want to jump to (ie. Memory Address 48). Convert that address to binary.
    1. 48 = 110000
  2. Append 0’s to create a 28-bit string.
    1. 0000000000000000000000110000 (28 bits total).
  3. Omit 2 rightmost 0’s to obtain 26 bits.
    1. 0000000000000000000000110000 => 00000000000000000000001100 (26 bits total)
  4. Prepend opcode for jump (000010)
    1. 000010 00000000000000000000001100
  5. Finally, the CPU will append “00” on the right and prepend the j instruction address’s leftmost 4 bits to form 32 bits total.
    1. 0000 00000000000000000000001100 00

I understand everything up until Step 5. I am not sure why it appends the address’s leftmost 4 bits.

1) I think one of the most interesting things we learned in this chapter was about Stack data structures. with Stack data structures come 2 important operations known as push and pop. The push operation inserts an item at the “top” of a stack structure and the pop operation will remove an item from the “top” of the stack and return that item as needed. In assembly language, a program stack is a stack used by a program to store data for subroutines. The direct memory address of the “top” of the program stack is held in a register called the stack pointer ($sp).

2) How many bits are in each machine instruction in MIPS? Convert this Process Instruction into machine instruction addi, $t1, $t3, 10. Hint: convert the opcode (operation code) first, then each register, then the immediate all into binary. (Section 3.5 for opcodes, register codes, and machine instructions formats)

3) 32 bits in each machine instruction. Conversion 001000 01011 01001 0000000000001010

1.In chapter 3: MIPS Assembly Part 2, I learned how computer works behind conditional statements.
bne and beq work to control structure for conditional judgment (if statement) and repetition (for statement, while statement).?In order to create a structure such as repetition and condition judgment, an instruction that can jump to an arbitrary address is required.

2. explain which label would be executed after the jump instruction?
1: j Comp4
2: Comp3: addi $t2, $zero, -5
3: Comp4: sw $t3, 0($t5)

3. On line 1, it labeled comp4 so it will jump to like 3, So, the sw instruction will be executed, and the addi instruction on like 2 won’t be is excuted.
This is a very simple problem but I wanted to typed the its process to make it clearer. You can try with other examples so that you can clarify the process