整数求和程序的流程设计和实现
来源:互联网 发布:网络写手签约哪个网站 编辑:程序博客网 时间:2024/06/09 23:02
流程设计如下:
TITLE Integer Summation Program ;This program prompts the user for three integers;stores them in an array,calculates the sum of the;array,and displays the sumINCLUDE Irvine32.inc.codemain PROC;MAIN program control procedure;Calls: Clrscr,PromptForIntergers;ArraySum,DisplaySum;---------------------------------------------------PromptForIntegers PROC;;Prompts the user for three integers,inserts them in ;an array.;Receives:ESI points to an array of DW integers,;ECX = array size;Returns:nothing;Calls:ReadInt,WriteString;---------------------------------------------------retPromptForIntegers ENDP;---------------------------------------------------ArraySum PROC;;Calculates the sum of an array of 32-bit integers.;Receives:ESI points to the array,ECX =array size;Returns:EAX = the sum of the array elements;---------------------------------------------------retArraySum ENDP;---------------------------------------------------DisplaySum PROC;;Displays the sum on the scr;Receives:EAX=the sum;Returns:nothing;Calls:WriteString,WriteInt;---------------------------------------------------retDisplaySum ENDPEND main
实现后如下:
TITLE Integer Summation Program ;This program prompts the user for three integers;stores them in an array,calculates the sum of the;array,and displays the sumINCLUDE Irvine32.incINTEGER_COUNT=3.datastr1 BYTE "Enter a signed integer:",0str2 BYTE "The sum of the integer is:",0array DWORD INTEGER_COUNT DUP(?).codemain PROCcall Clrscrmov esi,OFFSET arraymov ecx,INTEGER_COUNTcall PromptForIntegerscall ArraySumcall DisplaySUmexitmain ENDP;---------------------------------------------------PromptForIntegers PROC USES ecx edx esi;;Prompts the user for three integers,inserts them in ;an array.;Receives:ESI points to an array of DW integers,;ECX = array size;Returns:nothing;Calls:ReadInt,WriteString;---------------------------------------------------mov edx,OFFSET str1L1:call WriteStringcall ReadIntcall Crlfmov [esi],eaxadd esi,TYPE DWORDloop L1retPromptForIntegers ENDP;---------------------------------------------------ArraySum PROC USES esi ecx;;Calculates the sum of an array of 32-bit integers.;Receives:ESI points to the array,ECX =array size;Returns:EAX = the sum of the array elements;---------------------------------------------------mov eax,0L1:add eax,[esi]add esi,TYPE DWORDloop L1retArraySum ENDP;---------------------------------------------------DisplaySum PROC USES edx;;Displays the sum on the scr;Receives:EAX=the sum;Returns:nothing;Calls:WriteString,WriteInt;---------------------------------------------------mov edx,OFFSET str2call WriteStringcall WriteIntcall CrlfretDisplaySum ENDPEND main总结: 写个汇编真麻烦。、
0 0
- 整数求和程序的流程设计和实现
- 用户输入一串整数和任意数目的空格,程序自动对所有的整数进行求和
- demo1.c(实现1~整数n的求和)
- 游戏程序:定时器的设计和实现
- 利用数组结构实现大整数求和
- Java递归实现整数各位求和
- 整数求和
- 整数求和
- 整数求和
- 整数求和
- 整数求和
- 实现两个整数交换的宏程序
- 设计一个完整程序的流程
- 《编程之美 》2.1 位运算实现—交换两个整数、求和、整数的二进制表达中1的个数
- 1091 符号变化的整数数列求和
- 1097 特殊的整数数列求和
- 【忙啊忙】- 两个字符串的大整数求和
- a到b之间的整数求和
- 黑马程序员---java基础---异常处理
- 欧拉-拉格朗日方程
- 引用参数与引用返回值
- #define
- Linux进程间的通信(一)
- 整数求和程序的流程设计和实现
- 畅通工程续(1874)hdu最短路径算法—Floyd
- App Extension编程指南(iOS8/OS X v10.10):扩展类型--Today
- bzoj 1026——windy 数
- 『IOS』xcode 编译器禁用 ARC (Automatic Referencing Counting)
- mysql主从复制--傻瓜式操作
- 打印-杨辉三角
- HTTPCLIENT总结
- nyoj 113 字符串替换