This repository has been archived by the owner on Sep 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwang-shuang-hui-bian-yu-yan-di-san-ban-jian-ce-dian-da-an.html
1210 lines (1060 loc) · 32.7 KB
/
wang-shuang-hui-bian-yu-yan-di-san-ban-jian-ce-dian-da-an.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>王爽汇编语言第三版检测点答案</title>
<link href="/feeds/all.atom.xml" type="application/atom+xml" rel="alternate" title="华科美团点评技术俱乐部 Full Atom Feed" />
<link href="/feeds/hui-bian.atom.xml" type="application/atom+xml" rel="alternate" title="华科美团点评技术俱乐部 Categories Atom Feed" />
<!-- Bootstrap Core CSS -->
<link href="/theme/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="/theme/css/clean-blog.min.css" rel="stylesheet">
<!-- Code highlight color scheme -->
<link href="/theme/css/code_blocks/darkly.css" rel="stylesheet">
<!-- Custom Fonts -->
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href='https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<meta name="description" content="开学三周,王爽的《汇编语言》(第三版)总算是基本上看完了,本文是总结的第一部分,包括了书上所有的检测点答案 第一章 基础知识 检测点 1.1 1个CPU的寻址能力为8KB,那么它的地址总线的宽度为____。 13...">
<meta name="author" content="Zhihao Chen">
<meta name="tags" content="答案">
<meta name="tags" content="汇编">
<meta property="og:locale" content="zh_CN.UTF-8">
<meta property="og:site_name" content="华科美团点评技术俱乐部">
<meta property="og:type" content="article">
<meta property="article:author" content="/author/zhihao-chen.html">
<meta property="og:url" content="/wang-shuang-hui-bian-yu-yan-di-san-ban-jian-ce-dian-da-an.html">
<meta property="og:title" content="王爽汇编语言第三版检测点答案">
<meta property="article:published_time" content="2017-03-05 18:49:39+08:00">
<meta property="og:description" content="开学三周,王爽的《汇编语言》(第三版)总算是基本上看完了,本文是总结的第一部分,包括了书上所有的检测点答案 第一章 基础知识 检测点 1.1 1个CPU的寻址能力为8KB,那么它的地址总线的宽度为____。 13...">
<meta property="og:image" content="//images/bg.jpg">
</head>
<body>
<!-- Navigation -->
<nav class="navbar navbar-default navbar-custom navbar-fixed-top">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header page-scroll">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">华科美团点评技术俱乐部</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li><a href="/categories.html">分类</a></li>
<li><a href="/archives.html">归档</a></li>
<li><a href="/authors.html">作者</a></li>
<li><a href="/tags.html">标签</a></li>
<li><a href="/pages/about/index.html">关于</a></li>
<li><a href="/pages/friendlinks/index.html">友链</a></li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
<!-- Page Header -->
<header class="intro-header" style="background-image: url('/images/bg.jpg')">
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
<div class="post-heading">
<h1>王爽汇编语言第三版检测点答案</h1>
<span class="meta">Posted by
<a href="/author/zhihao-chen.html">Zhihao Chen</a>
on 2017年 3月05日 周日
</span>
</div>
</div>
</div>
</div>
</header>
<!-- Main Content -->
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
<!-- Post Content -->
<article>
<blockquote>
<p>开学三周,王爽的《汇编语言》(第三版)总算是基本上看完了,本文是总结的第一部分,包括了书上所有的检测点答案</p>
</blockquote>
<h2>第一章 基础知识</h2>
<h3>检测点 1.1</h3>
<ol>
<li>1个CPU的寻址能力为8KB,那么它的地址总线的宽度为____。
<strong>13</strong>
解析:CPU在内存中寻址的最小单位是Byte(字节),8KB = 2^13B,因此地址总线的宽度为13.</li>
<li>1KB的存储器有____个存储单元。存储单元的编号从____到____。
<strong>1024 0 1023</strong></li>
<li>1KB的存储器可以存储____个bit,____个Byte。
<strong>2^13 2^10</strong></li>
<li>1GB、1MB、1KB分别是____________Byte
<strong>2^30 2^20 2^10</strong></li>
<li>8080、8088、80286、80386的地址总线宽度分别为16根、20根、24根、32根,则他们的寻址能力分别为____(KB)、____(MB)、____(MB)、____(GB)。
<strong>64 1 16 4</strong></li>
<li>8080、8088、8086、80286、80386的数据总线宽度分别为8根、8根、16根、16根、32根。则它们一次可以传送的数据为:____(B)、____(B)、____(B)、____(B)、____(B)。
<strong>1 1 2 2 4</strong></li>
<li>从内存中读取1024字节的数据,8086至少要读取____次,80386至少要读取____次。
<strong>512 256</strong></li>
<li>在存储器中,数据和程序以____形式存放。
<strong>二进制</strong></li>
</ol>
<h2>第二章 寄存器</h2>
<h3>检测点 2.1</h3>
<ol>
<li>写出每条汇编指令执行后相关寄存器中的值</li>
</ol>
<div class="highlight"><pre><span></span>mov ax, 62627 AX =
mov ah, 31H AX =
mov al, 23H AX =
add ax, ax AX =
mov bx, 826CH BX =
mov cx, ax CX =
mov ax, bx AX =
add ax, bx AX =
mov al, bh AX =
mov ah, bl AX =
add ah, ah AX =
add al, 6 AX =
add al, al AX =
mov ax, cx AX =
</pre></div>
<p><strong>F4A3H 31A3H 3123H 6246H 826CH 6246H 826CH 04D8H 0482H 6C82H D882H D888H D810H 6246H</strong></p>
<ol>
<li>只能使用目前学过的汇编指令,最多使用4条指令,编程计算2的4次方。</li>
</ol>
<div class="highlight"><pre><span></span>mov ax, 2
add ax, ax
add ax, ax
add ax, ax
</pre></div>
<h3>检测点 2.2</h3>
<ol>
<li>给定段地址为0001H,仅通过变化偏移地址寻址,CPU的寻址范围为_____到_____。
<strong>00010H到1000FH</strong></li>
<li>有一数据存放在内存20000H的单元中,现给定段地址为SA,若想用偏移地址寻到此单元。则SA应满足的条件是:最小为_____,最大为_____。提示,反过来思考一下,当段地址给定为多少,CPU无论怎么变化偏移地址都无法寻到20000H单元?
<strong>1001F 2000H</strong>
<strong>20000H - 0FFFFH = 10001H</strong>
<strong>20000H - 00000H = 20000H</strong></li>
</ol>
<h3>检测点 2.3</h3>
<p>下面的3条指令执行后,CPU几次修改IP?都是在什么时候?最后IP中的值是多少?</p>
<div class="highlight"><pre><span></span>mov ax, bx
sub ax, ax
jmp ax
</pre></div>
<p>修改了四次:</p>
<ol>
<li>第1条指令执行后,IP指向第2条指令</li>
<li>第2条指令执行后,IP指向第3条指令</li>
<li>第3条指令执行后,IP指向第4条指令</li>
<li>JMP指令执行后,IP重新指向第1条指令</li>
</ol>
<h2>第三章 寄存器(内存访问)</h2>
<h3>检测点 3.1</h3>
<ol>
<li>
<p>在Debug中,用“d 0:0 1f”查看内存,结果如下。</p>
<p>0000:0000 70 80 F0 30 EF 60 30 E2-00 80 80 12 66 20 22 60
0000:0010 62 26 E6 D6 CC 2E 3C 3B-AB BA 00 00 26 06 66 88</p>
</li>
</ol>
<p>下面的程序执行前,AX=0,BX=0,写出每条汇编指令执行完后相关寄存器中的值。</p>
<div class="highlight"><pre><span></span>mov ax, 1
mov ds, ax
mov ax, [0000] AX =
mov bx, [0001] BX =
mov ax, bx AX =
mov ax, [0000] AX =
mov bx, [0002] BX =
add ax, bx AX =
add ax, [0004] AX =
mov ax, 0 AX =
mov al, [0002] AX =
mov bx, 0 BX =
mov bl, [000C] BX =
add al, bl AX =
</pre></div>
<p>提示,注意ds的设置。</p>
<p><strong>2662H E626H E626H 2662H D6E6H FD48H 2C14H 0 00E6H 0 0026H 000CH</strong></p>
<ol>
<li>内存中的情况如图3.6所示。
各寄存器的初始值:CS=2000H,IP=0,DS=1000H,AX=0,BX=0;
①写出CPU执行的指令序列(用汇编指令写出)
②写出CPU执行每条指令后,CS、IP和相关寄存器中的数值。
③再次体会:数据和程序有区别吗?如何确定内存中的信息哪些是数据,哪些是程序?</li>
</ol>
<table>
<thead>
<tr>
<th align="center">指令</th>
<th align="center">CS:IP</th>
<th align="center">DS</th>
<th align="center">AX</th>
<th align="center">BX</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">mov ax, 6622H</td>
<td align="center">2000:3</td>
<td align="center">1000H</td>
<td align="center">6622H</td>
<td align="center">0</td>
</tr>
<tr>
<td align="center">jmp 0ff0:0100</td>
<td align="center">2000:8->1000:0</td>
<td align="center">1000H</td>
<td align="center">6622H</td>
<td align="center">0</td>
</tr>
<tr>
<td align="center">mov ax, 2000H</td>
<td align="center">1000:3</td>
<td align="center">1000H</td>
<td align="center">2000H</td>
<td align="center">0</td>
</tr>
<tr>
<td align="center">mov ds, ax</td>
<td align="center">1000:5</td>
<td align="center">2000H</td>
<td align="center">2000H</td>
<td align="center">0</td>
</tr>
<tr>
<td align="center">mov ax, [0008]</td>
<td align="center">1000:8</td>
<td align="center">2000H</td>
<td align="center">C389H</td>
<td align="center">0</td>
</tr>
<tr>
<td align="center">mov ax, [0002]</td>
<td align="center">1000:B</td>
<td align="center">2000H</td>
<td align="center">EA66H</td>
<td align="center">0</td>
</tr>
</tbody>
</table>
<p>程序和数据没有区别,本质上都是二进制01码,关键在于CPU如何解读。</p>
<h3>检测点 3.2</h3>
<ol>
<li>补全下面的程序,使其可以将10000H~1000FH中的8个字,逆序复制到20000H~2000FH中。逆序复制的含义如图3.17所示(图中内存里的数据均为假设)。</li>
</ol>
<div class="highlight"><pre><span></span>mov ax, 1000H
mov ds, ax
__________
__________
__________
push [0]
push [2]
push [4]
push [6]
push [8]
push [A]
push [C]
push [E]
</pre></div>
<p>答案: </p>
<div class="highlight"><pre><span></span>mov ax, 2000H
mov ss, ax
mov sp, 0010H
</pre></div>
<ol>
<li>补全下面的程序,使其可以将10000H~1000FH中的8个字,逆序复制到20000H~2000FH中。</li>
</ol>
<div class="highlight"><pre><span></span>mov ax, 2000H
mov ds, ax
__________
__________
__________
pop [E]
pop [C]
pop [A]
pop [8]
pop [6]
pop [4]
pop [2]
pop [0]
</pre></div>
<p>答案: </p>
<div class="highlight"><pre><span></span>mov ax, 1000H
mov ss, ax
mov sp, 0
</pre></div>
<h2>第六章 包含多个段的程序</h2>
<h3>检测点 6.1</h3>
<ol>
<li>下面的程序实现依此用内存0:0-0:15单元中的内容改写程序中的数据,完成程序:</li>
</ol>
<div class="highlight"><pre><span></span>assume cs:codesg
codesg segment
dw 0123h, 0456h, 0789h, 0abch, 0defh, 0fedh, 0cbah, 0987h
start: mov ax, 0
mov ds, ax
mov bx, 0
mov cx, 8
s: mov ax, [bx]
_________
add bx, 2
loop s
mov ax, 4c00h
int 21h
codesg ends
end start
</pre></div>
<p>答案:</p>
<div class="highlight"><pre><span></span>mov cs:[bx], ax
</pre></div>
<ol>
<li>下面的程序实现依此用内存0:0-0:15单元中的内容改写程序中的数据,数据的传送用栈来进行。栈空间设置在程序内。完成程序:</li>
</ol>
<div class="highlight"><pre><span></span>assume cs:codesg
dw 0123h, 0456h, 0789h, 0abch, 0defh, 0fedh, 0cbah, 0987h
dw 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
start: mov ax, ____
mov ss, ax
mov sp, ____
mov ax, 0
mov ds, ax
mov bx, 0
mov cx, 8
s: push [bx]
____________
add bx, 2
loop s
mov ax, 4c00h
int 21h
codesg ends
end start
</pre></div>
<p>答案:</p>
<div class="highlight"><pre><span></span>0
24h
pop cs:[bx]
</pre></div>
<h2>第九章 转移指令的原理</h2>
<h3>检测点 9.1</h3>
<ol>
<li>程序如下</li>
</ol>
<div class="highlight"><pre><span></span>assume cs:code
data segment
___________
data ends
code segment
start: mov ax, data
mov ds, ax
mov bx, 0
jmp word ptr [bx+1]
code ends
end start
</pre></div>
<p>若要使程序中的jmp指令执行后,CS:IP指向程序的第一条指令,在data段中应该定义哪些数据?
答案:</p>
<div class="highlight"><pre><span></span>dw 0, 0
</pre></div>
<ol>
<li>程序如下</li>
</ol>
<div class="highlight"><pre><span></span>assume cs:code
data segment
dd 12345678H
data ends
code segment
start: mov ax, data
mov ds, ax
mov bx, 0
mov [bx], ____
mov [bx + 2], ____
jmp dword ptr ds:[0]
code ends
end start
</pre></div>
<p>补全程序,使jmp指令执行后,CS:IP指向程序的第一条指令。
答案:</p>
<div class="highlight"><pre><span></span>bx
cs
</pre></div>
<p>注意:bx指向低位,bx+2指向高位,低位为IP,而高位为CS。</p>
<ol>
<li>用Debug查看内存,结果如下:</li>
</ol>
<div class="highlight"><pre><span></span><span class="mi">2000</span><span class="o">:</span><span class="mi">1000</span> <span class="n">BE</span> <span class="mi">00</span> <span class="mi">06</span> <span class="mi">00</span> <span class="mi">00</span> <span class="mi">00</span> <span class="o">......</span>
</pre></div>
<p>则此时,CPU执行指令后,(CS)=?,(IP)=?</p>
<div class="highlight"><pre><span></span>mov ax, 2000H
mov es, ax
jmp dword ptr es:[1000H]
</pre></div>
<p>答案:
(CS)=0006,(IP)=00BE</p>
<h3>检测点 9.2</h3>
<p>补全编程,利用jcxz指令,实现在内存2000H段中查找第一个值为0的字节,找到后,将它的偏移地址存储在dx中。</p>
<div class="highlight"><pre><span></span>assume cs:code
code segment
start: mov ax, 2000H
mov ds, ax
mov bx, 0
s: __________
__________
__________
__________
jmp short s
ok: mov dx, bx
mov ax, 4c00h
int 21h
code ends
end start
</pre></div>
<p>答案:</p>
<div class="highlight"><pre><span></span>mov cl, [bx]
mov ch, 0 ;注意这一步的必要性
jcxz ok
inc bx
</pre></div>
<h3>检测点 9.3</h3>
<p>补全编程,利用loop指令,实现在内存的2000H段中查找第一个值为0的字节,找到后,将它的偏移地址存储在dx中。</p>
<div class="highlight"><pre><span></span>assume cs:code
code segment
start: mov ax, 2000H
mov ds, ax
mov bx, 0
s: mov cl, [bx]
mov ch, 0
_________
inc bx
loop s
ok: dec bx
mov dx, bx
mov ax, 4c00h
int 21h
code ends
end start
</pre></div>
<p>答案:</p>
<div class="highlight"><pre><span></span>inc cx ;注意loop的工作原理
</pre></div>
<h2>第十章 CALL和RET指令</h2>
<h3>检测点 10.1</h3>
<p>补全程序,实现从内存1000:0000处开始执行指令。</p>
<div class="highlight"><pre><span></span>assume cs:code
stack segment
db 16 dup (0)
stack ends
code segment
start: mov ax,stack
mov ss,ax
mov sp,16
mov ax, ____
push ax
mov ax, ____
push ax
retf
code ends
end start
</pre></div>
<p>答案:</p>
<div class="highlight"><pre><span></span>1000h
0
</pre></div>
<h3>检测点 10.2</h3>
<p>下面的程序执行后,ax中的数值为多少?</p>
<table>
<thead>
<tr>
<th align="center">内存地址</th>
<th align="center">机器码</th>
<th align="center">汇编指令</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">1000:0</td>
<td align="center">b8 00 00</td>
<td align="center">mov ax,0</td>
</tr>
<tr>
<td align="center">1000:3</td>
<td align="center">e8 01 00</td>
<td align="center">call s</td>
</tr>
<tr>
<td align="center">1000:6</td>
<td align="center">40</td>
<td align="center">inc ax</td>
</tr>
<tr>
<td align="center">1000:7</td>
<td align="center">58</td>
<td align="center">s: pop ax</td>
</tr>
</tbody>
</table>
<p>ax中的数值为6,注意执行完call s后,IP先变为6,然后将IP的值压栈,最后跳转至s。</p>
<h3>检测点 10.3</h3>
<p>下面的程序执行后,ax中的数值为多少?</p>
<table>
<thead>
<tr>
<th align="center">内存地址</th>
<th align="center">机器码</th>
<th align="center">汇编指令</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">1000:0</td>
<td align="center">b8 00 00</td>
<td align="center">mov ax,0</td>
</tr>
<tr>
<td align="center">1000:3</td>
<td align="center">9a 09 00 00 10</td>
<td align="center">call far ptr s</td>
</tr>
<tr>
<td align="center">1000:8</td>
<td align="center">40</td>
<td align="center">inc ax</td>
</tr>
<tr>
<td align="center">1000:9</td>
<td align="center">58</td>
<td align="center">s: pop ax</td>
</tr>
<tr>
<td align="center"></td>
<td align="center"></td>
<td align="center">add ax,ax</td>
</tr>
<tr>
<td align="center"></td>
<td align="center"></td>
<td align="center">pop bx</td>
</tr>
<tr>
<td align="center"></td>
<td align="center"></td>
<td align="center">add ax,bx</td>
</tr>
</tbody>
</table>
<p>ax中的数值为1010H,注意执行完call far ptr s后,IP先变为8,然后将CS、IP的值分别为1000和8依此压栈,最后再跳转至s继续执行。</p>
<h3>检测点 10.4</h3>
<p>下面的程序执行后,ax中的数值为多少?</p>
<table>
<thead>
<tr>
<th align="center">内存地址</th>
<th align="center">机器码</th>
<th align="center">汇编指令</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">1000:0</td>
<td align="center">b8 06 00</td>
<td align="center">mov ax,6</td>
</tr>
<tr>
<td align="center">1000:3</td>
<td align="center">ff d0</td>
<td align="center">call ax</td>
</tr>
<tr>
<td align="center">1000:5</td>
<td align="center">40</td>
<td align="center">inc ax</td>
</tr>
<tr>
<td align="center">1000:6</td>
<td align="center">58</td>
<td align="center">mov bp,sp</td>
</tr>
<tr>
<td align="center"></td>
<td align="center"></td>
<td align="center">add ax,[bp]</td>
</tr>
</tbody>
</table>
<p>ax中的数值为0BH,分析方法类似检测点10.2</p>
<h3>检测点 10.5</h3>
<ol>
<li>下面的程序执行后,ax中的数值为多少?</li>
</ol>
<div class="highlight"><pre><span></span>assume cs:code
stack segment
dw 8 dup (0)
stack ends
code segment
start: mov ax,stack
mov ss,ax
mov sp,16
mov ds,ax
mov ax,0
call word ptr ds:[0eh]
inc ax
inc ax
inc ax
mov ax,4c00h
int 21h
code ends
end start
</pre></div>
<p>ax中的数值为3,注意ds与ss中存放的段地址相同,在执行了call word ptr ds:[0EH]之后,程序会先将下一条指令inc ax的偏移量压栈,然后跳转到栈顶所指向的指令的位置,即跳转至第一条inc ax的位置,故最后ax的值为3。</p>
<p>注意:在使用Debug单步跟踪的时候,由于t命令所导致的中断,而影响了栈中的值。</p>
<ol>
<li>下面的程序执行后,ax和bx中的数值为多少?</li>
</ol>
<div class="highlight"><pre><span></span>assume cs:codesg
data segment
dw 8 dup (0)
data ends
code segment
start: mov ax,data
mov ss,ax
mov sp,16
mov word ptr ss:[0],offset s
mov ss:[2],cs
call dword ptr ss:[0]
nop
s: mov ax,offset s
sub ax,ss:[0ch]
mov bx,cs
sub bx,ss:[0eh]
mov ax,4c00h
int 21h
code ends
end start
</pre></div>
<p>ax中的数值为1,bx中的数值为0,注意到程序的一开始将a的偏移量和cs放入ss:[0]和ss:[2]中,然后调用call指令,将CS和IP(nop指令的偏移量)依此压栈后跳转到s处继续执行,ax最终为s的偏移量减去nop指令所在位置的偏移量,为1,bx最终为cs的段地址相减,为0。</p>
<h2>第十一章 标志寄存器</h2>
<h3>检测点 11.1</h3>
<p>写出下面每条指令执行后,ZF、PF、SF等标志位的值</p>
<table>
<thead>
<tr>
<th align="center">指令</th>
<th align="center">ZF</th>
<th align="center">PF</th>
<th align="center">SF</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">sub al, al</td>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">0</td>
</tr>
<tr>
<td align="center">mov al, 1</td>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">0</td>
</tr>
<tr>
<td align="center">push ax</td>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">0</td>
</tr>
<tr>
<td align="center">pop bx</td>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">0</td>
</tr>
<tr>
<td align="center">add al, bl</td>
<td align="center">0</td>
<td align="center">0</td>
<td align="center">0</td>
</tr>
<tr>
<td align="center">add bl, 10</td>
<td align="center">0</td>
<td align="center">1</td>
<td align="center">0</td>
</tr>
<tr>
<td align="center">mul al</td>
<td align="center">0</td>
<td align="center">1</td>
<td align="center">0</td>
</tr>
</tbody>
</table>
<h3>检测点 11.2</h3>
<p>写出下面每条指令执行后,ZF、PF、SF、CF、OF等标志位的值</p>
<table>
<thead>
<tr>
<th align="center">指令</th>
<th align="center">CF</th>
<th align="center">OF</th>
<th align="center">SF</th>
<th align="center">ZF</th>
<th align="center">PF</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">sub al, al</td>
<td align="center">0</td>
<td align="center">0</td>
<td align="center">0</td>
<td align="center">1</td>
<td align="center">1</td>
</tr>
<tr>
<td align="center">mov al, 10H</td>
<td align="center">0</td>
<td align="center">0</td>
<td align="center">0</td>
<td align="center">1</td>
<td align="center">1</td>
</tr>
<tr>
<td align="center">add al, 90H</td>
<td align="center">0</td>
<td align="center">0</td>
<td align="center">1</td>
<td align="center">0</td>
<td align="center">1</td>
</tr>
<tr>
<td align="center">mov al, 80H</td>
<td align="center">0</td>
<td align="center">0</td>
<td align="center">1</td>
<td align="center">0</td>
<td align="center">1</td>
</tr>
<tr>
<td align="center">add al, 80H</td>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">0</td>
<td align="center">1</td>
<td align="center">1</td>
</tr>
<tr>
<td align="center">mov al, 0FCH</td>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">0</td>
<td align="center">1</td>
<td align="center">1</td>
</tr>
<tr>
<td align="center">add al, 05H</td>
<td align="center">1</td>
<td align="center">0</td>
<td align="center">0</td>
<td align="center">0</td>
<td align="center">0</td>
</tr>
<tr>
<td align="center">mov al, 7DH</td>
<td align="center">1</td>
<td align="center">0</td>
<td align="center">0</td>
<td align="center">0</td>
<td align="center">0</td>
</tr>
<tr>
<td align="center">add al, 0BH</td>
<td align="center">0</td>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">0</td>
<td align="center">1</td>
</tr>
</tbody>
</table>
<h3>检测点 11.3</h3>
<ol>
<li>补全下面的程序,统计F000:0处32个字节中,大小在[32,128]的数据的个数。</li>
</ol>
<div class="highlight"><pre><span></span> mov ax, 0f000h
mov ds, ax
mov bx, 0
mov dx, 0
mov cx, 32
s: mov al, [bx]
cmp al, 32
__________
cmp al, 128
__________
inc dx
s0: inc bx
loop s
</pre></div>
<p>答案:</p>
<div class="highlight"><pre><span></span>jb s0
ja s0
</pre></div>
<ol>
<li>补全下面的程序,统计F000:0处32个字节中,大小在(32,128)的数据的个数。</li>
</ol>
<div class="highlight"><pre><span></span> mov ax, 0f000h
mov ds, ax
mov bx, 0
mov dx, 0
mov cx, 32
s: mov al, [bx]
cmp al, 32
__________
cmp al, 128
__________
inc dx
s0: inc bx
loop s
</pre></div>
<p>答案:</p>
<div class="highlight"><pre><span></span>jna s0
jnb s0
</pre></div>
<h3>检测点 11.4</h3>
<p>下面的程序执行后:(ax)=?</p>
<div class="highlight"><pre><span></span>mov ax, 0
push ax
popf ;将PSW置0(本章所学习的标志位都为0)
mov ax, 0fff0h
add ax, 0010h ;修改相关标志位
pushf
pop ax ;(将PSW保存至ax)
and al, 11000101B
and ah, 00001000B ;只考虑CF,PF,ZF,SF,OF五个标志位
</pre></div>
<p>答案:
(ax)=45H</p>
<h2>第十二章 内中断</h2>
<h3>检测点 12.1</h3>
<ol>
<li>用Debug查看内存,情况如下:
0000:0000 68 10 A7 00 8B 01 70 00-16 00 9D 03 8B 01 70 00
则3号中断源对应的中断处理程序的入口地址为:<strong><em>_</em></strong>_____</li>
</ol>
<p>答案:</p>
<p>0070:018B</p>
<p>注意高地址存放段地址,低地址存放偏移地址</p>
<ol>
<li>存储N号中断源对应的中断处理程序入口的偏移地址的内存单元的地址为:<strong><em>_
存储N号中断源对应的中断处理程序入口的段地址的内存单元的地址为:</em></strong>_</li>
</ol>
<p>答案:4N,4N+2</p>
<h2>第十三章 int指令</h2>
<h3>检测点 13.1</h3>
<ol>
<li>在上面的内容中,我们用7ch中断例程实现loop的功能,则上面的7ch中断例程所能进行的最大转移位移为多少?</li>
</ol>
<p>答案:65535</p>
<ol>
<li>用7ch中断例程完成jmp near ptr s指令的功能,用bx向中断例程传送转移位移。</li>
</ol>
<p>答案:</p>
<div class="highlight"><pre><span></span><span class="n">jnp</span><span class="o">:</span> <span class="n">push</span> <span class="n">bp</span>
<span class="n">mov</span> <span class="n">bp</span><span class="o">,</span> <span class="n">sp</span>
<span class="n">add</span> <span class="o">[</span><span class="n">bp</span><span class="o">+</span><span class="mi">2</span><span class="o">],</span> <span class="n">bx</span>
<span class="n">pop</span> <span class="n">bp</span>
<span class="n">iret</span>
</pre></div>
<h3>检测点 13.2</h3>
<p>判断下面说法的正误:</p>
<ol>
<li>我们可以编程改变FFFF:0处的指令,使得CPU不去执行BIOS中的硬件系统检测和初始化程序。</li>
</ol>
<p>错误:FFFF:0处的内容无法修改</p>