例子:写一个在字符串1后追加字符串2的子程序。折字符串均为0结尾
DSEG SEGMENT
BUFFER1 DB 'Hello World ',0
DB 50 DUP (0)
BUFFER2 DB ' Welcome !!!',0
DSEG ENDS
CSEG SEGMENT
ASSUME DS:DSEG,CS:CSEG
START:
MOV AX,DSEG
MOV DS,AX
;
MOV SI,OFFSET BUFFER1
CALL DMESS
CALL NEWLINE ;显示buff1信息
;
MOV SI,OFFSET BUFFER2
CALL DMESS
CALL NEWLINE ;显示buff2信息
;
MOV SI,OFFSET BUFFER1
MOV DI,OFFSET BUFFER2
CALL STRCAT ;将字符串2添加到字符串1中
MOV SI,OFFSET BUFFER1
CALL DMESS ;显示添加之后的字符串
CALL NEWLINE
MOV AX,4C00H
INT 21H
;子程序名:DMESS
;功 能:显示一个以0结尾的字符串
;入口参数:SI = 显示字符串的首地址
;出口参数:无
DMESS PROC
DMESS1: MOV DL,[SI]
INC SI
OR DL,DL ;OR操作使CF=0,ZF会反映运算结果
JZ DMESS2
MOV AH,2
INT 21H
JMP DMESS1
DMESS2: RET
DMESS ENDP
NEWLI