编程:在屏幕中间分别显示绿色、绿底红色、白底蓝色的字符串 'welcome to masm!'。
【解析】先将字符属性存在dx寄存器的高八位dh中,再将字符的ASCII码存在dx寄存器的低八位dl中,然后将dx写入显存中。使用两层循环,内层将ASCII码存入dl并将dx写入显存,循环16次;外层改变属性,循环3次。
用到的寄存器及作用:ds(指向data处的第一个字节),
【实例】
assume cs:code,ds:data,ss:stack
data segment
db 'welcome to masm!'
db 02h,24h,71h
data ends
stack segment
db 16 dup (0)
stack ends
code segment
start:
mov ax,data
mov ds,ax
mov bx,0
mov di,16
mov ax,stack
mov ss,ax
mov sp,16
mov ax,0b800h
mov es,ax
mov si,160*12+64
mov cx,3
s0: mov dh,ds:[di]
push cx
mov cx,16
s1: mov dl,ds:[bx]
mov es:[si],dx
inc bx
add si,2
loop s1
mov bx,0
inc di
add si,128
pop cx
loop s0
mov ax,4c00h
int 21h
code ends
end start
标签:16,汇编语言,mov,实验,dx,ax,data,ds,王爽 From: https://www.cnblogs.com/hellomydaughter/p/17497311.html