1、組合語言實習報告整數加總程式指導老師:邱正毅班級:資工一姓名: 黃偉哲 學號:4980E033TITLE Integer Summation Program (Sum1.asm) 整數加法程式; This program inputs multiple integers from the user, 程式告訴使用者有多個整數輸入; stores them in an array, calculates the sum of the並將它們存儲在一個陣列中,計算總和; array, and displays the sum. Chapter 5 example.陣列,並顯示總和。第 5 章的例子
2、。INCLUDE Irvine32.inc.data資料first DWORD 2323423424第一個 DWORD 2323423424second BYTE “adjaslfdjsl“第二個字串“adjaslfdjsl” .code代碼main PROC主程式 PROC; Main program control procedure.主程式的控制程序; Calls: Clrscr, PromptForIntegers,呼叫:Clrscr,PromptForIntegers,; ArraySum, DisplaySumArraySum,DisplaySumExit 退出main ENDP
3、主要 ENDP ;-PromptForIntegers PROC;Prompts the user for an array of integers, and提示使用者為一個陣列的整數,; fills the array with the users input.然後將他們插入陣列中。; Receives: ESI points to an array of接收的參數:ESI 指向陣列; doubleword integers, ECX = array size.雙字組整數,ECX= 陣列大小; Returns: the array contains the values回傳:陣列包含的數值
4、; entered by the user由使用者輸入; Calls: ReadInt, WriteString呼叫: ReadInt,WriteString ;-retPromptForIntegers ENDP;-ArraySum PROC;陣列元素的總和; Calculates the sum of an array of 32-bit integers.計算 32 位元整數的陣列的總和; Receives: ESI points to the array, ECX = array size接收參數: ESI 指向陣列,ECX=陣列大小; Returns: EAX = sum of th
5、e array elements回傳:EAX= 陣列元素的總和;-retArraySum ENDP;-DisplaySum PROC; Displays the sum on the screen將總和顯示在螢幕上; Recevies: EAX = the sum接收參數:EAX= 總和; Calls: WriteString, WriteInt呼叫程序: WriteString, WriteInt;-retDisplaySum ENDPEND main整數加法程式程式告訴使用者有多個整數輸入並將它們存儲在一個陣列中,計算總和陣列,並顯示總和。第 5 章的例子。資料第一個 DWORD 2323
6、423424第二個字串“adjaslfdjsl” 代碼主程式 PROC主程式的控制程序呼叫:Clrscr,PromptForIntegers,Exit 退出主要 ENDP 提示使用者為一個陣列的整數,然後將他們插入陣列中。接收的參數:ESI 指向陣列雙字組整數,ECX= 陣列大小回傳:陣列包含的數值由使用者輸入呼叫: ReadInt,WriteString陣列元素的總和計算 32 位元整數的陣列的總和接收參數: ESI 指向陣列,ECX=陣列大小回傳:EAX= 陣列元素的總和將總和顯示在螢幕上接收參數:EAX= 總和呼叫程序: WriteString, WriteIntTITLE Intege
7、r Summation Program (Sum1.asm); This program inputs multiple integers from the user,; stores them in an array, calculates the sum of the; array, and displays the sum. Chapter 5 example.INCLUDE Irvine32.inc.datafirst DWORD 2323423424second BYTE “adjaslfdjsl“.codemain PROC; Main program control proced
8、ure.; Calls: Clrscr, PromptForIntegers,; ArraySum, DisplaySumexitmain ENDP;-PromptForIntegers PROC; Prompts the user for an array of integers, and; fills the array with the users input.; Receives: ESI points to an array of; doubleword integers, ECX = array size.; Returns: the array contains the valu
9、es; entered by the user; 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 = sum of the array elements;-retArraySum ENDP;-DisplaySum PROC; Displays the sum on the screen; Recevies: EAX = the sum; Calls: WriteString, WriteInt;-retDisplaySum ENDPEND main