本文为《汇编语言程序设计》1302小节例程。

任务:在屏幕的5行12列显示3个红底高亮闪烁绿色的’a’

程序:

assume cs:code
code segment
mov ah,2 ;置光标功能
mov bh,0 ;第0页
mov dh,5 ;dh中放行号
mov dl,12 ;dl中放列号
int 10h

mov ah,9 ;显示字符功能
mov al,'a' ;字符
mov bl,11001010b;颜色属性
mov bh,0 ;第0页
mov cx,3 ;字符重复个数
int 10h

mov ax,4c00h
int 21h
code ends
end

任务:调用BIOS中断置灰色背景并清屏

assume cs:code
code segment
mov ax, 0600H
mov BH, 71H
mov cx, 0000H
mov dx, 184FH
int 10h

mov ax,4c00h
int 21h
code ends
end

例:编程在屏幕的5行12列显示字符串“welcome to masm!”。

程序:

assume cs:code
data segment
db 'Welcome to masm!','$'
data ends

code segment
start: mov ah,2 ; 置光标
mov bh,0 ; 第0页
mov dh,5 ; dh中放行号
mov dl,12 ; dl中放列号
int 10h

mov ax,data
mov ds,ax
mov dx,0 ;ds:dx指向字符串的首地址data:0
mov ah,9
int 21h

mov ax,4c00h
int 21h

code ends
end start