FAQ

Answers to frequently asked questions are posted here.

 

SPIM:
S1. I'm trying to run the the saved LabA1.s in my pc on the pcSpim. When I try to run the 'Go', I get the default prompt for the starting setup.  I want to accept the default but, the message that I recieve says:
Please enter and address or symbol at which to begin execution, or,  leave blank to begin at the default address of 0x00000000
I click OK but I don't see any output in the Console. What could be the problem asI didn't have any problem with this on the prism labs?

A1. You need to enter the starting address of the MIPS code that you have loaded. Typically it is the first entry in the left most column of the text segment (2nd window from the top). In most cases, the starting address is 0x00400000 but it can also be different. Try 0x00400000 as the starting address and see if it works. If it does not, then check the address from the first entry in the in the left most column of the text segment.

MIPS Programming

No questions as of now.

 

Lab B:
B1. I need a hint to solve LabB3. What logic to use in it?
B1. For LabB3.s, you split 18 as a sum of 2 and 16. For example, you can express (18 × y) as
18 × y = 2 × y + 16 × y

where y is any integer. Now you use two shift instructions, one to perform the multiplication (2 × y) and the other to perform the multiplication (16 × y). Add the two results to get your final result.

Lab D:
D1. Lab D assumes that we have an overall understanding of the notions of endianess? What is endianess?
D1. Big-endian and little-endian refers to the way in which a word (4 bytes) is stored on a machine. Recall that words must start at addresses that are multiples of 4 (By the way, this requirement is called the word alignment restriction). So, if we have to store the word 0x23456789 in the memory, we have two options for storing the word. We can store the most significant byte (23) at the smallest address, followed by 45 at the next higher address, then by 67, and finally by 89. In terms of the starting address (say 0x00200000), the storage of word 0x23456789 will be

Address                  Byte
0x00200003           89
0x00200002           67
0x00200001           45
0x00200000           23

This type of storage is called big endian since we are storing the most significant byte at the smallest address. Conversely, on the little endian machines, the least significant byte is stored at the smallest address as follows:

Address                  Byte
0x00200003           23
0x00200002           45
0x00200001           67
0x00200000           89

D2. The program gives a syntax error with the code provided in Lab D1.s. What should I do?
D2. Please replace the third instruction

b:      .byte 23

with

b1:     .byte 23

D3. Why is SPIM following little-endian format although MIPS is big-endian?
D2. The byte order of SPIM is the same as the byte order of the underlying machine on which the simulator is running. Since Intel 80x86 is little-endian, therefore, SPIM inherits the same little-endian format.

D4. How is the machine language code (0x08100013) for the jump instruction (j fini)calculated in Lab D2?
Note that the last three lines of the code is translated as

[0x00400044] 0x08100013 j 0x0040004c [fini] ;   19: j fini

[0x00400048] 0x2002fffb addi $2, $0, -5 ;       20: addi $v0,$0, -5

[0x0040004c] 0x03e00008 jr $31 ;                21: jr $ra

 

where the (jr $ra) with address is the destination for the  (j fini) instruction.

 

The machine code format for the jump instruction is

 

Opcode (6 bits)

Destination Address Field (26 bits)

 

The opcode for jump (j) instruction is 0x02 or 000010 in binary, which fills the opcode field. The destination address for the jump instruction is obtained by specifying the number of words to the address of the destination instruction. In other terms, this implies dividing the destination address (0x0040004c) by 4, which gives 0x00100013 or 0000 0000 0001 0000 0000 0000 0001 0011. Since only 26 bits can be saved in the address field, so the most significant 6-bits are ignored. This leaves the destination address field to become 00 0001 0000 0000 0000 0001 0011 as filled below

Opcode (6 bits)

Destination Address Field (26 bits)

0000 10

00 0001 0000 0000 0000 0001 0011


Expressing the aforementioned 32 bits in hexadecimal format, we get 0x08100013, which is the opcode for the (j fini) instruction.

To further practice, replace the (j fini) instruction with the (bne $t0, $a0, fini) instruction and derive the machine code for the new instruction.