03~solutions_for_chapter_3_exercises
更新时间:2023-05-15 17:00:01 阅读量: 实用文档 文档下载
- 搜书大师推荐度:
- 相关推荐
Solutions for Chapter 3 Exercises1
Solutions for Chapter 3 Exercises
3.10000 0000 0000 0000 0001 0000 0000 0000two3.21111 1111 1111 1111 1111 1000 0000 0001two3.31111 1111 1110 0001 0111 1011 1000 0000two3.4–250ten3.5–17ten
3.62147483631ten3.7
addu $t2, $zero, $t3 # copy $t3 into $t2
bgez $t3, next # if $t3 >= 0 then done
sub $t2, $zero, $t3 # negate $t3 and place into $t2Next:
3.9The problem is that A_lower will be sign-extended and then added to $t0.
The solution is to adjust A_upper by adding 1 to it if the most significant bit ofA_lower is a 1. As an example, consider 6-bit two’s complement and the address23 = 010111. If we split it up, we notice that A_lower is 111 and will be sign-extended to 111111 = –1 during the arithmetic calculation. A_upper_adjusted= 011000 = 24 (we added 1 to 010 and the lower bits are all 0s). The calculation isthen 24 + –1 = 23.
3.10Either the instruction sequence
addu $t2, $t3, $t4sltu $t2, $t2, $t4
or
addu $t2, $t3, $t4sltu $t2, $t2, $t3
works.
3.12To detect whether $s0 < $s1, it’s tempting to subtract them and look at the
sign of the result. This idea is problematic, because if the subtraction results in anoverflow, an exception would occur! To overcome this, there are two possiblemethods: You can subtract them as unsigned numbers (which never produces anexception) and then check to see whether overflow would have occurred. Thismethod is acceptable, but it is lengthy and does more work than necessary. Analternative would be to check signs. Overflow can occur if $s0 and (–$s1) share
2Solutions for Chapter 3 Exercises
the same sign; that is, if $s0 and $s1 differ in sign. But in that case, we don’t needto subtract them since the negative one is obviously the smaller! The solution inpseudocode would be
if ($s0<0) and ($s1>0) then
$t0:=1
else if ($s0>0) and ($s1<0) then
$t0:=0
else
$t1:=$s0–$s1 if ($t1<0) then $t0:=1else
$t0:=0
3.13Here is the equation:
Sum = (a b CarryIn) + (a b CarryIn)
CarryIn
a
Sum
Solutions for Chapter 3 Exercises3
3.23
One example of 6-bit operands that run faster when Booth’s algorithm looks at 3bits at a time is 21ten × 27ten = 567ten.Two-bit Booth’s algorithm:
010101 × 011011 – 010101000000+ 010101– 010101000000+ 010101= 21ten= 27ten
10 string (always start with padding 0 to right of LSB)11 string, middle of a string of 1s, no operation01 string, add multiplicand10 string, subtract multiplicand11 string01 string
11111101011two’s complement with sign extension as needed0000000000zero with sign extension shown
000010101positive multiplicand with sign extension111010110000000+ 01010101000110111 = 567ten
4Solutions for Chapter 3 Exercises
Don’t worry about the carry out of the MSB here; with additional sign extensionfor the addends, the sum would correctly have an extended positive sign. Now,using the 3-bit Booth’s algorithm:
010101 × 011011 – 010101 – 010101+ 0101010= 21ten= 27ten
110 string (always start with padding 0 to right of LSB)101 string, subtract the multiplicand
011 string, add twice the multiplicand (i.e., shifted left 1 place)
11111101011two’s complement of multiplicand with sign extension111101011two’s complement of multiplicand with sign extension+ 0101010 01000110111
= 567 ten
Using the 3-bit version gives only 3 addends to sum to get the product versus 6addends using the 2-bit algorithm.
Booth’s algorithm can be extended to look at any number of bits b at a time. Theamounts to add or subtract include all multiples of the multiplicand from 0 to2(b–1). Thus, for b > 3 this means adding or subtracting values that are other thanpowers of 2 multiples of the multiplicand. These values do not have a trivial“shift left by the power of 2 number of bit positions” method of computation.3.25
l.d $f0, –8($gp)l.d $f2, –16($gp)l.d $f4, –24($gp)
fmadd $f0, $f0, $f2, $f4s.d $f0, –8($gp)
3.26a.
x = 0100 0000 0110 0000 0000 0000 0010 0001y = 0100 0000 1010 0000 0000 0000 0000 0000Exponents
100 0000 0+100 0000 11000 0000 1–011 1111 1100 0001 0
Solutions for Chapter 3 Exercises5
xy
1.100 0000 0000 0000 0010 0001×1.010 0000 0000 0000 0000 0000
1 100 0000 0000 0000 0010 0001 000 0000 0000 0000 0000 0000+ 11 0000 0000 0000 0000 1000 010 0000 0000 0000 0000 0000 1.111 0000 0000 0000 0010 1001 010 0000 0000 0000 0000 0000 Round result for part b.
1.111 1100 0000 0000 0010 1001
z 0011 1100 1110 0000 0000 1010 1100 0000Exponents
100 0001 0–11 1100 1
100 1 --> shift 9 bits
1.111 0000 0000 0000 0010 1001 010 0000 00 + z 111 0000 0000 0101 011 0000 001.111 0000 0111 0000 0010 1110 101 GRSResult:
0100 0001 0111 0000 0111 0000 0100 1111b.
1.111 1100 0000 0000 0000 1001 result from mult.+ z 111 0000 0000 0101 0111.111 1100 0111 0000 0001 1110 011 GRS0100 0001 0111 0000 0111 0000 0100 1110
6Solutions for Chapter 3 Exercises
3.27
a.
Solutions for Chapter 3 Exercises7
3.28
a.
c.
8Solutions for Chapter 3 Exercises
d.Convert to positive:
100010
00
0000
0000
11011000
010|0111Since signs differ, convert quotient to negative:
1111 1111 1111 1111 1111 1111 1110 0101two
3.29Start
Set subtract bit to true
1.If subtract bit true: Subtract the Divisor register from the Remainder andplace the result in the remainder register. else Add the Divisor register to the Remainder and place the result in theremainder register.Test Remainder>=0
2.a. Shift the Quotient register to the left, setting rightmost bit to 1.<0
2.b. Set subtract bit to false.3.Shift the Divisor register right 1 bit.<33rd rep ---> repeatTest remainder<0
Solutions for Chapter 3 Exercises9
Add Divisor register to remainder and place in Remainder register.DoneExample:
Perform n + 1 iterations for n bitsRemainder 0000 1011Divisor 0011 0000Iteration 1:(subtract)
Rem 1101 1011Quotient 0
Divisor 0001 1000Iteration 2:(add)
Rem 1111 0011Q 00
Divisor 0000 1100Iteration 3:(add)
Rem 1111 1111Q 000
Divisor 0000 0110Iteration 4:(add)
Rem 0000 0101Q 0001
Divisor 0000 0011
Iteration 5:(subtract)
Rem 0000 0010Q 0001 1
Divisor 0000 0001
Since remainder is positive, done.Q = 0011 and Rem = 0010
10Solutions for Chapter 3 Exercises
3.30
a.–1 391 460 350b.2 903 506 946c.–8.18545 × 10–12
d.sw $s0, $t0(16) sw $r16, $r8(2)
3.31
a.613 566 756b.613 566 756c.6.34413 × 10–17
d.addiu, $s2, $a0, 18724 addiu $18, $4, 0x8924
3.35
.285 × 104+9.84 × 10410.125 × 1041.0125 × 104
with guard and round: 1.01 × 105without: 1.01 × 105
3.36
3.63 × 104+.687 × 1044.317 × 104
with guard and round: 4.32 × 104without: 4.31 × 104
3.37
Solutions for Chapter 3 Exercises11
Single precisionDoubleprecision3.38
0 1000 011 010 0000 0000 0000 0000 0000
0 1000 0000 011 0100 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
Single precision
Doubleprecision3.39
0 1000 0011 010 0100 0000 0000 0000 0000
0 1000 0000 011 0100 1000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
01111011
10011001100110011001100
10011001100110011001101
truncround
Single precision
01111111011
10011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011010
truncround
Doubleprecision
12precisionSingle precision
DoubleSolutions for Chapter 3 Exercises
3.40
1 0001 1110 101 0101 0101 0101 0101 0101
1 0111 1111 110 1010 1010 1010 1010 1010 1010 1010 1010 1010 1010 1010 1010 1010 t runc
1 0111 1111 110 1010 1010 1010 1010 1010 1010 1010 1010 1010 1010 1010 1010 1011 round
3.41No, since floating point adds are not associative, doing them simultaneously
is not the same as doing them serially.3.42
a.
Convert +1 . 1011 * 214 + –1 . 11 * 2–21.1011 0000 0000 0000 0000 000
–0.0000 0000 0000 0001 1100 0001.1010 1111 1111 1110 0100 0000100 0110 1101 0111 1111 1111 0010 0000b.Calculate new exponent:111 11 1100 0110 1+011 1110 11000 0101 0
–011 1111 1 minus bias1111 1111
100 0101 1 new exponentMultiply signi cands:
×1.101 1000 0000 0000 0000 00001.110 0000 0000 0000 0000 0000
1 11 11
1 1011 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 11 0110 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000+1.10 1100 0000 0000 0000 0000 0000 0000 0000 0000 0000 000010.11 1101 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
Solutions for Chapter 3 Exercises13
Normalize and round:
exponent 100 0110 0signi cand
1.011 1010 0000 0000 0000 0000Signs differ, so result is negative:
1100 0110 0011 1010 0000 0000 0000 00003.43
0 101 1111 1 011 1110 0100 0000 0000 00000 101 0001 1 111 1000 0000 0000 0000 0000a.Determine difference in exponents:1011 1111–1010 0011001 1100 --> 28
Add signi cands after scaling:
1.011 1110 0100 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000+0.000 0000 0000 0000 0000 0000 0000 1111 1000 0000 0000 0000 00001.011 1110 0100 0000 0000 0000 0000 1111 1000 0000 0000 0000 0000Round (truncate) and repack:
0 101 1111 1 011 1110 0100 0000 0000 0000 0101 1111 1011 1110 0100 0000 0000 0000b.Trivially results in zero:
0000 0000 0000 0000 0000 0000 0000 0000
c.We are computing (x + y) + z, where z = –x and y ≠ 0(x + y) + –x = y intuitively
(x + y) + –x = 0 with nite oating-point accuracy
14Solutions for Chapter 3 Exercises
3.44
a.215 – 1 = 32767b.
2.0ten × 22 11
22 = 3.23 × 10616
12
22 = 1.04 × 10123313
22 = 1.09 × 10246614
22 = 1.19 × 10493215
15
22 = 1.42 × 109864so
as small as 2.0ten × 10–9864
and almost as large as 2.0ten × 109864
c.20% more signi cant digits, and 9556 orders of magnitude more exibility.(Exponent is 32 times larger.)3.45The implied 1 is counted as one of the significand bits. So, 1 sign bit, 16
exponent bits, and 63 fraction bits.3.46
Load 2 × 10308
Square it 4 × 10616Square it 1.6 × 101233Square it 2.5 × 102466Square it 6.2 × 104932Square it 3.6 × 109865
Min 6 instructions to utilize the full exponent range.
正在阅读:
03~solutions_for_chapter_3_exercises05-15
音河水库风景区旅游总体规划200305-22
爱在心口难开作文500字07-03
中秋节快乐作文500字06-28
2022年消防安全月工作总结大全07-31
校园小达人作文300字06-21
2016-2022年中国高端女装行业分析及市场前景预测报告(目录) - 图文10-30
小学生写想象的作文06-15
扬州市救护总站人事制度改革暂行办法12-24
- 1应用语言学chapter4 syntax exercises
- 2Intermediate Accounting 8th Edition Solutions by J. David Spiceland - Chapter - 01
- 3Chapter 3 Environment
- 4会计学:企业决策的基础exercises-chapter4答案 - 图文
- 5Module 6 Unit 3 Vocabulary Exercises
- 6Key to chapter 3
- 7广告学概论教案chapter03
- 8Chapter 3 Goverment of the UK
- 9exercises
- 10国际金融英文chapter 1--03版
- 教学能力大赛决赛获奖-教学实施报告-(完整图文版)
- 互联网+数据中心行业分析报告
- 2017上海杨浦区高三一模数学试题及答案
- 招商部差旅接待管理制度(4-25)
- 学生游玩安全注意事项
- 学生信息管理系统(文档模板供参考)
- 叉车门架有限元分析及系统设计
- 2014帮助残疾人志愿者服务情况记录
- 叶绿体中色素的提取和分离实验
- 中国食物成分表2020年最新权威完整改进版
- 推动国土资源领域生态文明建设
- 给水管道冲洗和消毒记录
- 计算机软件专业自我评价
- 高中数学必修1-5知识点归纳
- 2018-2022年中国第五代移动通信技术(5G)产业深度分析及发展前景研究报告发展趋势(目录)
- 生产车间巡查制度
- 2018版中国光热发电行业深度研究报告目录
- (通用)2019年中考数学总复习 第一章 第四节 数的开方与二次根式课件
- 2017_2018学年高中语文第二单元第4课说数课件粤教版
- 上市新药Lumateperone(卢美哌隆)合成检索总结报告
- solutions
- exercises
- chapter
- 03
- 企业资讯系统对企业文化的构建_以广东省粤电集团有限公司为例
- 最具创意大型活动策划案例
- 产业经济学教程课后习题答案——马增林主编(中国农业出版社)
- 第3课 区域经济和重心的南移
- 十八届三中全会报告重点解读
- 2015年中国高效减水剂行业运营监测报告
- 栅格地图技术与VML融合的WebGIS研究
- 最新生物会考选择题易错部分复习精选
- C语言课程设计实验报告
- 在党员宣誓仪式上的讲话-领导致辞
- XX社区卫生服务中心2011工作计划
- CI-900便携式乙烯气体分析仪
- 商用车车架常用横梁的力学性能研究
- 人体常见疾病与保健
- 唐五代时期敦煌的宴饮“赌射”——敦煌文献P.3272卷“射羊”一词小解
- 珠海洗浴设备生产线项目商业计划书
- DCYX6576-黑弧奥美-华润外滩九里核心idea2011.3
- 第11讲 状态图和活动图
- 诚信计生双向承诺书
- 消防演习步骤Process for Fire Drill