New Semester
Started
Get
50% OFF
Study Help!
--h --m --s
Claim Now
Question Answers
Textbooks
Find textbooks, questions and answers
Oops, something went wrong!
Change your search query and then try again
S
Books
FREE
Study Help
Expert Questions
Accounting
General Management
Mathematics
Finance
Organizational Behaviour
Law
Physics
Operating System
Management Leadership
Sociology
Programming
Marketing
Database
Computer Network
Economics
Textbooks Solutions
Accounting
Managerial Accounting
Management Leadership
Cost Accounting
Statistics
Business Law
Corporate Finance
Finance
Economics
Auditing
Tutors
Online Tutors
Find a Tutor
Hire a Tutor
Become a Tutor
AI Tutor
AI Study Planner
NEW
Sell Books
Search
Search
Sign In
Register
study help
business
principles algorithms and systems
Computer Systems 5th Edition J Stanley Warford - Solutions
13. Translate the following C program to Pep/9 assembly language.#include int main() {char ch;scanf("%c", &ch);if ((ch >= 'A') && (ch = 'a') && (ch
12. Translate the following C program to Pep/9 assembly language.#include const int limit = 5;int main() {int number;scanf("%d", &number);while (number < limit) {number++;printf("%d ", number);}return 0;}
11. Translate the following C program to Pep/9 assembly language.#include int main() {int number;scanf("%d", &number);if (number % 2 == 0) {printf("Even");}else {printf("Odd");}return 0;}
10. What are the translation rules for accessing the field of a node pointed to by a global pointer?
9. Section 6.4 does not show how to access an element from a two-dimensional array. Describe how a two-dimensional array might be stored and the assembly language object code that would be necessary to access an element from it.
8. In the Pep/9 program of Figure 6.40, if you enter 4 for Guess, what statement executes after the branch at 0010? Why?
7. Figure 6.26 is the run-time stack just after the second return. Draw the run-time stack, as in that figure, that corresponds to the time just before the second return.
6. Draw the values just before and just after the second CALL at 001C of Figure 6.18 executes, as they are drawn in Figure 6.19.
5. Read the papers by Bohm and Jacopini and by Dijkstra that are referred to in this chapter and write a summary of them.
4. Discover the function of the mystery program of Figure 6.16, and state in one short sentence what it does.
3. The object code for Figure 6.14 has a CPWA at 000C to test the value of j. Because the program branches to that instruction from the bottom of the loop, why doesn’t the compiler generate an LDWA j,d at that point before CPA?
2. What is an optimizing compiler? When would you want to use one? When would you not want to use one? Explain.
1. Explain the difference in the C memory model between global and local variables. How is each allocated and accessed?
31. Write an assembly language program that corresponds to the following C program:int num;int main () {scanf("%d", &num);num = num % 16;printf("num = %d", num);return 0;}
30. Write an assembly language program that corresponds to the following C program:int num;int main () {scanf("%d", &num);num = num / 16;printf("num = %d", num);return 0;}
29. Write an assembly language program that corresponds to the following C program:int num1;int num2;int main () {scanf("%d", &num1);num2 = -num1;printf("num1 = %d", num1);printf("num2 = %d", num2);return 0;}
28. Write an assembly language program that corresponds to the following C program:char ch;int main () {scanf("%c", &ch);ch--;printf("%c", ch);return 0;}
27. Write an assembly language program that corresponds to the following C program:int width;int length;int perim;int main () {scanf("%d %d", &width, &length);perim = (width + length) * 2;printf("width = %d", width);printf("length = %d", length);printf("perim = %d", perim);return 0;}
26. Write an assembly language program that corresponds to the following C program:const int amount = 20000;int num;int sum;int main () {scanf("%d", &num);sum = num + amount;printf("sum = %d", sum);return 0;}Test your program twice. The first time, enter a value for num to make the sum within the
25. Write an assembly language program that corresponds to the following C program:const char chConst = 'a';char ch1;char ch2;int main () {scanf("%c%c", &ch1, &ch2);printf("%c%c%c", ch1, chConst, ch2);return 0;}
24. Write an assembly language program that corresponds to the following C program:int num1;int num2;int main () {scanf("%d %d", &num1, &num2);printf("%d%d", num2, num1);return 0;}
23. Write an assembly language program that prints your first name on the screen. Use immediate addressing with a hexadecimal constant to designate the operand of LDBA for each letter of your name.
22. Write an assembly language program that prints your first name on the screen. Use immediate addressing with a decimal constant to designate the operand of LDBA for each letter of your name.
21. Write an assembly language program that prints your first name on the screen. Use immediate addressing with a character constant to designate the operand of LDBA for each letter of your name.
20. Write an assembly language program that prints your first name on the screen. Use the .ASCII pseudo-op to store the characters at the bottom of your program. Use the LDBA instruction with direct addressing to output the characters from the string. The name you print must contain more than two
18. How does a C compiler enforce type compatibility?
17. How are the symbol table of an assembler and a compiler similar? How do they differ?
16. In the following code, determine the value of the symbol this. Predict and explain the output of the assembly language program:this: DECO this,d STOP.END
15. In the following code, determine the value of the symbol this. Predict and explain the output of the assembly language program:this: HEXO this,d STOP.END
14. In the following code, determine the values of the symbols this, that, and theOther. Write the object code in hexadecimal. (Do not predict the output.)BR theOther this: .WORD 17 that: .WORD 19 theOther: DECO this,d DECO that,d STOP.END
13. In the following code, determine the values of the symbols here and there. Write the object code in hexadecimal. (Do not predict the output.)BR there here: .WORD 9 there: DECO here,d STOP.END
12. Determine the object code and predict the output of the following assembly language programs:*(a)DECO 'm',i LDBA '',i STBA 0xFC16,d DECO "mm",i LDBA '',i STBA 0xFC16,d LDBA 0x0026,i STBA 0xFC16,d STOP.END(b)DECO 'Q',i LDBA '',i STBA 0xFC16,d DECO 0xFFC3,i LDBA '',i STBA 0xFC16,d LDBA 0x007D,i
11. Predict the output of the program in Figure 5.13 if the dot commands are changed to.WORD 0xFE63 ;First.BYTE 0x00 ;Second.BYTE 'b' ;Third.WORD 1401 ;Fourth
10. Predict the output of the program in Figure 5.13 if the dot commands are changed to.WORD 0xFFC7 ;First.BYTE 0x00 ;Second.BYTE 'H' ;Third.WORD 873 ;Fourth
9. Predict the output of the following assembly language program if the input is g. Predict the output if the input is A. Explain the difference between the two results:LDBA 0xFC15,d ANDA 0x000A,d STBA 0xFC16,d STOP.WORD 0x00DF.END
8. Predict the output of the following assembly language program:LDBA 0x000E,d STBA 0xFC16,d LDBA 0x000D,d STBA 0xFC16,d STOP.ASCII "is".END
7. Predict the output of the following assembly language program:LDBA 0x0015,d STBA 0xFC16,d LDBA 0x0014,d STBA 0xFC16,d LDBA 0x0013,d STBA 0xFC16,d STOP.ASCII "gum".END
6. Convert the following assembly language pseudo-ops into hexadecimal machine language:(a) .BYTE 13(b) .ASCII "Frog\x00"(c) .WORD -6
5. Convert the following assembly language pseudo-ops into hexadecimal machine language:(a) .ASCII "Bear\x00"(b) .BYTE 0xF8(c) .WORD 790
4. Convert the following assembly language instructions into hexadecimal machine language:(a) ADDA 0x01FE,i(b) STRO 0x000D,sf(c) LDWX 0x01FF,s
3. Convert the following assembly language instructions into hexadecimal machine language:(a) ASLA(b) DECI 0x000F,s(c) BRNE 0x01E6,i
2. Convert the following machine language instructions into assembly language, assuming that they were not generated by pseudo-ops:(a) 82B7DE(b) 04 (c) DF63DF
1. Convert the following machine language instructions into assembly language, assuming that they were not generated by pseudo-ops:(a) 9AEF2A(b) 03(c) D7003D
73. Using the declarations as in Problem 72, write the function void decToBase(int baseNum[], int decNum)to convert the nonnegative decimal integer to the unsigned number in the arbitrary base.Write the function void putNumber(const int baseNum[])to output the unsigned number in the arbitrary base.
72. Write a program in C to convert an unsigned number in an arbitrary base to a nonnegative decimal integer. For four-digit base 6 numbers, for example, declare const int base = 6;const int numDigits = 4;int number[numDigits];Write the function void getNumber(int num[])to input the unsigned number
71. Defining a hexadecimal number as in Problem 67, write the function void decToHex(int hex[], int dec)to convert a signed decimal integer to a four-digit hexadecimal number. Do not output the hexadecimal number in the function. Test your function with interactive input.
70. Defining a hexadecimal number as in Problem 67, write the function int hexToDec(const int hexNum[])to convert a four-digit hexadecimal number to a signed decimal integer. Do not output the decimal integer in the function. Test your function with interactive input.
69. Defining a hexadecimal number as in Problem 67, write the function void decToHex(int hexNum[], int decNum)to convert a nonnegative decimal integer to a four-digit hexadecimal number. Do not output the hexadecimal number in the function. Test your function with interactive input.
68. Defining a hexadecimal number as in Problem 67, write the function int hexToDec(const int hexNum[])to convert a four-digit hexadecimal number to a nonnegative decimal integer. Do not output the decimal integer in the function. Test your function with interactive input.
67. Write a program in C that takes as input a four-digit hexadecimal number and prints the next 10 hexadecimal numbers. Define a hexadecimal number as int hexNum[4]Allow upper- or lowercase letters for input and use uppercase letters for the hexadecimal output. For example, 3C6f should be valid
66. Write the function for Problem 65 renamed shiftRight(), using the arithmetic shift right operation.
65. Defining a binary number as in Problem 57, write the function void shiftLeft(int binNum[], int *cBit)to perform an arithmetic shift left on binNum. cBit should be the value of the carry bit after the shift. Do not output the shifted number or the carry bit in the function. Test your function
64. Write the void function for Problem 63 renamed as binaryOr() using the OR operation.
63. Defining bAnd, bin1, and bin2 as binary numbers as in Problem 57, write the void function void binaryAnd(int bAnd[], const int bin1[], const int bin2[])to compute bAnd as the AND of the two binary numbers bin1 and bin2. Do not output the binary number in the function. Test your function with
62. Defining a binary number as in Problem 57, write the function void decToBin(int bin[], int dec)to convert a signed decimal integer to an eight-bit two’s complement binary number. Do not output the binary number in the function. Test your function with interactive input.
61. Defining a binary number as in Problem 57, write the function int binToDec (const int bin[])to convert an eight-bit two’s complement binary number to a signed decimal integer. Do not output the decimal integer in the function. Test your function with interactive input.
60. Defining sum, bin1, and bin2 as binary numbers as in Problem 57, write the void function void binaryAdd(int sum[], int *cBit, const int bin1[], const int bin2[])to compute sum as the sum of the two binary numbers, bin1 and bin2. cBit should be the value of the carry bit after the addition. Do
59. Defining a binary number as in Problem 57, write the function void decToBin(int bin[], int dec)to convert a nonnegative decimal integer to an eight-bit unsigned binary number. Do not output the binary number in the function. Test your function with interactive input.
58. Defining a binary number as in Problem 57, write the function int binToDec(const int bin[])to convert an eight-bit unsigned binary number to a nonnegative decimal integer. Do not output the decimal integer in the function. Test your function with interactive input.
57. Write a program in C that takes as input an 8-bit binary number and prints the next 10 binary numbers. Define a binary number as int binNum[8];Use binNum[0] to store the most significant (i.e., leftmost) bit and binNum[7] to store the least significant bit. Ask the user to input the first
56. Write a program in C that takes as input a 4-digit octal number and prints the next 10 octal numbers. Define an octal number as int octNum[4];Use octNum[0] to store the most significant (i.e., leftmost) octal digit and octNum[3] to store the least significant octal digit. Test your program with
55. For IEEE 754 double-precision floating point, write the hexadecimal representation for(a) positive zero(b) the smallest positive denormalized number(c) the largest positive denormalized number(d) the smallest positive normalized number(e) 1.0(f) the largest positive normalized number(g)
54. For IEEE 754 single-precision floating point, write the hexadecimal representation for(a) positive zero(b) the smallest positive denormalized number(c) the largest positive denormalized number(d) the smallest positive normalized number(e) 1.0(f) the largest positive normalized number(g)
53. For IEEE 754 single-precision floating point, what is the number, as written in binary scientific notation, whose hexadecimal representation is the following?*(a) 4280 0000(b) B350 0000(c) 0061 0000(d) FF80 0000(e) 7FE4 0000(f) 8000 0000
52. For IEEE 754 single-precision floating point, write the hexadecimal representation for the following decimal values:(a) 27.1015625(b) –1.0(c) – 0.0(d) 0.5(e) 0.6(f) 256.015625
51. Assuming a three-bit exponent field and a four-bit significand, what decimal values are represented by the following bit patterns?*(a) 0 010 1101(b) 1 101 0110(c) 1 111 1001(d) 0 001 0011(e) 1 000 0100(f) 0 111 0000
50. Assuming a three-bit exponent field and a four-bit significand, write the bit pattern for the following decimal values:*(a) –12.5(b) 13.0(c) 0.43(d) 0.1015625
49. (a) With excess 7 representation, what is the range of numbers as written in binary and in decimal for a four-bit cell? (b) With excess 15 representation, what is the range of numbers as written in binary and in decimal for a five-bit cell? (c) With excess 2n–1 –1 representation, what is
48. Construct a table similar to Figure 3.33 that compares all the values with a four-bit cell for excess 7 and two’s complement representation.
47. Convert the following numbers from decimal to binary:(a) 12.28125(b) 0.0234375(c) 0.7
46. Convert the following numbers from decimal to binary:(a) 13.15625(b) 0.0390625(c) 0.6
45. Convert the following numbers from binary to decimal:(a) 101.101001(b) 0.000101(c) 1.0
44. Convert the following numbers from binary to decimal:(a) 110.101001(b) 0.000011(c) 1.0
43. Octal numbers are sometimes used instead of hexadecimal numbers to represent bit sequences.*(a) How many bits does one octal number represent?How would you represent the decimal number –13 in octal with the following cells?(b) A 15-bit cell(c) A 16-bit cell(d) An 8-bit cell
42. You are the chief communications officer for the Lower Slobovian army at war with the Upper Slobovians. Your spies will infiltrate the enemy’s command headquarters in an attempt to gain the “upper” hand. You know the Uppers are planning a major assault, and you also know the following:
41. Decode the following UTF-8 words:(a) 56 6F 69 C3 A0(b) 4B C3 A4 73 65(c) 70 C3 A2 74 65
40. Convert the following Unicode code points to UTF-8:*(a) U+0542, Armenian(b) U+2873, Braille Pattern(c) U+4EB6, CJK Unified(d) U+13007, Egyptian Hieroglyphics
39. How is the following string of 13 characters stored in ASCII?(321)497–0015
38. How is the following string of nine characters stored in ASCII?Pay $0.92
36. Decode the following secret ASCII message (reading across):100 1000 110 0001 111 0110 110 0101 010 0000 110 0001 010 0000 110 1110 110 1001 110 0011 110 0101 010 0000 110 0100 110 0001 111 1001 010 0001 37. Decode the following secret ASCII message (reading across):100 1101 110 0101 110 0101
35. Assuming nine-bit two’s complement binary representation, write the bit patterns for the following decimal numbers in hexadecimal:(a) –73(b) –1(c) 94
34. Assuming seven-bit two’s complement binary representation, write the bit patterns for the following decimal numbers in hexadecimal:(a) –27(b) 63(c) –1
33. Assuming nine-bit two’s complement binary representation, convert the following numbers from hexadecimal to decimal. Remember to check the sign bit:(a) 1B4(b) 0F5(c) 100
32. Assuming seven-bit two’s complement binary representation, convert the following numbers from hexadecimal to decimal. Remember to check the sign bit:(a) 5D(b) 2F(c) 40
31. The technique for converting from decimal to any base will work, with some modification, for bases other than binary. (a) Explain the method to convert from decimal to octal. (b)Explain the method to convert from decimal to base n in general.
30. This chapter mentions the method of converting from decimal to hexadecimal but gives no examples. Use the method to convert the following decimal numbers to hexadecimal:*(a) 26,831(b) 4096(c) 9
29. Convert the following numbers from hexadecimal to decimal:*(a) 2D5E(b) 2F(c) 7
28. Count the next five numbers in hexadecimal, starting with the following:*(a) 3AB7(b) 6FD(c) B9E
27. (a) Write the RTL specification for a rotate right on an eight-bit cell.(b) Write the RTL specification for a rotate left on an eight-bit cell.
26. Assuming a nine-bit cell, show the effect of the rotate operation on each of the following values with the given initial value of C:(a) C = 1, ROL 0 0110 1101(b) C = 0, ROL 0 0110 1101(c) C = 1, ROR 0 0110 1101(d) C = 0, ROR 0 0110 1101
25. Assuming a seven-bit cell, show the effect of the rotate operation on each of the following values with the given initial value of C:(a) C = 1, ROL 010 1101(b) C = 0, ROL 010 1101(c) C = 1, ROR 010 1101(d) C = 0, ROR 010 1101
24. (a) Write the RTL specification for an arithmetic shift right on an eight-bit cell. (b) Write the RTL specification for an arithmetic shift left on an eight-bit cell.
23. Assuming nine-bit two’s complement representation, convert each of the following decimal numbers to binary, show the effect of the ASL operation on it, and then convert the result back to decimal. Repeat with the ASR operation:(a) 94(b) 135(c) – 62(d) 1(e) 0(f) –1
Assuming seven-bit two’s complement representation, convert each of the following decimal numbers to binary, show the effect of the ASL operation on it, and then convert the result back to decimal. Repeat with the ASR operation: (a) 24(b) 37(c) –26(d) 1(e) 0(f) –1
19. With two’s complement binary representation, what is the range of numbers as written in binary and in decimal notation for the following cells?*(a) a two-bit cell*(b) a three-bit cell(c) a four-bit cell(d) a five-bit cell(e) an n-bit cell in general
16. Convert the following numbers from binary to decimal, assuming nine-bit two’s complement binary representation:(a) 0 0001 1010(b) 1 0110 1010(c) 1 1111 1100(d) 0 0000 0001(e) 1 0000 0000(f) 1 0000 0001
15. Convert the following numbers from binary to decimal, assuming seven-bit two’s complement binary representation:(a) 001 1101(b) 101 0101(c) 111 1100(d) 000 0001(e) 100 0000(f) 100 0001
14. Convert the following numbers from decimal to binary, assuming nine-bit two’s complement binary representation:(a) 51(b) –29(c) –2(d) 0(e) –256(f) –1(g) What is the range for this cell as written in binary and in decimal?
13. Convert the following numbers from decimal to binary, assuming seven-bit two’s complement binary representation:(a) 49(b) –27(c) 0(d) –64(e) –1(f) –2 (g) What is the range for this computer as written in binary and in decimal?
12. Why do programmers at Level ISA3 confuse Halloween and Christmas? Hint: What does 31(oct) equal?
Showing 400 - 500
of 640
1
2
3
4
5
6
7
Step by Step Answers