问题 问答题

编制一个程序,其功能是:计算内存中连续存放的20个字节无符号数据的相邻两个数据之间的和,并找出和的最大值,和的最大值存放在结果的最后一个字单元,和为字数据。
例如:
内存中有:20H,04H,58H,34H,35H,4DH……,
则结果为:0024H,008CH,0082H……
部分程序已经给出,其中原始数据由过程LOAD从文件INPUT.DAT中读入以SOURCE开始的内存单元中。运算结果要求从RESULT开始的内存单元存放,由过程SAVE保存到文件OUTPUT.DAT中。
请填空BEGIN和END之间已给出的源程序使其完整,空白已经用横线标出,每行空白一般只需要—条指令,但采用功能相当的多条指令也行,考生也可以删除BEGIN和END之间原有的代码并自行编程来完成要求的功能。
对程序必须进行汇编,并与IO.OBJ链接产生可执行文件,最终运行程序产生结果。调试中若发现整个程序中存在错误之处,请加以修改。
【试题程序】
TRN OAD:FAR,SAVE:FAR
NEQU 10
SSEG SEGMENT TACK
B256 DUP ()
SSEG NDS
DSEG EGMENT
SOURCE DB N*2 DUP ()
RESULT DW N+1 DUP (0)
NAME0 DB ’INPUT.DAT’,0
NAME1 DB ’OUTPUT.DAT’,0
DSEG DS
CSEG EGMENTSSUME CS:CSEG,DS:DSEG,SS:SSEG
START PROC FAR
USH S
OR AX,AX
USH X
OV AX,DSEG
OV DS,AX
EA DX,SOURCE
EA SI,NAME0
OV CX,N*2ALL GAD
; ******** BEGIN ********
EA SI, SOURCE
EA DI,RESULT
OV CX,N
AGAIN0: (1)
OV AL,[SI]
DD AL,[SI+1]
DC AH,0
OV [DI],AX
DD SI, (2)
(3)
OOP GAIN0
OV BX,N-1
OV SI,OFFSET RESULT
OV AX,[SI]
AGAIN1: ADD SI, 2
MP AX,[SI]
(4)
OV AX,[SI]
NEXT: DEC BX
NZ AGAIN1
(5)
; ******** END ********
EA DX,RESULT
EA SI,NAME1
OV CX,N+1
ALL AVE
ET
START ENDP
CSEG ENDS
END START

答案

参考答案:

(A) MOV AX,0 (B) B

(C) ADD DI,B (D) JAE NEXT (E) MOV[SI+B],AX

解析:

从程序的整体结构可以看出程序首先进行的是求和运算,并将结果存入从RESULT开始的存储单元中。求和结束以后,再求RESULT中数据的最大值。

第一个循环AGAIN0用来对SOURCE中相邻的数据求和,并存入RESULT中。为了使上一次的相加结果不影响后面的运算,需要在每一次进入循环的时候将AX寄存器清零,因此第一个空白处应该填写的内容为MOV AX,0(或XOR AX,AX或 SUB AX,AX)。本程序的加法运算过程中,指针的变化要特别注意。由于是对相邻两个数据进行求和,所以尽管SOURCE中的数据是字节类型,但由于一次操作需要使用两个数据,所以SI指针的变化每次应该是2,也就是说一次加法使用两个数据以后,下一次要从第三个数据开始,所以第二个空白处应填2。指向RESULT的指针也要变化,由于RESULT是字类型,因此指针的变化也应该是2,所以第三个空白处应该是DI增加2,即ADD DI,2。

寻找最大值采用的算法是逐个比较法,即将存储单元中的第一个数取到AX寄存器中,然后逐个与存储单元的内容进行比较,如果AX寄存器中的数据大,则进行下一次比较,否则将存储单元中的内容传送到AX中,这样在比较结束时,AX中的内容便是这一组数中的最大值。在程序中,首先将用米控制循环次数的内容送到BX寄存器中,然后将存储单元的偏移地址送到寄存器SI中。将第一个数据取入AX寄存器后,便开始比较,显然第四个空白处应该填写的内容是一个跳转语句,从下面 MOV AX,[SI]可以知道跳转的条件应该是AX中的数据大于[SI]中的数据,所以应使用JAE指令。由于需要修改指针并且判断比较是否结束,因此应该跳转到NEXT处,即第四个空白处的程序是JAE NEXT。最后一个语句实现的是将最大值存入RESULT的最后一个存储单元,由于在比较时,SI已经指到了RESULT中的最后一个数据,所以只需要将指针SI再加2就指向了RESULT的最后一个存储单元,即第五个空应填的内容为MOV [SI+2],AX。

单项选择题 A1型题
阅读理解

It was once thought that air pollution affected only the area immediately around large cities with factories and/or heavy automobile traffic. Today, we know that although these are the areas with the worst air pollution, the problem is literally worldwide. On several occasions over the past decade, a heavy cloud of air pollution has covered the entire eastern half of the United States and led to health warnings even in rural areas away from any major concentration of manufacturing and automobile traffic. In fact, the very climate of the entire earth may be affected by air pollution. Some scientists feel that the increasing concentration of carbon dioxide in the air resulting from the burning of fossil fuels(coal and oil) creating a greenhouse effect-holding in heat reflected from the earth and raising the world’s average temperature. If this view is correct and the world’s temperature is raised only a few degrees, much of the polar ice cap will melt and cities such as New York, Boston, Miami, and New Orleans will be under water.

Another view, less widely held, is that increasing particulate matter in the atmosphere is blocking sunlight and lowering the earth’s temperature-a result that would be equally disastrous(灾难的). A drop of just a few degrees could create something close to a new ice age, and would make agriculture difficult or impossible in many of our top farming areas. At present we do riot know for sure that either of these conditions will happen(though one recent government report prepared by experts in the field concluded that the greenhouse effect is very likely). Perhaps, if we very lucky, the two tendencies will offset each other and the world’s temperature will stay about the same as it is now.

小题1:As pointed out at the beginning of the passage, people used to think that air pollution ______.

A.caused widespread damage in the countryside

B.affected the entire eastern half of the United States

C.almost brought worldwide effect

D.existed merely in urban and industrial areas小题2:As far as the greenhouse effect is concerned, the author _____________.

A.shares the same view with the scientists

B.is uncertain of its occurrence

C.rejects it as being ungrounded(无根据的)

D.thinks that it will increasingly destroy the world soon小题3:It can be inferred from the passage that                   .

A.raising the world’s temperature a little would not do much harm to life on the earth

B.lowering the world’s temperature a little would lead to agricultural disasters

C.almost no temperature variations have occurred over the past decade

D.the world’s temperature will remain stable forever小题4:This passage is primarily concerned with             .

A.the greenhouse effect in the world

B.the measures to adjust the climate

C.the potential effect of air pollution

D.the measures to protect the environment