问题详情

为下列数据段中的数组编制一程序,调用题7.16的宏定义SUMMING,求出该数组中各元素之和。DATADD 101246,274365,843250,475536SUMDQ?


时间:2022-01-05 12:24 关键词: 汇编语言程序设计 计算机科学技术

答案解析

<p> 程序如下:<br> SUMMING MACRO ARRAY,COUNT,RESULT<br> LOCAL ADDITION<br> MOV ESI,0<br> MOV ECX,COUNT<br> ADDITION:MOV EAX,ARRAY[ESI*4];;双字为4字节<br> ADD RESULT,EAX<br> ADC RESULT+4,0;;将进位加到结果的高位双字中<br> INC ESI<br> LOOP ADDITION<br> ENDM<br> .MODEL SMALL<br> .386<br> .DATA<br> DATADD101246,274365,843250,475536<br> SUMDQ?<br> .CODE<br> START:MOV AX,@DATA<br> MOV DS,AX<br> SUMMING DATA,4,SUM<br> MOV AX,4C00H<br> INT 21H<br> END START</p>