1: | Four Itanium logical instructions directly correspond to four of the sixteen logical functions in Table 6-1. Write single Itanium instructions that compute some of the other logical functions. |
2: | Suppose that registers r2 and r3 contain the values 0x12345678 and 0x9abcdef0, respectively. What would be the results computed and stored in register r1 by each of the Itanium logical instructions? |
3: | Devise examples to show that andcm r1=r2,r3 does not produce r1 = r2 NAND r3. |
4: | What is the net result of the following instruction sequence?
xor r23=r22,r23 xor r22=r23,r22 xor r23=r22,r23 |
5: | When an immediate value is used in an Itanium logical instruction, state in words what can be said a priori about bits <63:8> of the result for: (a) and, (b) andcm, (c) or, and (d) xor in relation to an unknown pattern in bits <63:8> of the second source operand in a register. |
6: | Make a table, enlarged from Table 6-3, that shows explicitly all the cases for addition of three single-bit operands (A, B, and an incoming carry) to produce two output functions, a sum, and an outgoing carry. Relate this table to the exposition near the end of Section 6.1.6 in the text. |
7: | Consider interleaving the hypothetical Itanium instruction sequences for computing the sum and outgoing carry for a single bit position (Section 6.1.6). What would be the apparent smallest number of clock cycles overall? Show the instruction sequence and any necessary stops. |
8: | Find out how the assembler that you are using responds to an attempt to use a count greater than 63 in register r2 with the all-register forms of Itanium shift instructions. Similarly try to tell the assembler to use a count larger than 63 with the immediate forms of Itanium shift instructions. Describe your findings. |
9: | When the Itanium shr instruction divides an integer value by some power of 2, the remainder is lost. Explain how to compute the remainder using one or more Itanium instructions from this chapter. |
10: | Show that implementation of the shrp instruction is equivalent to a combination of these steps: logical shift right on the contents of register r3 by count6 bit positions, logical shift left on the contents of register r2 by (64–count6) bit positions, and combination of those partial results using logical OR to produce the final result in register r1. |
11: | What explicit sequence of instructions would be necessary:
|
12: | Propose several different short sequences of Itanium instructions that would determine whether register r27 contains:
|
13: | Modify the MAXIMUM program so that it reports both the greatest number found and the index position at which that value occurs in the array num(). |
14: | Complete the task begun at the end of Section 6.5.1 by preparing a full program that multiplies two 64-bit signed integers, N and X. Test thoroughly with different magnitudes and sign combinations. Estimate the figure of merit for the loop body that you use. |
15: | Modify the DECNUM program to handle negative numbers of up to six digits in their base 10 representation. Can you make it issue a leading minus sign if and only if a number is negative? |
16: | A table of consecutive 8-byte memory locations is called PTRTBL. The length of the table (i.e., the number of slots) is unknown, but the contents of each entry in the table is known in advance to be:
Write a routine that passes through PTRTBL only once and counts:
The routine should copy these tallies into quad word locations labeled ACTIVE and TOTAL just before it finishes. Use the following data for the first actual run: PTRTBL: data80, 4000, 0, 0, 0, 0x8ACE642012345678, 5276, -1 Conduct a second run using about a dozen entries of your own. |
17: | Explain why the output of the IO_C program produces one more line of output, if you enter no characters before pushing the return (or enter) key, than when you do supply one or more other characters first. |
18: | Documentation for the C library says that putchar “returns the character written” (unless a system-detected error occurs). Use the debugger to verify this for chrput. |
19: | Why should LEN in the BACKWARD program be no bigger than 213 bytes (admittedly an extreme line length)? |
20: | Adapt BACKWARD to edit a sentence by inserting the word “not” at a predetermined location. |
21: | Combine and adapt relevant portions from SCANTEXT, DECNUM, IO_C, and BACKWARD to build a program that prints on the screen the number of words found in a line of input from the keyboard. |
22: | Write a program that prompts for a decimal number with arbitrarily many digits, and then formats it using commas to set off the digits in groups of three—i.e., according to the standard pattern x,xxx,xxx. You will need to determine the length of the input string of digits. Test all the cases (length modulo 3). |
23: | Many text editors have a Change Case command that will modify selected text by converting A–Z to a–z and a–z to A–Z, while leaving all other ASCII characters unchanged. Write a routine incorporating some Itanium logical instructions that performs this task. Test its operation on several strings and on the following:
"'Why, I don't know Bertha,' Bert said." You will first have to devise a way to store in the .data segment a string that contains quotation marks. The program must not alter spaces and punctuation marks. |
24: | Puzzle solvers know about palindromes, or words that read the same backwards and forwards (RADAR, OTTO).
|
18.117.184.189