;**********************************************************************
TITLE 整数求和
;**********************************************************************
;**********************************************************************
;*程序运行平台要求
.386
.model flat,stdcall
option casemap:none
;**********************************************************************
;**********************************************************************
;文件包含
INCLUDE Irvine32.inc
;**********************************************************************
;**********************************************************************
;宏定义部分
INTEGER_COUNT=5;
;**********************************************************************
;**********************************************************************
;数据段定义
.data
str1 byte "please Enter a integer",0dh,0ah,0
str2 byte "the sum of the input is",0
arrayByte byte INTEGER_COUNT DUP(0)
;**********************************************************************
;**********************************************************************
;代码段定义
.code
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;函数定义:显示提示信息,请用户输入
;函数参数:使用edx作为局部变量
WarnDis proc USES edx
mov edx,offset str1;
call WriteString;
ret
WarnDis endp
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;函数定义:给全局变量数组从用户输入处,进行赋值
;函数参数:esi ecx ebx
InputArray PROC USES esi ecx ebx
mov esi,offset arrayByte;
mov ebx,0
mov ecx,length arrayByte;
LInput:
call ReadInt
mov [esi+ebx],eax
inc ebx
loop LInput
ret
InputArray endp
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;函数定义:对数组进行求和过程
;函数参数:esi ecx ebx
Sum proc uses esi ecx ebx
mov esi,offset arrayByte;
mov ecx,length arrayByte
xor eax,eax
mov ebx,0
LSum:
mov dl,[esi+ebx]
add al,dl
;检测是否有进位发生
JC cfProc
JMP final
cfProc:
inc ah;
final:
inc ebx
loop LSum;
ret
Sum endp
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
main proc
call WarnDis
call InputArray
call Sum
call WriteInt
exit
main endp
end main
;**********************************************************************
标签:汇编,处理,模块化,mov,++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
From: https://blog.51cto.com/u_15995156/6166877