{"id":1450,"date":"2015-05-13T12:10:26","date_gmt":"2015-05-13T19:10:26","guid":{"rendered":"http:\/\/sites.evergreen.edu\/compcog15\/?page_id=1450"},"modified":"2015-05-13T12:10:26","modified_gmt":"2015-05-13T19:10:26","slug":"ch-14-answers","status":"publish","type":"page","link":"https:\/\/sites.evergreen.edu\/compcog15\/ch-14-answers\/","title":{"rendered":"Ch 14 Answers"},"content":{"rendered":"<p>14.1<br \/>\nA Balanced Introduction to Computer Science, 3\/E<br \/>\nDavid Reed \u00a9Pearson Prentice Hall, 2011<br \/>\nChapter 14 Review Question Solutions<br \/>\n14.1. What would happen if you placed the number 100 in R0, then set the knobs so that A<br \/>\nBus = R0, B Bus = R0, ALU = A-B, and C Bus = R0?<br \/>\nThe value in Register 0 would be subtracted from itself and the result, 0, stored back<br \/>\ninto Register 0.<br \/>\n14.2. Describe the settings that would cause the value stored in R2 to be doubled.<br \/>\nA Bus = R2, B Bus = R2, ALU = A+B, and C Bus = R2.<br \/>\n14.3. How many cycles are required to add the contents of R0, R1, and R2 and then place<br \/>\nthe sum in R3? Describe the settings for each cycle.<br \/>\nA Bus = R0, B Bus = R1, ALU = A+B, C Bus = R3.<br \/>\nA Bus = R2, B Bus = R3, ALU = A+B, C Bus = R3.<br \/>\n14.4. What settings would result in the sum of registers R0 and R3 being stored in memory<br \/>\nlocation 4?<br \/>\nA Bus = R0, B Bus = R3, ALU = A+B, C Bus connected to MM, R\/W = 4.<br \/>\n14.5. What settings would cause the contents of memory address 4 to be copied into<br \/>\nregister R0?<br \/>\nMM Bus connected to C, C Bus = R0, R\/W = 4.<br \/>\n14.6. Assuming that data can be copied to and from main memory in a single CPU cycle,<br \/>\nhow many cycles are required to add the contents of memory addresses 5 and 6 and<br \/>\nthen store the result in memory address 7? Describe the settings for each cycle.<br \/>\nMM Bus connected to C, C Bus = R0, R\/W = 5.<br \/>\nMM Bus connected to C, C Bus = R1, R\/W = 6.<br \/>\nA Bus = R0, B Bus = R1, ALU = A+B, C Bus connected to MM, R\/W = 7.<br \/>\n14.7. What task would the following machine-language program perform?<br \/>\n0: 1010001000000000<br \/>\n1: 1000001000000011<br \/>\n14.2<br \/>\n2: 1111111111111111<br \/>\nThis program stores the value 0 in memory address 3. The first statement subtracts<br \/>\nthe value in R0 from itself, and stores the result (0) back in R0. The second statement<br \/>\nstores the value from R0 in MM[3]. The third statement halts execution.<br \/>\n14.8. What sequence of machine-language instructions would cause the contents of the four<br \/>\nregisters to be copied into memory locations 7, 8, 9, and 10, respectively?<br \/>\n1000001000000111<br \/>\n1000001000101000<br \/>\n1000001001001001<br \/>\n1000001001101010<br \/>\n1111111111111111<br \/>\n14.9. What sequence of machine-language instructions would cause the simulator to add<br \/>\nthe contents of memory locations 10, 11, and 12 and then store the result in memory<br \/>\nlocation 13?<br \/>\n1000000100001010<br \/>\n1000000100101011<br \/>\n1000000101001100<br \/>\n1010000100110001<br \/>\n1010000100111011<br \/>\n1000001001101101<br \/>\n1111111111111111<br \/>\n14.10. What do you think would happen if you forgot to place a HALT instruction at the end<br \/>\nof a machine-language program? How would the Control Unit react? Use the<br \/>\nsimulator to test your prediction, then report the results.<br \/>\nThe Program Counter would advance beyond the last instruction. The contents of<br \/>\nmemory addresses would be treated as instruction codes, either producing unexpected<br \/>\nresults or an error if the code does not correspond to a legal instruction.<br \/>\n14.11. What sequence of assembly-language instructions corresponds to the machinelanguage<br \/>\ninstruction set from Exercise 14.7?<br \/>\nSUB R0 R0 R0<br \/>\nSTORE 3 R0<br \/>\nHALT<br \/>\n14.12. What sequence of assembly-language instructions corresponds to the machinelanguage<br \/>\ninstruction set you wrote in Exercise 14.9?<br \/>\nLOAD R0 10<br \/>\nLOAD R1 11<br \/>\nLOAD R2 12<br \/>\n14.3<br \/>\nADD R3 R0 R1<br \/>\nADD R3 R2 R3<br \/>\nSTORE 13 R3<br \/>\nHALT<br \/>\n14.13. Write a sequence of assembly-language instructions that multiplies the contents of<br \/>\nmemory location 10 by four. For example, if the number 10 were stored in memory<br \/>\nlocation 10, executing your instructions would cause the simulator to store 40 there.<br \/>\nNote: although the ALU Operation knob does not provide a multiplication setting, a<br \/>\nnumber can be multiplied via repeated additions (e.g., 10* 4 = 10+10+10+10).<br \/>\nLOAD R0 10<br \/>\nADD R0 R0 R0<br \/>\nADD R0 R0 R0<br \/>\nSTORE 10 R0<br \/>\nHALT<br \/>\n1. TRUE or FALSE? Any piece of memory that is used to store the sum of numeric values<br \/>\nis known as a register.<br \/>\nFALSE<br \/>\n2. TRUE or FALSE? The path that data follows within the CPU, traveling along buses<br \/>\nfrom registers to the ALU and then back to registers, is known as the CPU datapath.<br \/>\nTRUE<br \/>\n3. TRUE or FALSE? All modern CPUs provide the same set of basic operations that can be<br \/>\nexecuted in a single CPU cycle.<br \/>\nFALSE<br \/>\n4. TRUE or FALSE? The size of main memory is generally measured in MHz or GHz.<br \/>\nFALSE<br \/>\n5. TRUE or FALSE? Suppose you wish to add two numbers that are stored in memory.<br \/>\nBefore the Arithmetic Logic Unit (ALU) can add the numbers, they must first be<br \/>\ntransferred to registers within the CPU.<br \/>\nTRUE<br \/>\n14.4<br \/>\n6. TRUE or FALSE? In real computers, it takes roughly the same amount of time to<br \/>\ntransfer data from main memory to registers as it does to add two numbers in registers.<br \/>\nFALSE<br \/>\n7. TRUE or FALSE? Within the CPU, the Control Unit is responsible for fetching<br \/>\nmachine-language instructions from memory, interpreting their meaning, and carrying<br \/>\nout the specified CPU cycles.<br \/>\nTRUE<br \/>\n8. TRUE or FALSE? Suppose a CPU contains eight registers. Within a machine-language<br \/>\ninstruction, at least three bits would be required to uniquely identify one of the registers.<br \/>\nTRUE<br \/>\n9. TRUE or FALSE? In a multitasking computer, the program counter keeps track of how<br \/>\nmany programs are currently loaded into main memory.<br \/>\nFALSE<br \/>\n10. TRUE or FALSE? In a stored-program computer, both machine-language instructions<br \/>\nand the data operated on by those instructions can reside in main memory at the same<br \/>\ntime.<br \/>\nFALSE<br \/>\n11. Name the three subunits of the CPU, and describe the role of each subunit in carrying out<br \/>\ncomputations.<br \/>\nThe arithmetic logic unit (ALU) is the collection of circuitry that performs actual<br \/>\noperations on data. Registers are memory locations that are built into the CPU and<br \/>\naccessed directly by the ALU. The control unit is the circuitry in charge of fetching data<br \/>\nand instructions from main memory, as well as controlling the flow of data from the<br \/>\nregisters to the ALU and back to the registers.<br \/>\n12. Describe how data values move around the CPU datapath and what actions occur during<br \/>\na single CPU cycle. How does the datapath relate to CPU speed?<br \/>\nThe path that data follows within the CPU, traveling along buses from registers to the<br \/>\nALU and then back to registers, is known as the CPU datapath. Every task performed by<br \/>\na computer, from formatting a document to displaying a page in a Web browser, is<br \/>\nbroken down into sequences of simple operations; the computer executes each individual<br \/>\noperation by moving data from the registers to the ALU, performing computations on that<br \/>\n14.5<br \/>\ndata within the ALU, and then storing the result in the registers. CPU speed measure<br \/>\nhow many such cycles occur in one second, e.g., 1.8 GHz means 1.8 billion CPU cycles<br \/>\nper second.<br \/>\n13. Consider two computer systems that are identical except for their CPUs. System 1<br \/>\ncontains a 1.8 GHz Pentium 4, whereas System 2 contains a 1.8 GHz PowerPC processor.<br \/>\nWill these two systems always require the same amount of time to execute a given<br \/>\nprogram? Justify your answer.<br \/>\nCPU speed is generally measured in gigahertz (GHz), which indicates how many billions<br \/>\nof CPU cycles occur in a second. Since different families of CPUs will different basic<br \/>\noperations using different hardware configurations, some tasks may require more cycles<br \/>\nusing one CPU when compared with another. Thus, performance comparisons based on<br \/>\nCPU speed are not always accurate.<br \/>\n14. Consider the following tasks: (1) adding 100 numbers stored in main memory, and (2)<br \/>\nadding a number to itself 100 times. Although both tasks require 100 additions, the<br \/>\nsecond would be executed much more quickly than the first would. Why?<br \/>\nFor the first task, the 100 numbers must each be loaded into registers from main memory<br \/>\nbefore the additions can take place. Thus, 100 memory loads and 99 additions must take<br \/>\nplace. For the second task, only one number must be loaded from memory, before<br \/>\nadditions can take place. Thus, 1 memory load and 99 additions must take place.<br \/>\n15. Machine languages are machine-specific, meaning that each type of computer has its own<br \/>\nmachine language. Explain why this is the case.<br \/>\nMachine language instructions correspond to the low-level operations that can be<br \/>\nexecuted by the hardware of the machine. Since different computers have different<br \/>\nCPUS, register configurations, and ALU operations, their machine languages will differ.<br \/>\n16. Within the control unit, what is the role of the program counter (PC)? That is, how is the<br \/>\nPC used in fetching and executing instructions?<br \/>\nThe program counter (PC) keeps track of the address of the next program instruction to<br \/>\nbe executed. Initially set to the first instruction in the program, it is automatically<br \/>\nincremented as each instruction is loaded, decoded by the control unit, and executed.<br \/>\n17. In a stored-program computer, both instructions and data are stored in main memory.<br \/>\nHow does the Control Unit know where the program instructions begin? How does it<br \/>\nknow where the instructions end?<br \/>\nIn real computers, the starting location for programs is usually maintained by the<br \/>\noperating system, which keeps track of each program in memory and its location. The<br \/>\n14.6<br \/>\nend of a program is usually marked by a special instruction that tells the control unit to<br \/>\nHALT.<br \/>\n18. Describe two advantages of assembly languages over machine languages.<br \/>\nIt is much easier for programmers to remember and understand assembly-language<br \/>\ninstructions than patterns of 0s and 1s. Furthermore, most assembly languages support the<br \/>\nuse of variable names, enabling programmers to specify memory locations by descriptive<br \/>\nnames, rather than by numerical addresses.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>14.1 A Balanced Introduction to Computer Science, 3\/E David Reed \u00a9Pearson Prentice Hall, 2011 Chapter 14 Review Question Solutions 14.1. What would happen if you placed the number 100 in R0, then set the knobs so that A Bus = R0, B Bus = R0, ALU = A-B, and C Bus = R0? The value [&hellip;]<\/p>\n","protected":false},"author":274,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"open","template":"","meta":{"_mi_skip_tracking":false},"_links":{"self":[{"href":"https:\/\/sites.evergreen.edu\/compcog15\/wp-json\/wp\/v2\/pages\/1450"}],"collection":[{"href":"https:\/\/sites.evergreen.edu\/compcog15\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/sites.evergreen.edu\/compcog15\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/sites.evergreen.edu\/compcog15\/wp-json\/wp\/v2\/users\/274"}],"replies":[{"embeddable":true,"href":"https:\/\/sites.evergreen.edu\/compcog15\/wp-json\/wp\/v2\/comments?post=1450"}],"version-history":[{"count":0,"href":"https:\/\/sites.evergreen.edu\/compcog15\/wp-json\/wp\/v2\/pages\/1450\/revisions"}],"wp:attachment":[{"href":"https:\/\/sites.evergreen.edu\/compcog15\/wp-json\/wp\/v2\/media?parent=1450"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}