问答题

编制一个程序,其功能是:计算内存中连续存放的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
N EQU 10
SSEG SEGMENT TACK
B 256 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 EGMENT SSUME 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*2 ALL 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

热门 试题

问答题
As the importance of recycling becomes more apparent, questions about it linger. Is it worth the effort How does it work Is recycling waste just going into a landfill in China Here are some answers. It is an awful lot of rubbish. Since 1960 the amount of municipal waste being collected in America has nearly tripled, reaching 245m tonnes in 2005. According to European Union statistics, the amount of municipal waste produced in western Europe increased by 23% between 1995 and 2003, to reach 577kg per person. (So much for the plan to reduce waste per person to 300kg by 2000.) As the volume of waste has increased, so have recycling efforts. In 1980 America recycled only 9.6% of its municipal rubbish ; today the rate stands at 32%. A similar trend can be seen in Europe, where some countries, such as Austria and the Netherlands, now recycle 60% or more of their municipal waste. Britain’s recycling rate, at 27%, is low, but it is improving fast, having nearly doubled in the past three years. Even so, when a city introduces a kerbside recycling programme, the sight of all those recycling lorries trundling around can raise doubts about whether the collection and transportation of waste materials requires more energy than it saves. We are constantly being asked: Is recycling worth doing on environmental grounds says Julian Parfitt, principal analyst at Waste & Resources Action Programme (WRAP), a non-profit British company that encourages recycling and develops markets for recycled materials. Studies that look at the entire life cycle of a particular material can shed light on this question in a particular case, but WRAP decided to take a broader look. It asked the Technical University of Denmark and the Danish Topic Centre on Waste to conduct a review of 55 life-cycle analyses, all of which were selected because of their rigorous methodology. The researchers then looked at more than 200 scenarios, comparing the impact of recycling with that of burying or burning particular types of waste material. They found that in 83% of all scenarios that included recycling, it was indeed better for the environment. Based on this study, WRAP calculated that Britain’s recycling efforts reduce its carbon-dioxide emissions by 10m-15m tonnes per year. That is equivalent to a 10% reduction in Britain’s annual carbon-dioxide emissions from transport, or roughly equivalent to taking 3.5m cars off the roads. Similarly, America’s Environmental Protection Agency estimates that recycling reduced the country’s carbon emissions by 49m tonnes in 2005. Recycling has many other benefits, too. It conserves natural resources. It also reduces the amount of waste that is buried or burnt, hardly ideal ways to get rid of the stuff. (Landfills take up valuable space and emit methane, a potent greenhouse gas; and although incinerators are not as polluting as they once were, they still produce noxious emissions, so people dislike having them around.) But perhaps the most valuable benefit of recycling is the saving in energy and the reduction in greenhouse gases and pollution that result when scrap materials are substituted for virgin feed-stock. If you can use recycled materials, you don’t have to mine ores, cut trees and drill for oil as much, says Jeffrey Morris of Sound Resource Management, a consulting firm based in Olympia, Washington. Extracting metals from ore, in particular, is extremely energy-intensive. Recycling aluminium, for example, can reduce energy consumption by as much as 95%. Savings for other materials are lower but still substantial: about 70% for plastics, 60% for steel, 40% for paper and 30% for glass. Recycling also reduces emissions of pollutants that can cause smog, acid rain and the conta-mination of waterways.