assume cs:codesg,es:datasg,ss:stacksg
datasg segment
db 'welcome to masm!' //要显示的字符串,共16个byte
db 11000010B //第一种字体属性,红底闪烁绿字
datasg ends
stacksg segment
db 16 dup (0) //定义栈段,16个字节,用于保存cx的值,因为有2层loop
stacksg ends
codesg segment
start:
mov ax , 0B800h //字符缓冲区内存起始段地址
mov ds , ax
mov bx , 720h //我要把文件显示在第11,12,13三行的中间的32个字节(16个字节文字,16个字节属性),这么推算出这个偏移地址
mov si , 0 //要写入的区域的偏移地址,ds:[bx+si]共同构成最终的写入地址
mov ax , datasg
mov es , ax //datasg段地址存放到es段寄存器
mov di , 0 //遍历字符串”welcome to masm!"的编译量,从0到15,loop 三次
mov bp , 10h //字体属性偏移量
mov cx , 3 //要写3行文字
mov ax , stacksg
mov ss , ax
mov sp , 10h
s:
push cx
mov cx , 16
t:
mov al , es:[di]
mov [bx+si] , al
inc si
inc di
mov al , es:[bp]
mov [bx+si] , al
inc si
loop t
mov si , 0
mov di , 0
add bx , 0A0h
inc bp
pop cx
loop s
mov ax , 4c00h
int 21h
codesg ends
datasg segment
db 'welcome to masm!' //要显示的字符串,共16个byte
db 11000010B //第一种字体属性,红底闪烁绿字
db 00000111B //第二种字体属性,黑底白字
db 01110001B //第三种字体属性,白底蓝字datasg ends
stacksg segment
db 16 dup (0) //定义栈段,16个字节,用于保存cx的值,因为有2层loop
stacksg ends
codesg segment
start:
mov ax , 0B800h //字符缓冲区内存起始段地址
mov ds , ax
mov bx , 720h //我要把文件显示在第11,12,13三行的中间的32个字节(16个字节文字,16个字节属性),这么推算出这个偏移地址
mov si , 0 //要写入的区域的偏移地址,ds:[bx+si]共同构成最终的写入地址
mov ax , datasg
mov es , ax //datasg段地址存放到es段寄存器
mov di , 0 //遍历字符串”welcome to masm!"的编译量,从0到15,loop 三次
mov bp , 10h //字体属性偏移量
mov cx , 3 //要写3行文字
mov ax , stacksg
mov ss , ax
mov sp , 10h
s:
push cx
mov cx , 16
t:
mov al , es:[di]
mov [bx+si] , al
inc si
inc di
mov al , es:[bp]
mov [bx+si] , al
inc si
loop t
mov si , 0
mov di , 0
add bx , 0A0h
inc bp
pop cx
loop s
mov ax , 4c00h
int 21h
codesg ends
end start