汇编多整数求和
来源:互联网 发布:淘宝联盟升级高佣金 编辑:程序博客网 时间:2024/05/16 06:53
对用户输入的多个整数求和,并输出结果
TITLE Integer Summation ProgramINCLUDE Irvine32.incARRAY_SIZE = 20.data str1 BYTE "Enter a signed integer:",0 str2 BYTE "The sum of the integers is:",0 str3 BYTE "How many integers will be added? ",0 str4 BYTE "The array cannot be larger than 20",0ah,0 array DWORD ARRAY_SIZE DUP(?).code main PROCcall Clrscrmov esi,OFFSET arraymov ecx,ARRAY_SIZEcall panduan //判断读入的整数个数是否大于20call PromptForIntegerscall ArraySumcall DisplaySumexitmain endppanduan PROC USES edx mov edx,OFFSET str3 call WriteString call ReadInt call Crlf mov ebx,20 cmp ebx,eax mov edi,eax JNC L1 mov edx,OFFSET str4 call WriteString exitL1: retpanduan ENDPPromptForIntegers PROC USES ecx edx esimov edx,OFFSET str1 mov ecx,ediL1: call WriteString call ReadInt call Crlf mov [esi],eax add esi,TYPE DWORD loop L1 ret PromptForIntegers ENDPArraySum PROC USES esi ecx mov eax,0L1: add eax,[esi] add esi,TYPE DWORD loop L1 ret ArraySum ENDPDisplaySum PROC USES edx mov edx,OFFSET str2 call WriteString call WriteInt call CrlfretDisplaySum ENDPEND main
除显示多整数的和外,还分别显示这些整数中正整数的和负整数的和
TITLE Integer Summation ProgramINCLUDE Irvine32.incARRAY_SIZE = 20.data str1 BYTE "Enter a signed integer:",0 str2 BYTE "The sum of the positive integers is:",0 str3 BYTE "How many integers will be added? ",0 str4 BYTE "The array cannot be larger than 20",0ah,0 str5 BYTE "The sum of the negative integers is:",0 array DWORD ARRAY_SIZE DUP(?).code main PROCcall Clrscrmov esi,OFFSET arraymov ecx,ARRAY_SIZEcall panduancall PromptForIntegerscall ArraySumcall DisplaySumexitmain endppanduan PROC USES edx mov edx,OFFSET str3 call WriteString call ReadInt call Crlf mov ebx,20 cmp ebx,eax mov edi,eax JNC L1 mov edx,OFFSET str4 call WriteString exitL1: retpanduan ENDPPromptForIntegers PROC USES ecx edx esimov edx,OFFSET str1 mov ecx,ediL1: call WriteString call ReadInt call Crlf mov [esi],eax add esi,TYPE DWORD loop L1 ret PromptForIntegers ENDPArraySum PROC USES esi ecx mov eax,0 mov ebx,0 mov edx,0L1: cmp [esi],edx jl L2 add eax,[esi] jmp L3 L2: add ebx,[esi] L3: add esi,TYPE DWORD loop L1 ret ArraySum ENDPDisplaySum PROC USES edx mov edx,OFFSET str2 call WriteString call WriteInt call Crlf mov edx,OFFSET str5 mov eax,ebx call writestring call writeint call CrlfretDisplaySum ENDPEND main
- 通用寄存器eax, ebx, ecx, edx, esi, edi, ebp, esp
关于通用寄存器的相关解释
0 0
- 汇编多整数求和
- 汇编-求和
- 整数求和
- 整数求和
- 整数求和
- 整数求和
- 整数求和
- ARM汇编(1):若干整数数的最大值最小值问题、求和问题、平均数问题
- 汇编求和实验
- 大整数求和
- ;整数数组求和
- noj0001 - 整数求和
- NOJ-整数求和
- 大整数求和
- 大整数求和
- acm_整数求和
- PHP大整数求和
- 两个整数之间所有整数求和
- POJ 2431 Expedition 优先队列
- java学习——发送激活邮件-就这么简单
- Gradle在大型Java项目上的应用
- Android ListView功能扩展,实现高性能的瀑布流布局
- PAT 1016. Phone Bills (25)
- 汇编多整数求和
- java String StringBuilder StringBuffer 以及各种赋值和注意
- dcloud mui html5plus 5+sdk
- iOS 8 自适应 Cell
- Linux上Oracle 11g安装步骤图解
- Spring Security教程(7)---- 解决UsernameNotFoundException无法被捕获的问题
- Android自定义View的实现方法(四)
- 每天被面试虐一点点(四)
- 平凡人生