NEED A PERFECT PAPER? PLACE YOUR FIRST ORDER AND SAVE 15% USING COUPON:

Lifters & Loaders

[ad_1]

Assume the text segment begins at 0040 000016, the data segment
begins at 1000 000016, and the global pointer currently contains 1000 800016 You’ll see two object
files below, Object File 1 and Object File 2. Your task here will be to play the role of the linker
and link these two files together into the resulting executable file. The format for the executable
is provided for you on the third page and the gray squares are the ones you’ll have to fill-in with
resolved memory addresses, etc. I recommend printing the 3 pages out so you can refer to them
easily. If you have any questions, let me know! Odds are we’ll be discussing this in Office Hours
for Week 11 so please join! -J. Kovba
Object File 1 Header
Name Procedure A
Text Size 30016
Data Size 6016
Text Segment Address Instruction
0 lw $a0,X($gp) # depends on X
4 jal B # depends on B
… …
Data Segment 0 (X)
… …
Relocation
Information
Address Instruction Type Dependency
0 lw X
4 jal B
Symbol Table Label Address
X –
B –
Object File 2 Header
Name Procedure B
Text Size 10016
Data Size 2016
Text Segment Address Instruction
0 sw $a1, Y($gp) # depends on Y
4 jal A # depends on A
… …
Data Segment 0 (Y)
… …
Relocation
Information
Address Instruction Type Dependency
0 sw Y
4 jal A
Symbol Table Label Address
Y –
A –
Executable File
Header
Text Size 400 # total combined text
size
Data Size 80 # total combined data
size
Address
Text Segment _ _ _ _ _ _ _ 16 (the memory address for Procedure A’s lw instruction) lw $a0, X($gp) X = _ _ _16

where X is the

offset relative to the
global pointer register
to get to X in the data
segment
_ _ _ _ _ _ _ 16 (the memory address for Procedure A’s jal instruction) jal B _ _ _ _ _ _ _16

where B is the

(pseudo-direct)
address of Procedure
B in the text segment

0040 030016
(the memory address
for Procedure B’s lw
instruction)
sw $a1, Y($gp)
Y = _ _ _ _16

where Y is the

offset relative to the
global pointer register
to get to Y in the data
segment
0040 030416
(the memory address
for Procedure B’s jal
instruction)
jal A
_ _ _ _ _ _ _ _16

where A is the

(pseudo-direct)
address of Procedure
A in the text segment

Data Segment Address
_ _ _ _ _ _ _ 16 X # the location of X in the data section _ _ _ _ _ _ _16 Y # the location of Y in
the data section
Error Types
For each of the C code snippets below, tell which of the following errors exist: scanner, syntax,
semantic, linker, or if there is no error. Note: some snippets may contain multiple types of
errors. Please be sure to list all types of warning/errors you find. You might find it helpful to
compile your code to identify any warnings/errors: https://repl.it/languages/c
C Code Error(s)

include

int main()
{
printf(“Today is the $d’th day of April.”, day);
}
int main(void) {
int -i = 0;
}

include

int main(void) {
int i = -0;
printf(“i = %f”, i)
}

include

int main(void) {
bool loop = true;
while(loop)
printf(“Hello, world!n”);
}
}

include

int main(void) {
do until(i == 10)
{
printf(“Hello, world!n”);
i++;
}
}

include

int main(void) {
int i = 0;

do
{
printf(“Hello, world!n”);
++i;
} while(i == 10)
}

Sample Solution

The post Lifters & Loaders appeared first on acestar tutors.

[ad_2]

Source link

Looking for this or a Similar Assignment? Click below to Place your Order