MIPS Instruction Coding Solved

$24.99 $18.99

Instruction Coding Formats MIPS instructions are classified into four groups according to 3 coding formats, NO Pseudo-instructions or co-processor instructions required in Assignment1&2. R-Type – This group contains all instructions that do not require an immediate value, target offset, memory address displacement, or memory address to specify an operand. This includes arithmetic and logic with…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 votes)

Instruction Coding Formats

MIPS instructions are classified into four groups according to 3 coding formats, NO Pseudo-instructions or co-processor instructions required in Assignment1&2.

R-Type – This group contains all instructions that do not require an immediate value, target offset, memory address displacement, or memory address to specify an operand. This includes arithmetic and logic with all operands in registers, shift instructions, and register direct jump instructions (jalr and jr).

All R-type instructions use opcode 000000.

I-Type – This group includes instructions with an immediate operand, branch instructions, and load and store instructions. In the MIPS architecture, all memory accesses are handled by the main processor, so coprocessor load and store instructions are included in this group.

All opcodes except 000000, 00001x, and 0100xx are used for I-type instructions.

J-Type – This group consists of the two direct jump instructions (j and jal). These instructions require a memory address to specify their operand.

J-type instructions use opcodes 00001x.

Coprocessor Instructions – MIPS processors all have two standard coprocessors, CP0 and CP1. CP0 processes

various kinds of program exceptions. CP1 is a floating point processor. The MIPS architecture makes allowance for future inclusion of two additional coprocessors, CP2 and CP3. All coprocessor instructions use opcodes 0100xx.

Note: ALL arithmetic immediate values are sign-extended. After that, they are handled as signed or unsigned 32-bit numbers, depending upon the instruction. Signed instructions can generate an overflow exception; unsigned cannot.

R-Type Instructions (Opcode 000000)

Main processor instructions that do not require a target address, immediate value, or branch displacement use an R-type

MIPS Instruction Coding 2/19/09 1:56 PM

MIPS Instruction Coding 2/19/09 1:56 PM

MIPS Instruction Coding 2/19/09 1:56 PM

How syscall works?

Recall that you will read in a MIPS file as input in your project 1, and you will need to run the code (Read Project 1 instruction first if you do not understand). In your assembling part, you simply need to put the binary code: 00000000000000000000000000001100 in, all syscalls have the same machine code.

How do we distinguish them then? Syscalls are distinguished by checking the value stored in $v0 register. In your simulation part, when ever you see a syscall made (seeing this binary code: 00000000000000000000000000001100), you simply go and check what is stored in $v0. In other words, you can write a switch, with the value in $v0 being the cases. For each case, you simply implement its functionality. Using print_int as an example, in your case: 1 , you can have printf(“%d”, *a0); . The argument column specifies the arguments this syscall takes (the integer to be printed is stored in $a0, for example).

The input MIPS code format

You will need to consider the following situations while reading the input MIPS file:

  1. There will only be .data and .text sections.

  1. There could be spaces or tabs before and after each line.

3. There could be spaces before and after each element within a line. e.g. add $t0, $t1, $t2 .

  1. There could be empty lines.

  1. There could be comments after the line of code. There could also be a line with only comments. Comments are always following a “#”.

  1. Labels can be followed by a line of code, or can have it’s own line. Labels are labeling the same line of code in both situations.

case1

label: add $t0, $t1, $t2

case2

label:

add $t0, $t1, $t2

The data types you need to support (for project 2)

The data types you need to support are:

  1. ascii

  1. asciiz

  1. word

  1. byte

  1. half

MIPS Instruction Coding Solved
$24.99 $18.99