例题程序清单精简Word文档格式.docx
《例题程序清单精简Word文档格式.docx》由会员分享,可在线阅读,更多相关《例题程序清单精简Word文档格式.docx(17页珍藏版)》请在冰点文库上搜索。
PUSHDS
MOVAX,0
PUSHAX
MOVAX,DATA
MOVDS,AX
MOVAH,9
LEADX,INPUT
INT21H
MOVAH,1
ANDAL,0FH
MOVXX,AL
MOVBX,OFFSETTABLE
MOVAH,0
MOVAL,XX
ADDBX,AX
MOVAL,[BX]
MOVYY,AL
RET
STARTENDP
CODEENDS
ENDSTART
exp3.asm
;
sample分支结构
XXDB56
STACKSEGMENTPARASTACK
DB256DUP(?
START:
MOVAL,[XX]
CMPAL,0
JGEBIGER
MOVAL,-1
JMPEQUL
BIGER:
JEEQUL
MOVAL,1
EQUL:
MOVAH,4CH
exp5.asm
sample分支结构跳转表
BASEDWSBR0,SBR1,SBR2,SBR3
BNDB3
MOVBL,BN
MOVBH,0
SHLBX,1
JMPBASE[BX]
SBR0:
MOVAH,2
MOVDL,'
0'
SBR1:
1'
SBR2:
2'
SBR3:
3'
exp52.asm
sample分支结构跳转指令表
BNDB3
MOVAL,BN
ADDAX,AX
MOVBX,OFFSETBASE
JMPBX
BASE:
JMPSBR0
JMPSBR1
JMPSBR2
JMPSBR3
ENDSTART
EXP6.ASMsample循环结构统计数据块负数的个数
BUFDB-1,3,5,-7,99,-120,127,-128,56,2
CUNTEQU$-BUF
SUMDW?
MAIN:
LEABX,BUF
MOVCX,CUNT
MOVDX,0
LP1:
ANDAL,AL
JNSPLUS
INCDX
PLUS:
INCBX
LOOPLP1
MOVSUM,DX
ENDMAIN
EXP7.ASMsample循环结构
CODESEGMENT
CODE
MOVCX,0
LP:
ANDAX,AX
JZEXIT
SALAX,1
JNCZERO
INCCX
ZERO:
JMPLP
EXIT:
ENDMAIN
EXP8.asm
DATASEGMENT
BUFDB02H,38H,47H,33H,09H,76H,7BH,23H
CUNTEQU$-BUF
SUMDB3DUP(0)
MOVBX,0
MOVAL,BUF[BX]
CMPAL,30H
JBNEXT
CMPAL,39H
JAABC1
INCSUM[0]
JMPNEXT
ABC1:
CMPAL,’A’
CMPAL,’Z’
JAabc2
INCSUM[1]
abc2:
CMPAL,’a’
CMPAL,’z’
JANEXT
INCSUM[2]
NEXT:
INCBX
EXP9.ASMsample子程序调用寄存器传递参数
BUFFER1DB90,-56,98,12,68,-100,37,15,-4
CUNT1EQU$-BUFFER1
RESULT1DW?
BUFFER2DB101,32,-89,16,82,25,91,84,71
CUNT2EQU$-BUFFER2
RESULT2DW?
MOVSI,OFFSETBUFFER1
MOVCX,CUNT1
CALLSUM
MOVRESULT1,AX
MOVSI,OFFSETBUFFER2
MOVCX,CUNT2
MOVRESULT2,AX
入口参数:
SI:
数组首地址,CX:
数组长度
出口参数:
AX:
求和
SUMPROC
CMPCX,0
JZEXIT
AGAIN:
PUSHAX
MOVAL,[SI]
CBW
MOVBX,AX
POPAX
ADDAX,BX
INCSI
LOOPAGAIN
RET
SUMENDP
sample子程序调用参数地址表传递参数
BUFFERDB11,22,33,44,55,66,77,88,99,101,111,122
CUNTDW$-BUFFER
RESULTDW?
TABLEDW3DUP(?
MOV[TABLE],OFFSETBUFFER
MOV[TABLE+2],OFFSETCUNT
MOV[TABLE+4],OFFSETRESULT
LEABX,TABLE
入口参数BX:
参数地址表的首地址
MOVSI,[BX]
MOVBP,[BX+2]
MOVCX,DS:
[BP]
MOVDI,[BX+4]
MOVAX,0
ADDAL,[SI]
ADCAH,0
MOV[DI],AX
sample子程序调用堆栈传递参数
ARRAYDB11,22,33,44,55,66,77,88,99,101,111,122
CUNTDW$-ARRAY
RESULTDW?
LEABX,ARRAY
PUSHBX
LEABX,CUNT
LEABX,RESULT
CALLfarptrSUM
CODE2SEGMENT
CODE2
SUMPROCFAR
PUSHCX
PUSHBP
MOVbp,SP
MOVBX,[BP+14]
MOVCX,[BX]
MOVBX,[BP+12]
MOVSI,[BP+16]
CMPCX,0
MOV[BX],AX
POPBP
POPCX
POPBX
POPAX
RET6
CODE2ENDS
ENDmain
EXP10.ASM
ARYDB56H,78H,12H,99H,34H,23H,32H;
BCDcode
CUNTDW$-ARY
LEABX,ARY
MOVBP,SP
DAA
MOVDL,AL
MOVAL,0
ADCAL,AH
MOVAH,AL
MOVAL,DL
INCSI