Computer Systems: A Programmer's Perspective (3rd Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
3rd Edition
ISBN: 9780134092669
Author: Bryant, Randal E. Bryant, David R. O'Hallaron, David R., Randal E.; O'Hallaron, Bryant/O'hallaron
Publisher: PEARSON
Expert Solution & Answer
Book Icon
Chapter 7, Problem 7.12HW

A.

Explanation of Solution

Computing the value of the relocated reference to “swap” in the “callq” instruction:

From the given question, the function “swap” in object file “m.o” is

9: e8 00 00 00 00callqe<main+oxe>

From the given question,

r.offset=0xar.symbol=swapr.type=R_X86_64_PC32r.addend=-4

And then value of “ADDR(.text)” is “0x4004e0” and value of “ADDR(swap)” is “0x4004f8”.

  • ADDR(s)=ADDR(.text)=0x4004e0
    • Here “ADDR” means run-time addresses for each section.
  • ADDR(r.symbol)=ADDR(swap)=0x4004f8

Compute the run time address of the references using the formula of “refaddr = ADDR(s) + r.offset”

refaddr=ADDR(s)+r

B.

Explanation of Solution

Computing the value of the relocated reference to “swap” in the “callq” instruction:

From the given question, the function “swap” in object file “m.o” is

9: e8 00 00 00 00callqe<main+oxe>

From the given question,

From the given question,

r.offset=0xar.symbol=swapr.type=R_X86_64_PC32r.addend=-4

And then value of “ADDR(.text)” is “0x4004d0” and value of “ADDR(swap)” is “0x400500”.

  • ADDR(s)=ADDR(.text)=0x4004d0
    • Here “ADDR” means run-time addresses for each section.
  • ADDR(r.symbol)=ADDR(swap)=0x400500

Compute the run time address of the references using the formula of “refaddr = ADDR(s) + r.offset”

refaddr=ADDR(s)+r

Blurred answer
Students have asked these similar questions
Q2: Besides the while-loop in Q1, I want to implement a 2nd while-loop running in parallel with the first while: while(1) { wt(1); XX); } However, on an MCU there is no parallelism. (For ex., on Arduino I can define only one loop() function.) Write a single while that does the job of both whiles. (a) Write it in a procedural style. (b) Write it the super-loop style (state-machine with fixed heartbeat).
2. Create a program that prints "CS2253" using the TRAP instruction (opcode 1111) and trap vector x22 (see Table A.3 on page 675). for the string should start at address x6000 and the program should start at address x3000. The data Note that you can load multiple .bin files into the simulator. can contain your program at address x3000, and the other can contain your data, at address x6000. One Your program should not make any assumptions about what values are initially in R0 to R7 when it starts to run. Screen shot required.
Computer science
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr