云南大学 软件学院 大二年级上册学期 专业英语重点及习题总结.pdf

上传人:文*** 文档编号:93811730 上传时间:2023-07-14 格式:PDF 页数:101 大小:15.05MB
返回 下载 相关 举报
云南大学 软件学院 大二年级上册学期 专业英语重点及习题总结.pdf_第1页
第1页 / 共101页
云南大学 软件学院 大二年级上册学期 专业英语重点及习题总结.pdf_第2页
第2页 / 共101页
点击查看更多>>
资源描述

《云南大学 软件学院 大二年级上册学期 专业英语重点及习题总结.pdf》由会员分享,可在线阅读,更多相关《云南大学 软件学院 大二年级上册学期 专业英语重点及习题总结.pdf(101页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、2.1 Perform the following number conversions 十 六 进 制 与 二 进 制 的 转 换)A.0 x39A7F8 to binaryHexadecimal 3 9 A 7 F 8Binary 0011 1001 1010 0111 1111 1000B.Binary 1100100101111011 to hexadecimalBinary 1100 1001 0111 1011Hexadecimal C 9 7 BC.0 xD5E4C to binaryHexadecimal D 5 E 4 cBinary 1101 0101 1110 0100

2、1100D.Binary 1001101110011110110101 to hexadecimalBinary 10 0110 1110 0111 1011 0101Hexadecimal 2 6 E 7 B 52.2 Fill in the blank entries in the following table,giving the decimal and hexadecimalrepresentations of different powers of 2:n 2An(Decimal 十 进 制)2、(Hexadecimal 十 六 进 制)9 512 0 x20019 524,288

3、 0 x8000014 16,384 0 x400016 65,536 0 x1000017 131,072 0 x200005 32 0 x207 128 0 x802.3A single byte can be represented by two hexadecimal digits.Fill in the missing entries in thefollowing table,giving the decimal,binary,and hexadecimal values of different byte patterns:(做 题 认 真 即 可 进 制 之 间 的 转 换)D

4、ecimal Binary Hexadecimal0 0000 0000 0 x00167=10*16+7 10100111 0 xA762=3*16+14 0011 1110 0 x3E188=1 1*16+12 1011 1100 OxBC3*16+7=55 0011 0111 0 x378*16+8=136 1000 1000 0 x8815*16+3=243 mi ooii 0 xF35*16+2=82 0101 0010 0 x5210*1 6+1 2=172 1010 1100 OxAC14*16+7=231 11100111 0 xE72.4 Without converting

5、 the numbers to decimal or binary,try to solve the following arithmeticproblems,giving the answers in hexadecimal.Hint:Just modify the methods you use forperforming decimal addition and subtraction to use base 16.(注 意 给 出 的 数 字 是.进 制 卜 进 制 还 是 十 六 进 制)十 六 进 制 得 写 O xA.0 x503c+0 x8=0 x5044.Adding 8 t

6、o hex c gives 4 with a carry of 1.(进 位 1)B.0 x503c-0 x40=0 x4ffc.Subtracting 4 from 3 in the second digit position requires a borrowfrom the third(借 位 1).Since this digit is 0,we must also borrow from the fourth position.C.0 x503c+64=0 x507c.Decimal 64(26)equals hexadecimal 0 x40.D.0 x50ea-0 x503c=0

7、 xae.To subtract hex c(decimal 12)from hex a(decimal 10),we borrow16 from the second digit,giving hex e(decimal 14).In the second digit,we now subtract 3 fromhex d(decimal 13),giving hex a(decimal 10).2.5Consider the following three calls to show_bytes:(个 内 存 单 元 存 放,个 工 行 8 个 比 特 存 储 有 两 种 方 式:1 小

8、端 法 一-最 低 有 效 字 节 在 最 前 面 2 大 端 法 最 高 有 效 字 节 在 最 前 面)继 续 我 们 前 面 的 示 例,假 设 变 鼠 X 类 型 为 i n i.位 于 地 址 0 x 1 0 0处,有 一 个 十 六 进 制 值 为 0 x01234567o地 址 范 围 0 x100 0 x103的 字 节 顺 序 依 赖 于 机 器 的 类 型:大 端 法 0 x100 0 x101 0 x102 0 x10310 1231 45 67|.小 端 法 0 x100 0 x101 0 x102 0 x10316 71 45 1 23 01 1 注 意,在 字 0

9、x01234567中,高 位 字 节 的 十 六 进 制 值 为 0 x 0 1,而 低 位 字 节 值 为 0 x67。个 字 节 指 针 引 用 一 个 字 节 序 列,其 中 每 个 字 节 都 被 认 为 是 一 个 非 负 整 数。第 一 个 例 程 show_bytes的 输 入 是 个 字 节 序 列 的 地 址(它 用 一 个 字 节 指 针 来 指 示)和 一 个 字 节 数。showj)ytes打 印 出 以 十 六 进 制 表 小 的 字 节。C格 式 化 指 令.2x”表 示 整 数 必 须 用 至 少 两 个 数 字 的 十 六 进 制 格 式 输 出。int val

10、=0 x87654321;byte_pointer valp=(byte_pointer)&val;show_bytes(valp,1);/*A.*/show_bytes(valp,2);/*B.*/show_bytes(valp,3);/*C.*/Indicate which of the following values will be printed by each call on a littleendianmachine and on a big-endian m achine:(小 端:从 低 到 高 大 端:从 高 到 低)A.Little endian:21 Big endia

11、n:87B.Little endian:21 43 Big endian:87 65C.Little endian:21 43 65 Big endian:87 65 432.6Using show_int and show_float,we determine that the integer 3510593 has hexadecimalrepresentation 0 x00359141,while the floating-point number 3510593.0 has hexadecimalrepresentation 0 x4A564504.A.Write the binar

12、y representations of these two hexadecimal values.(用 二 进 制 表 不 这 两 个 卜 六 进 制)Using the notation of the example in the text,we write the two strings as follows:0 0 3 5 9 1 4 100(X)0(X)0 0011 0101 1001 0001 0100 00014 A 5 6 4 5 0 40100 10100101 01100100 0101 0000 0100B.Shift these two strings relative

13、 to one another to maximize the number of matching bits.Howmany bits m atch?(移 动 两 个 二 进 制 串 的 相 对 位 置,使 其 匹 配 位 数 最 多,最 多 是 多 少 位)With the second word shifted two positions to the right relative to the first,we find a sequencewith 21 matching bits.C.What parts of the strings do not match?We find al

14、l bits of the integer embedded in the floating-point number,except for the mostsignificant bit having value 1.Such is the case for the example in the text as well.In addition,thefloating-point number has some nonzero high-order bits that do not match those of the integer.c.税 们 发 现 除 了 累 有 效 佳 1,搂 数

15、的 所 有 他 域 在 浮 点 数 中.这 正 好 也 是 书 中 示 例 的 情 况,另 外,“就 有 一 些 解 的 雕 蒲 整 数 中 的 雕 相 匹 配.2.7 What would be printed as a result of the following call to show_bytes?(show.bytes返 回 指 针 指 向 使 用 字 节 的 最 低 字 节 地 址)const char*s=abcdef”;show_bytes(byte_pointer)s,strlen(s);Note that letters a through z have ASCII co

16、des 0 x61 through 0 x7A.It prints 61 62 63 64 65 66.Recall also that the library routine strlen does not count theterminating null character,and so show_bytes printed only through the character f.2.8 Fill in the following table showing the results of evaluating Boolean operations onbit vectors.Opera

17、tionab a(求 反)ba&b(且)a I b(或)aAb(异 或)Result(运 算 比 较 简 单 认 真 已 经 给 了 编 码 字 节 取 反 即 可)01101(X)1010101011001011010101010010000010111110100111100(同 为()相 同 为 0 不 同 为 1)2.9 Computers generate color pictures on a video screen or liquid crystal display by mixing threedifferent colors of light:red,green,and b

18、lue.Imagine a simple scheme,with three different lights,each of which can be turned on or off,projecting onto a glass screen.计 算 机 生 成 彩 色 照 片 视 频 屏 幕 或 液 晶 显 示 器 通 过 混 合 三 种 不 同 颜 色 的 光 线:红、绿、蓝。想 象 个 简 单 的 计 划,三 个 不 同 的 灯 光,每 种 都 可 以 打 开 或 关 闭,投 射 在 个 玻 璃 屏 幕。We can then create eight different colo

19、rs based on the absence(0)or presence(1)of light sourcesR,G,and B:R G B Color0 0 0 Black0 0 1 Blue0 1 0 Green0 1 1 Cyan1 0 0 Red1 0 1 Magenta1 1 0 Yellow1 1 1 WhiteEach of these colors can be represented as a bit vector of length 3,and we can apply Booleanoperations to them.A.The complement of a col

20、or is formed by turning off the lights that are on and turning on thelights that are off.What would be the complement of each of the eight colors listed above?Colors are complemented by complementing the values of R,G and B.(取 补)From this,we cansee that White is the complement of Black,Yellow is the

21、 complement of Blue,Magenta is thecomplement of Green,and Cyan is the complement of Red.B.Describe the effect of applying Boolean operations on the following colors:(:进 制 的 交 集 或 勺 或 运 算)Blue I Green=Yellow&Cyan=Red A Magenta=Blue(001)I Green(010)=Cyan(Oil)Yellow(110)&Cyan(011)=Green(010)Red(100)A M

22、agenta(101)=Blue(001)2.10As an application of the property that a A a=0 for any bit vector a,consider the followingprogram:1 void inplace_swap(int*x,int*y)2*y=*x 八*y;/*Step 1*/3*x=*x 八*y;/*Step 2*/4*y=*x 八*y;/*Step 3*/5 As the name implies,we claim that the effect of this procedure is to swap the va

23、lues stored at thelocations denoted by pointer variables x and y.Note that unlike the usual technique for swappingtwo values,we do not need a third location to temporarily store one value while we are movingthe other.There is no performance advantage to this way of swapping;it is merely an intellect

24、ualAmusement.Starting with values a and b in the locations pointed to by x and y,respectively,fill in the table thatfollows,giving the values stored at the two locations after each step of the procedure.Use theproperties of A to show that the desired effect is achieved.Recall that every element is i

25、ts ownadditive inverse(that is,a A a=0).(交 换 两 个 数)Step*x*yInitially a bStep 1 a aA bStep 2 a A(a A b)=(a A a)A b=b aA bStep 3 b bA(a A b)=(b A b)A a=a2.11 Armed with the function inplace_swap from Problem 2.10,you decide to write code that willreverse the elements of an array by swapping elements f

26、rom opposite ends of the array,workingtoward the m iddle.(一 个 串 倒 序)You arrive at the following function:1 void reverse_array(int a,int ent)2 int first,last;3 for(first=0,last=cnt-1;4 first=last;5 first+,last)6 inplace_swap(&afirst,&alast);7When you apply your function to an array containing element

27、s 1,2,3,and 4,you find the arraynow has,as expected,elements 4,3,2,and 1.When you try it on an array with elements 1,2,3,4,and 5,however,you are surprised to see that the array now has elements 5,4,0,2,and 1.In fact,you discover that the code always works correctly on arrays of even length,but it se

28、ts the middleelement to 0 whenever the array has odd length.A.For an array of odd length cnt=2k+1,what are the values of variables first and last in the finaliteration of function reverse_array?Both first and last have value k,so we are attempting to swap the middle element with itself.B.Why does th

29、is call to function xor_swap set the array element to 0?In this case,arguments x and y to inplace_swap both point to the same location.When we compute*x A*y,we get O.We then store 0 as the middle element of the array,and the subsequent stepskeep setting this element to 0.C.What simple modification t

30、o the code for reverse_array would eliminate this problem?Simply replace the test in line 4 of reverse_array to be first last,since there is no need to swapthe middle element with itself.2.12Write C expressions,in terms of variable x,for the following values.Your code should workfor any word size w

31、2 8.For reference,we show the result of evaluating the expressions for x=0 x87654321,with w=32.A.The least significant byte of x,with all other bits set to 0.0 x(X)000021.X&OxFFB.All but the least significant byte of x complemented,with the least significant byte leftunchanged.0 x789ABC21.X A 0 xFFC

32、.The least significant byte set to all 1 s,and all other bytes of x left unchanged.0 x876543FF.x IOxFF2.13The Digital Equipment VAX computer was a very popular machine from the late 1970s untilthe late 1980s.Rather than instructions for Boolean operations And and Or,it had instructions bis(bit set)a

33、nd bic(bit clear).Both instructions take a data word x and a mask word m.Theygenerate a result z consisting of the bits of x modified according to the bits of m.With bis,themodification involves setting z to 1 at each bit position where m is l.With bic,the modificationinvolves setting z to 0 at each

34、 bit position where m is 1.To see how these operations relate to the C bit-level operations,assume we have functions bis andbic implementing the bit set and bit clear operations,and that we want to use these to implementfunctions computing bit-wise operations I and A,without using any other C operat

35、ions.Fill in themissing code below.Hint:Write C expressions for the operations bis and bic./*Declarations of functions implementing operations bis and bic*/int bis(int x,int m);int bic(int x,int m);/*Compute xly using only calls to functions bis and bic*/int bool_or(int x,int y)int result=bis(x,y);r

36、eturn result;)/*Compute xAy using only calls to functions bis and bic*/int bool_xor(int x,int y)int result=bis(bic(x,y),bic(y,x);return result;)2.14Suppose that x and y have byte values 0 x66 and 0 x39,respectively.Fill in the following tableindicating the byte values of the different C expressions:

37、Expression Value Expression Valuex&y 0 x20 x&y 0 x01x 1 y 0 x7F xlly 0 x01 x 1 y OxDF!x I I!y 0 x00 x&!y 0 x00 x&y 0 x01(两 个 a n d就 是 表 示 如 果 两 边 都 为 1 结 果 就 是 1 不 都 为 1是 0 如 果 是 数 表 示 为 1 是 0即 是 0)把 数 转 成 0 和 1 然 后 再 做 与 或 的 运 算 结 果 只 有 01 和 002.15 Using only bit-level and logical operations,write

38、a C expression that is equivalent to x=y.In other words,it will return 1 when x and y are equal,and 0 otherwise.The expression is!(X A y).That is,xAy will be zero if and only if every bit of x matches the corresponding bit of y.We thenexploit the ability of!to determine whether a word contains any n

39、onzero bit.2.16 Fill in the table below showing the effects of the different shift operations on single bytequantities.The best way to think about shift operations is to work with binary representations.Convert the initial values to binary,perform the shifts,and then convert back to hexadecimal.Each

40、 of the answers should be 8 binary digits or 2 hexadecimal digits.二 进 制 十 六 进 制 X 3 表 示 讲 数 像 左 移 3 位 高 位 舍 弃 低 位 0 补 齐 X 2 表 示 将 数 向 右 移 2 位 低 位 舍 弃 高 位 0 补 齐 算 数 最 地 位 0 用 0 补 齐 是 1 用 1补 齐 逻 辑 用 0 补 齐 X x 3 x 2(Logical)x 2(Arithmetic)Hex Binary Binary Hex Binary 1 Hex Binary Hex0 xC3 11000011 1000

41、11000 0 x18 00110000 0 x30 11110000 OxFO0 x75 01110101 10101000 0 xA8 00011101 O x ID 0(X)11101 OxlD0 x87 10000111 100111000 0 x38 00100001 0 x21 11100001 OxEl0 x66 01100110 00110000 0 x30 00011001 0 x19 00011001 0 x192.17Assuming w=4,we can assign a numeric value to each possible hexadecimal digit,

42、assumingeither an unsigned or a two s-complement interpretation.Fill in the following table according tothese interpretations by writing out the nonzero powers of two in the summations shown inEquations 2.1 and 2.3:Hexadecimal Binary B2U4(x)B2T4(x)OxE 1H0 2八 3+2八 2+2八 1=14-2八 3+2八 2+2八 1二-20 x0 0000

43、 0 00 x5 0101 2A2+2A0=5 2A2+2A0=50 x8 1000 2八 3 二 8-2A3=-8OxD 1101 2A3+2A2+2A0=13-2A3+2A2+2A0=-3OxF1H12八 3+2八 2+2八 1+2 0=15-2八 3+2八 2+2八 1+2八 0=-1无 符 号 的 二 进 制”,Tw-1-7 3 2*1+2 七 2 B2Uw(x)=2,1=0i=02.18In Chapter 3,we will look at listings generated by a disassembler,a program that converts anexecutab

44、le program file back to a more readable ASCII form.These files contain manyhexadecimal numbers,typically representing values in two scomplement form.Being able torecognize these numbers and understand their significance(for example,whether they arenegative or positive)is an important skill.For the l

45、ines labeled A-J(on the right)in the following listing,convert the hexadecimal values(in 32-bit two,s-complement form)shown to the right of the instruction names(sub,mov,and add)into their decimal equivalents:(把 右 边 的 十 六 进 制 的 数 转 为 十 进 制 数,注 意 正 负)8048337:81 ec b8 0100 00 sub$0 xlb8,%esp A.4408048

46、33d:8b 55 08 mov 0 x8(%ebp),%edx8048340:83 c2 14 add$0 xl4,%edx B.208048343:8b 85 58 fe ffff mov 0 xfffffe58(%ebp),%eax C.-4248048349:03 02 add(%edx),%eax804834b:89 85 74 fe ff ff mov%eax,0 xfffffe74(%ebp)D.-3968048351:8b 55 08 mov 0 x8(%ebp),%edx8048354:83 c2 44 add$0 x44,%edx E.688048357:8 b 8 5 c

47、 8 fe ffff mov 0 xfffffec8(%ebp),%eax F.-312804835d:89 02 mov%eax,(%edx)804835f:8b 45 10 mov 0 x_10(%ebp),%eax G 168048362:03 45 0c add 0 xc(%ebp),%eax H.128048365:89 85 ec fe ff ff mov%eax,0 x fffffeec(%ebp)I.276804836b:8b 45 08 mov 0 x8(%ebp),%eax804836e:83 cO 20 add$0 x20,%eax J.328048371:8b 00 m

48、ov(%eax),%eax2.19 Using the table you filled in when solving Problem 2.17,fill in the following table describingthe function T2U4:X T2U4(x)x(hex)-8 8 ox8-3 13 oxd-2 14 oxe-1 15 oxf0 0 oxO5 5 ox5函 数 72U x)士 82U W(T28W(X)生 成 一 个 无 符 号 数,(如 果 是 负 数 T2U4后 的 结 果 绝 对 值 相 加 为 1 6 如 果 是 正 数 结 果 不 变)B2UT2BW(

49、*)=T2UW(x)=几 0+x叫(X)=,x+2*.x 02.20 Explain how Equation 2.6 applies to the entries in the table you generated when solvingProblem 2.19.For the first four entries,the values of x are negative and T2U4(x)=x+2A4.For theremaining two entries,the values of x are nonnegative and T2U4(x)=x.2.21 Assuming th

50、e expressions are evaluated on a 32-bit machine that uses two scomplementarithmetic,fill in the following table describing the effect of casting and relational operations,inthe style of Figure 2.18:(一 般 情 况 下 带 U 的 表 示 不 带 符 号 如 果 大 小 关 系 满 足 为 1 不 满 足 结 果 为 0)Expression Type Evaluation-2147483647-1

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 教案示例

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com