Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Suppose we are generating code for an imperative language on a machine with 8 - byte floating - point numbers, 4 - byte integers, 1
Suppose we are generating code for an imperative language on a machine with byte floatingpoint numbers, byte integers, byte characters, and byte alignment for both integers and floatingpoint numbers. Suppose further that we plan to use contiguous rowmajor layout for multidimensional arrays, that we do not wish to reorder fields of records or pack either records or arrays, and that we will assume without checking that all array subscripts are in bounds.
a Consider the following variable declarations:
A : array of real
i : integer
x : real
Show the code that our compiler should generate for the following as signment: x : Ai Explain how you arrived at your answer.
b Consider the following more complex declarations:
r : record
x : integer
y : char
A : array of record
z : real
B : array of char
j k : integer
Assume that these declarations are local to the current subroutine. Note the lower bounds on indices in A; the first element is A
Describe how r would be laid out in memory. Then show code to load rAjBk into a register. Be sure to indicate which portions of the address calculation could be performed at compile time.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started