《匯編語言 廖建明主編 第六章習(xí)題答案》由會(huì)員分享,可在線閱讀,更多相關(guān)《匯編語言 廖建明主編 第六章習(xí)題答案(5頁珍藏版)》請(qǐng)?jiān)谘b配圖網(wǎng)上搜索。
1、第六章習(xí)題答案6.1 C6.2 D6.3 D6.4 C 6.5 B6.6 錯(cuò)。在L0: MOV AL,0語句后面加上RET語句6.7段內(nèi)調(diào)用:保存IP內(nèi)容入棧;更新IP內(nèi)容段間調(diào)用:保存CS,IP內(nèi)容入棧;更新CS,IP內(nèi)容6.8段內(nèi)返回:從棧中彈出一個(gè)字的內(nèi)容送入IP寄存器;SP=(SP)+n(如果帶有操作數(shù)n)段間返回:從棧中彈出兩個(gè)字的內(nèi)容分別送入IP,CS;SP=(SP)+n(如果帶有操作數(shù)n)6.9從棧中彈出兩個(gè)字的內(nèi)容分別送入IP,CS;SP=(SP)+46.10在需要和主程序共享寄存器的時(shí)候需要保護(hù)寄存器6.11寄存器傳遞參數(shù);堆棧傳遞參數(shù);地址表傳遞參數(shù)6.12相同點(diǎn):都進(jìn)行一
2、次程序跳轉(zhuǎn)不同點(diǎn):CALL會(huì)保存原地址IP入棧,而JMP不會(huì)6.13錯(cuò)誤:子程序是FAR類型的,CALL時(shí)用的是NEAR6.14BX;(BX);SHIFT6.15圖略6.16DATA SEGMENT N DB 5DATA ENDSSTACK SEGMENTDW 20H DUP(0)STACK ENDSCODE SEGMENTASSUME CS:CODE,DS:DATA,SS:STACKBEGIN:MOV AX,DATAMOV DS,AXMOV AL,NCALL FACT;調(diào)用階乘子程序計(jì)算5!MOV RESULT,DXDEC NMOV AL,NCALL FACT;調(diào)用階乘子程序計(jì)算4!ADD
3、RESULT,DXDEC NMOV AL,NCALL FACT;調(diào)用階乘子程序計(jì)算3!ADD RESULT,DXMOV AH,4CHINT 21HFACT PROC NEAR;階乘子程序MOV DX,1CMP AL,0JZ DONEPUSH AXDEC ALCALL FACTPOP AXMUL DLMOV DX,AXDONE:RETFACT ENDPCODE ENDSEND BEGIN6.17略618(1)寄存器傳值MOV AX,DATAMOV DS,AXMOV SI,OFFSET NUMMOV CX,COUNTMOV DX,0CALL FMOV AH,4CHINT 21HF PROCLOP:
4、MOV DI,OFFSET NUM20ADD DI,DXINC DXXOR BL,BLMOV AX,SILOP20:CMP AX,20JC SUB5SUB AX,20INT BLJMP LOP20SUB5:MOV DI,BLXOR BL,BLLOP5:CMP AX,5JC SUB2SUB AX,5INT BLJMP LOP5SUB2:ADD DI,COUNT; DI=DI+2*COUNTMOV DI,BLXOR BL,BLLOP2:CMP AX,2JC SUB1SUB AX,2INT BLJMP LOP2SUB1:ADD DI,COUNT SHL 1;DI=DI+2*COUNTMOV DI,B
5、LXOR BL,BLLOP1:CMP AX,1JC DONESUB AX,1INT BLJMP LOP1DONE:ADD DI,COUNT ADD DI,COUNTADD DI,COUNT;DI=DI+3*COUNTMOV DI,BLADD SI,2LOOP LOPRETF ENDPEODE ENDS(2)堆棧傳值BEGIN:MOV AX,DATAMOV DS,AXMOV SI,OFFSET NUMMOV DI OFFSET NUM20MOV CX,COUNTPUSH SIPUSH DIPUSH CXCALL FMOV AH,4CHINT 21HF PROCPUSH AXPUSH BXPUSH
6、 CXPUSH SIPUSH DIMOV BP,SPMOV CX,12BPMOV DI,14BPMOV SI,16BPLOP:XOR BL,BLMOV AX,SILOP20:CMP AX,20JC SUB5SUB AX,20INC BLJMP LOP20SUB5:MOV DI,BLXOR BL,BLLOP5:CMP AX,5JC SUB2SUB AX,5INC BLJMP LOP5SUB2:MOV DI+COUNT,BLXOR BL,BLLOP2:CMP AX,2JC SUB1SUB AX,2INC BLJMP LOP2SUB1:MOV DI+COUNT+COUNT,BLXOR BL,BLLOP1:CMP AX,1JC DONESUB AX,1INC BLJMP LOP1DONE:MOV DI+COUNT+COUNT+COUNT,BLADD SI,2INT DILOOP LOPRETF ENDPCODE ENDSEND BEGIN