nl DB 13, 10, '$' ,int 21h详解
#make_COM#
ORG 100H
; set data segment:
MOV AX, CS
MOV DS, AX
MOV ES, AX
; input a string:
MOV DX, OFFSET s1
MOV AH, 0AH
INT 21h
; get one line down,by printing new line characters: //13 10 "$"打印一个换行
MOV DX, offset nl
MOV AH, 9
INT 21h
; set '$' to the end of inputed string: //为输入的字符串加入 '$'
MOV DI, offset s1
XOR BX, BX
; second byte of buffer holds ,the number of inputed,characters : //buffer的第二个字节为字符的长度,即[DI+1]=
MOV BL, [DI+1] //如果你输入wanghj,那么[DI+1]=6,bl也等于6,bx也等于6
MOV BYTE PTR [DI+BX+2], '$' //所以'$' 放在第8个字节的地方,也是wanghj的尾部
; print the entered string:
MOV DX, offset s1
; first byte is buffer size, second actual characters; //0放的是能输入的最大字符,1放的是输入字符的个数,所以要跳过这两个字符
; these 2 bytes:
ADD DX, 2
MOV AH, 9
INT 21h
; exit to operating
; system:
MOV AH, 4Ch
INT 21h
; data:
s1 DB 30, 30 dup(' ')
nl DB 13, 10, '$'
END
posted on 2011-05-15 09:37 wanghj_dz 阅读(1106) 评论(0) 编辑 收藏 举报