王爽《汇编语言》第3版 实验 9 根据材料编程
warning:
这篇文章距离上次修改已过714天,其中的内容可能已经有所变动。
assume ds:datasg,cs:codesg
datasg segment
db 'welcome to masm!'
db 02h,24h,71h ;分别代表绿字,绿地红字,白底蓝字
datasg ends
codesg segment
start:
mov ax,0B878h
mov ds,ax ;设置要写入的内存地址为显存区域大概 13 行位置 160*12=1920=780h
mov cx,16 ;16 个字符,所以要 loop 16 次
mov bx,60 ;设置列位置
mov ax,datasg
mov es,ax ;把字符串数据放到 es
mov bp,0 ;记数,用于读取 welcome....
mov si,0 ;记数,用于读取 02h,24h,71h;
s16:
mov al,es:[bp] ;依次读取 welcome... 放入 al
mov dx,cx ;备份好 cx
mov ch,0
mov cl,al
sub cl,20h ;如果当前读的字符是空格就换显示的样式
jcxz changstyle
mov ah,es:[si+16] ;把显示样式写入ah
jmp notspace ;如果当前读取的字符不是空格,就跳过更换样式的代码
changstyle:
inc si ;更换字体的显示样式
mov ah,00h ;如果是空格就没有样式
notspace:
mov [bx],ax ; 显示到屏幕上
add bx,2
inc bp
mov cx,dx ;还原 cx 继续进行 loop 循环
loop s16
mov ax,4c00h
int 21h
codesg ends
end start
1718959974877.png