欢迎来到天天文库
浏览记录
ID:52428992
大小:325.16 KB
页数:89页
时间:2020-03-27
《深入理解计算机系统 第二版 课后习题答案 pdf.pdf》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、ComputerSystems:AProgrammer'sPerspectiveInstructor'sSolutionManual1RandalE.BryantDavidR.O'HallaronDecember4,20031Copyright c2003,R.E.Bryant,D.R.O'Hallaron.Allrightsreserved.2Chapter1SolutionstoHomeworkProblemsThetextusestwodifferentkindsofexercises: PracticeProblems.Theseareproblems
2、thatareincorporateddirectlyintothetext,withexplanatorysolutionsattheendofeachchapter.Ourintentionisthatstudentswillworkontheseproblemsastheyreadthebook.Eachonehighlightssomeparticularconcept. HomeworkProblems.Thesearefoundattheendofeachchapter.Theyvaryincomplexityfromsimpledrillstom
3、ulti-weeklabsandaredesignedforinstructorstogiveasassignmentsortouseasrecitationexamples.Thisdocumentgivesthesolutionstothehomeworkproblems.1.1Chapter1:ATourofComputerSystems1.2Chapter2:RepresentingandManipulatingInformationProblem2.40Solution:Thisexerciseshouldbeastraightforwardvari
4、ationontheexistingcode.code/data/show-ans.c1voidshow_short(shortintx)2{3show_bytes((byte_pointer)&x,sizeof(shortint));4}56voidshow_long(longintx)7{8show_bytes((byte_pointer)&x,sizeof(long));9}12CHAPTER1.SOLUTIONSTOHOMEWORKPROBLEMS1011voidshow_double(doublex)12{13show_bytes((byte_poi
5、nter)&x,sizeof(double));14}code/data/show-ans.cProblem2.41Solution:Therearemanywaystosolvethisproblem.Thebasicideaistocreatesomemultibytedatumwithdifferentvaluesforthemostandleast-significantbytes.Wethenreadbyte0anddeterminewhichbyteitis.Inthefollowingsolutionistocreateanintwithvalue
6、1.Wethenaccessitsfirstbyteandconvertittoanint.Thisbytewillequal0onabig-endianmachineand1onalittle-endianmachine.code/data/show-ans.c1intis_little_endian(void)2{3/*MSB=0,LSB=1*/4intx=1;56/*ReturnMSBwhenbig-endian,LSBwhenlittle-endian*/7return(int)(*(char*)&x);8}code/data/show-ans.cPro
7、blem2.42Solution:Thisisasimpleexerciseinmaskingandbitmanipulation.Itisimportanttomentionthat˜0xFFisawaytogenerateamaskthatselectsallbuttheleastsignificantbytethatworksforanywordsize.(x&0xFF)
8、(y&˜0xFF)Problem2.43Solution:Theseexercisesrequirethinkingaboutthelogicaloperation!inanontrad
9、itionalway.Normally
此文档下载收益归作者所有