int21.asm

来自「汇编语言 参考书 包含作业与答案 从入门到精通 通俗易懂」· 汇编 代码 · 共 60 行

ASM
60
字号
; This sample gets a string
; from a user, and prints
; it out.
; It uses INT 21h, so it should
; not be compiled as BIN file!

#make_COM#

; COM file is loaded at 100h
; prefix:
        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:
        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:
        MOV BL, [DI+1]
        MOV BYTE PTR [DI+BX+2], '$'

; print the entered string:
        MOV DX, offset s1
; first byte is buffer size,
; second actual characters
; entered, we skip
; 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

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?