Exercises

1:

With reference to Figure 7-1, do you think a debugger program might well provide some access to stack storage marked "out of scope" or "unknown" or both in order to assist an application programmer? Repeat for a core dump analyzer utility in order to assist someone who is checking the behavior of a new operating system.

2:

Explain why a different choice of stacked flag value would have to be used in the DECNUM2 program if the values of the digits were first stored on the stack and were not converted into ASCII characters until later, in the store section of the program. Suggest a suitable flag value. How would the loop control instructions have to be altered? Would they be less efficient?

3:

Identify all the changes that would be necessary in the DECNUM2 program if we wanted to use the other convention of a stack that builds toward decreasing addresses.

4:

Adapt the DECNUM2 program to display its results using chrput. You should store a newline character at the end of the generated string of digits. Also, even though this would no longer be a leaf procedure, it can be brought into conformance with the spirit of programming conventions if you restore the ar.lc register at the appropriate juncture.

5:

How many physical registers would be required in a SPARC implementation having the maximum number of register windows?

6:

What are the chief differences between SPARC register windows and the Itanium register stack?

7:

What are the restrictions on the use of registers r8r11 (ret0r3) for scratch purposes within a given routine if it contains one of the following?

  1. No procedure calls

  2. Calls to other routines

  3. Recursive calls to itself

8:

Take the DECNUM2 program apart in a different manner: A shell program, DECNUM4, calls a function, DIV10, that returns a quotient in register r8 and a remainder in register r9 when it divides its single argument by 10. Put the DOT8 factor in the data segment of the function.

9:

Describe all the changes that would be necessary if the RANDOM function were to be redesigned to receive arguments from its caller by reference rather than by value.

10:

On what (approximate) date will the number of seconds since 00:00 on January 1, 1970, as it used to be maintained in all Unix systems as a 32-bit quantity, first become negative in the two's complement sense? Will the 64-bit number of 100-ns time units since 00:00 on November 17, 1858, as maintained in OpenVMS systems, become negative in the two's complement sense first?

11:

Devise a satisfactory instruction or sequence of instructions to pass in a register as one of the first eight arguments:

  1. 34

  2. 34

  3. r5

  4. [r5]

  5. label in data section.

12:

Explain how one might proceed to implement in Itanium assembly language, as a callable function returning a numeric code, the following case structure expressed in a Pascal-like pseudocode:

 CASE Char OF ' '                                : It_is := 0 (a space); '0'..'9'                           : It_is := 1 (a numeral); 'A','E','I','O','U'                : It_is := 2 (a vowel); 'A'..'Z'                           : It_is := 3 (a letter); OTHERWISE                          : It_is := 4 (punctuation); END 

Assume uppercase input. Consult your instructor to inquire whether you are expected to write just the central portion for the case structure, a complete function, or also a calling program for actual testing.

13:

Write an assembly language procedure INTSORT(List,N) that sorts a list of N quad words stored at address List. Assume a relatively small N and use a simple algorithm, such as an insertion sort. Pass List by reference and N by value from a main program written in a high-level language of your choice, for testing.

14:

Write an assembly language function and test it from a main program written in a high-level language of your choice. State clearly how arguments to the function are to be passed into the function. Pass a quad word result back in register r8. Select one of the following:

  1. Function P(N,R) that calculates the number of permutations of N things taken R at a time,

    P(N,R) = N * (N 1) * ... * (N R+1) assuming 0 R N.

  2. Function GCD(X,Y) that calculates the greatest common divisor of two positive quad word integers X and Y using the algorithm

    while X Y do replace X by |X Y| and replace Y by MIN(X,Y).

  3. Function LOW(List,N) that finds the lowest value in a list of N signed quad word integers.

  4. Function POS_LOW(List,N) that returns the index location (counting from zero) where the lowest value occurs in a list of N quad word integers.

15:

(Advanced, and related more closely to software than processor architecture) Consult the Itanium Software Conventions and Runtime Architecture Guide and then use the debugger to show that the call to a C library function is accomplished via a "stub procedure."



ItaniumR Architecture for Programmers. Understanding 64-Bit Processors and EPIC Principles
ItaniumR Architecture for Programmers. Understanding 64-Bit Processors and EPIC Principles
ISBN: N/A
EAN: N/A
Year: 2003
Pages: 223

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net