《组合语言》由会员分享,可在线阅读,更多相关《组合语言(6页珍藏版)》请在金锄头文库上搜索。
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. 陣列,並顯示總和。第
2、 5 章的例子。 INCLUDE Irvine32.inc .data 資料 first DWORD 2323423424 第一個 DWORD 2323423424 second BYTE “adjaslfdjsl“ 第二個字串“adjaslfdjsl” .code 代碼 main PROC 主程式 PROC ; Main program control procedure. 主程式的控制程序 ; Calls: Clrscr, PromptForIntegers, 呼叫:Clrscr,PromptForIntegers, ; ArraySum, DisplaySum ArraySum,Disp
3、laySum Exit 退出 main ENDP 主要 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 arr
4、ay contains the values 回傳:陣列包含的數值 ; entered by the user 由使用者輸入 ; Calls: ReadInt, WriteString 呼叫: ReadInt,WriteString ;- ret PromptForIntegers ENDP ;- ArraySum PROC ;陣列元素的總和 ; Calculates the sum of an array of 32-bit integers. 計算 32 位元整數的陣列的總和 ; Receives: ESI points to the array, ECX = array size 接收參
5、數: ESI 指向陣列,ECX=陣列大小 ; Returns: EAX = sum of the array elements 回傳:EAX=陣列元素的總和 ;- ret ArraySum ENDP ;- DisplaySum PROC ; Displays the sum on the screen 將總和顯示在螢幕上 ; Recevies: EAX = the sum 接收參數:EAX=總和 ; Calls: WriteString, WriteInt 呼叫程序: WriteString, WriteInt ;- ret DisplaySum ENDP END main整數加法程式 程式告
6、訴使用者有多個整數輸入 並將它們存儲在一個陣列中,計算總和 陣列,並顯示總和。第 5 章的例子。 資料 第一個 DWORD 2323423424第二個字串“adjaslfdjsl” 代碼 主程式 PROC 主程式的控制程序 呼叫:Clrscr,PromptForIntegers, Exit 退出主要 ENDP 提示使用者為一個陣列的整數, 然後將他們插入陣列中。 接收的參數:ESI 指向陣列 雙字組整數,ECX=陣列大小回傳:陣列包含的數值由使用者輸入呼叫: ReadInt,WriteString陣列元素的總和計算 32 位元整數的陣列的總和 接收參數: ESI 指向陣列,ECX=陣列大小 回
7、傳:EAX=陣列元素的總和 將總和顯示在螢幕上 接收參數:EAX=總和 呼叫程序: WriteString, WriteIntTITLE 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.INCLUDE Irvine32.inc.data first DWORD
8、2323423424 second BYTE “adjaslfdjsl“.code main PROC ; Main program control procedure. ; Calls: Clrscr, PromptForIntegers, ; ArraySum, DisplaySumexit main ENDP;- PromptForIntegers PROC ; ; Prompts the user for an array of integers, and ; fills the array with the users input. ; Receives: ESI points to
9、 an array of ; doubleword integers, ECX = array size. ; Returns: the array contains the values ; entered by the user ; Calls: ReadInt, WriteString ;- ret PromptForIntegers 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 ;- ret ArraySum ENDP;- DisplaySum PROC ; ; Displays the sum on the screen ; Recevies: EAX = the sum ; Calls: WriteString, WriteInt ;- ret DisplaySum ENDPEND main