int21.asm

来自「介绍用Java解析网络数据的三种特殊方法」· 汇编 代码 · 共 61 行

ASM
61
字号
; This sample gets a string
; from a user, and prints
; it out.
; INT 21h is used, thus
; DOS operating system is
; required.

#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 + -
显示快捷键?