MIPS Relocation Table: List Instructions

  • Thread starter ElijahRockers
  • Start date
  • Tags
    Mips Table
In summary: I think I got it. I think related addresses (like home and office) don't need to be in the relocation table because they will be addressed by the program constantly. However, absolute addresses (like my dorm room number) do need to be in the table, because the program might not know where they are at all.
  • #1
ElijahRockers
Gold Member
270
10

Homework Statement



List instructions that will contribute an entry to the relocation table.

1 funca:
2 la $t0 , n
3 lw $s0 , 0( $t0 )
4 addi $s2 , $zero , 1
5 sub $s1 , $s1 , $s1
6 loop:
7 sll $t0 , $s2 , 3 1
8 slt $t1 , $t0 , $z e ro
9 bne $t1 , $zero , skip
10 add $s1 , $s1 , $s2
11 skip:
12 addi $s2 , $s2 , 1
13 beq $s2 , $s0 , done
14 j loop
15 done:
16 addi $v0 , $s1 , 0
17 j r $ra
18
19 n: .word 11

The Attempt at a Solution



lines 1, 6, 11, 15, 19...

This is a shot in the dark. the summer class I am taking is sort of off-step between lab and lecture. I've tried google, and searching the book thoroughly but I'm still not exactly sure when the relocation table is considered having an entry contributed. I know that related addresses may not need to, but that absolute addresses would. I haven't seen any solid rules to go by yet though.

Thanks.
 
Physics news on Phys.org
  • #3
I went through that pdf already, actually, and just now again.

It has some examples in chapter 9 of what might constitute a relocation entry, but frankly I am not an experienced enough MIPS programmer to make heads or tails of WHY those are valid examples. Chapter 11 was also not much help - much of that document is intended to be used as a reference for experienced MIPS programmers, which I am definitely not. We are in week 3, and are very soon going to be starting into verilog, which I have much more experience with than MIPS.

It's obvious my answers in the above post are incorrect, but I wouldn't know how to change them.
 
  • #4
Sorry I can't be of more help. I've done a small amount of MIPS programming, but I'm in no way an expert. The link I found was by doing a web search for mips "relocation table", which gave me a lot of hits. One of them might be more helpful than the one I gave.

If not, I suggest talking with your instructor during office hours. If you go to him, explain that you have done put in an effort by reading the text and searching on the web, to no avail.
 
  • #5
Exactly what I Google searched for. I'm in lab right now, and I have talked to my TA about it. I think I am getting the idea.

lines 2 and lines 14 are the only ones that require an entry, since they need to be translated into a 32 bit absolute address. The other instructions, like that on line 9, don't require an absolute value, rather they are relational and specify a certain number of lines of code to jump to in the positive or negative direction.

This is my understanding of it after talking with the TA.

edit: Thanks for your help!
 
Last edited:

What is the MIPS relocation table?

The MIPS relocation table is a data structure used in the MIPS assembly language to store information about the location of instructions and data within a program. It is used by the linker to properly relocate the program when it is loaded into memory.

Why is a relocation table necessary in MIPS?

A relocation table is necessary in MIPS because the program's instructions and data may not always be loaded into the same memory location when it is executed. The relocation table allows the program to be loaded into any memory location, and the linker will use the information in the table to adjust the program's addresses accordingly.

How does the MIPS relocation table work?

The MIPS relocation table contains entries for each instruction or data item that needs to be relocated. Each entry includes the original address of the item and the amount that needs to be added to the address to adjust it for the new memory location. When the program is loaded into memory, the linker will use the information in the table to make the necessary adjustments.

What is the format of the MIPS relocation table?

The MIPS relocation table is typically stored in the program's executable file and is organized into a table or list structure. Each entry in the table contains the original address and the relocation amount, and the entries are usually sorted in ascending order by address.

Can the MIPS relocation table be modified?

Yes, the MIPS relocation table can be modified by the linker during the linking process. The linker may add or remove entries in the table based on the instructions and data used in the program, and it may also modify the relocation amounts to account for any changes in memory layout.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
6K
  • Programming and Computer Science
Replies
1
Views
8K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
9K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
5K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
16K
Back
Top