如果要用两个程序实现, 必须用实DOS,或者用DosBox。 我是用DosBox实现的。
安装和中断例程代码如下
assume cs:code
code segment
start: ;installtion
mov ax, cs
mov ds, ax
mov si, offset shwtxt
mov ax, 0
mov es, ax
mov di, 200h
mov cx, offset shwtxtend-offset shwtxt
cld
rep movsb
mov ax, 0
mov es, ax
mov word ptr es:[7ch*4], 200h
mov word ptr es:[7ch*4+2],0
mov ax, 4c00h
int 21h
shwtxt: push cx
push si
push bx
push ax
mov ah, 160
mul dh
mov bx, ax
mov ah, 32
mul dl
Add ax, bx
mov di, ax
pop ax
pop bx
mov ax, 0b800h
mov es, ax
mov al, cl
nxtchr: mov cl, [si]
mov ch, 0
jcxz ok
mov ch, al
mov es:[di], cx
add di, 2
inc si
jmp short nxtchr
ok: pop si
pop cx
iret
shwtxtend: nop
code ends
code segment
start: ;installtion
mov ax, cs
mov ds, ax
mov si, offset shwtxt
mov ax, 0
mov es, ax
mov di, 200h
mov cx, offset shwtxtend-offset shwtxt
cld
rep movsb
mov ax, 0
mov es, ax
mov word ptr es:[7ch*4], 200h
mov word ptr es:[7ch*4+2],0
mov ax, 4c00h
int 21h
shwtxt: push cx
push si
push bx
push ax
mov ah, 160
mul dh
mov bx, ax
mov ah, 32
mul dl
Add ax, bx
mov di, ax
pop ax
pop bx
mov ax, 0b800h
mov es, ax
mov al, cl
nxtchr: mov cl, [si]
mov ch, 0
jcxz ok
mov ch, al
mov es:[di], cx
add di, 2
inc si
jmp short nxtchr
ok: pop si
pop cx
iret
shwtxtend: nop
code ends
end start
运行和使用例程的程序如下
assume cs:code
data segment
db "welcome to masm!",0
data ends
code segment
start: mov dh, 12
mov dl, 8
mov cl, 01110001B
mov ax, data
mov ds, ax
mov si, 0
int 7ch
mov ax, 4c00h
int 21h
code ends
data segment
db "welcome to masm!",0
data ends
code segment
start: mov dh, 12
mov dl, 8
mov cl, 01110001B
mov ax, data
mov ds, ax
mov si, 0
int 7ch
mov ax, 4c00h
int 21h
code ends
end start