【正文】
umOf 程序 ? CALL 和 RET 指令 ? 巢狀程序呼叫 ? Local 和 Global 標(biāo)籤 ? 程序參數(shù) ? 流程表象徵 ? USES 運(yùn)算 35 創(chuàng)造程序 ? 大的問題能被區(qū)分為更小的工作使他們變成更易辦 ? 一個程序是美國金屬學(xué)會同等 Java 或 C++函數(shù) ? 下列各項是一個被命名的組合語言程序 ? 例子 : sample PROC . . ret sample ENDP 36 程序的註解說明 ? 所有工作的描述完成的藉著程序 . ? 接受:一連串的輸入?yún)?shù);陳述他們的用法和需求。 為每個程序建議了文件 : 如果一個程序沒有被滿意它的先決條件被叫,它可能將不生產(chǎn)預(yù)期的輸出 . 37 例子 :程序的總數(shù) 。 。 Receives: EAX, EBX, ECX, the three integers. May be 。 Returns: EAX = sum, and the status flags (Carry, 。 Requires: nothing 。 error L1:: 。 local label jmp L1 。 array index mov eax,0 。 set number of elements L1: add eax,myArray[esi] 。 point to next integer loop L1 。 store the sum ret ArraySum ENDP ArraySum 程序計算排列的總數(shù)。 Receives: ESI points to an array of doublewords, 。 Returns: EAX = sum 。 set the sum to zero L1: add eax,[esi] 。 point to next integer loop L1 。總數(shù)在 EAX 被復(fù)原 : 46 流程表符號 ? 下列的符號是流程表的基本方塊 : b e g in / e n dp r o c e s s ( t a s k )d e c is ionp r o c e d u r ec a lly e snoman u a l inp u td is p lay(包括在書的第 166 頁上不被列出的二個符號 .) 47 為 ArraySum 程序的流程表 b e g inp u s h e s i, e c xe a x = 0a d d e a x , [ e s i]a d d e s i, 4e c x 0 ?e c x = e c x ? 1y e snop o p e c x , e s iendAr ray Sum Proc e du re push esi push ecx mov eax,0AS1: add eax,[esi] add esi,4 loop AS1 pop ecx pop esi48 你輪到的 . . . 畫一個表達(dá)下列的 pseudocode的流程表 input exam grade from the user if( grade 70 ) display Pass else display Fail endif 49 . . . (解答 ) b e g ing r a d e 7 0 ?d is p lay P a s s d is p lay Failendinp u t e x a m g r a d ey e sno50 你輪到的 . . . ? 在先前的幻燈片中修正流程表讓使用者繼續(xù)輸入考試得分直到 1 的價值被進(jìn)入 51 USES 運(yùn)算 ? 列出將被保持的暫存器 ArraySum PROC USES esi ecx mov eax,0 。 sum of three integers push eax 。 2 add eax,ecx 。 4 ret SumOf ENDP 三個暫存器的總數(shù)被儲存在列 ( 3) 上的 EAX, 但是 pop協(xié)議指導(dǎo)以 EAX 對列的出發(fā)價值替換它 : ( 4) 53 下一章 ? 連結(jié)外部函式庫 ? 本書所用的連結(jié)函式庫 ? 堆疊運(yùn)算 ? 定義和使用程序 ? 運(yùn)用程序的程式設(shè)計 54 規(guī)劃使用程序的設(shè)計 ? 由上而下的設(shè)計 (功能的分解)包括下列各項: ? 在開始編碼之前設(shè)計你的計畫 ? 中斷大的工作進(jìn)入更小的一些 ? 使用以程序呼叫為基礎(chǔ)的階層的結(jié)構(gòu) ? 分開地測試個別的程序 55 整數(shù)總和計畫 (1 of 4) 主要部份步驟 : ? 為多個整數(shù)的提示使用者 ? 計算排列的總數(shù) ? 顯示總數(shù) 描述:寫一個對於多個 32 位元整數(shù)促使使用者的計畫,在排列中儲存他們,計算排列的總數(shù),而且顯示在螢?zāi)簧系目倲?shù) 。 清除螢?zāi)? PromptForIntegers WriteString 。 數(shù)入整數(shù) ArraySum 。 顯示字串 WriteInt