单字符输入输出
bash
;默认采用ML6.11汇编程序
DATAS SEGMENT
CHAR DB ?;CHAR存储输入的字符
CHANGELINE DB 13,10,'$';用来表示换行符
DATAS ENDS
STACKS SEGMENT
DB 128 DUP(?)
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
;输入字符
MOV AH,0
INT 16H
MOV CHAR,AL
;输出字符
MOV DL,CHAR
MOV AH,2
INT 21H
;输出换行符
MOV DX,OFFSET CHANGELINE
MOV AH,9
INT 21H
MOV AH,4CH
INT 21H
CODES ENDS
END START
字符串输入输出
bash
;默认采用ML6.11汇编程序
DATAS SEGMENT
CHANGELINE DB 13,10,'$';表示换行符
BUF DB 30,?,30 DUP(?) ;存储输入的字符串(DUP 数组)
DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
;输入字符串
LEA DX,BUF;字符串的存储地址
MOV AH,0AH
INT 21H
;输出字符串
MOV DX,OFFSET CHANGELINE
MOV AH,9
INT 21H
MOV AH,4CH
INT 21H
CODES ENDS
END START