从键盘输入字符串并输出该字符串(汇编语言)

时间:2022-02-05 01:28:29

原文地址http: //blog.sina.com.cn/s/blog_4b7bd3380100a76z.html



DATAS SEGMENT

STR   DB 'Please input a string:$'
BUF   DB 20
      DB ?
      DB 20 DUP(?)
CRLF  DB 0AH,0DH,'$'
  DATAS ENDS

STACKS SEGMENT
       DB 200 DUP(?)
STACKS ENDS

CODES SEGMENT
    ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
    MOV AX,DATAS
    MOV DS,AX
   
    LEA DX,STR
    MOV AH,9
    INT 21H
   
    MOV AH,10
    LEA DX,BUF
    INT 21H
   
    LEA DX,CRLF
    MOV AH,9
    INT 21H
   
    MOV AL,BUF+1
    ADD AL,2
    MOV AH,0
    MOV SI,AX
    MOV BUF[SI],24H
    LEA DX,BUF+2
    MOV AH,9
    INT 21H
   
   
    MOV AH,4CH
    INT 21H
CODES ENDS
    END START