实验要求:
显示绿色、红底绿色、白底蓝色的welcome to masm!
写了一段小代码:
显示结果:
其他实验要求只需把字体属性改一下。
为增加代码重用性。利用循环。
assume cs:code
data segment
db 'welcome to masm!'
db 2,24h,71h
data ends
stack segment
db 16 dup(0)
stack ends
code segment
start:mov ax,stack
mov ss,ax
mov sp,0
mov ax,data
mov ds,ax
mov cx,3
mov ax,0B800H
mov es,ax
mov si,10h
mov ax,0
s:
mov ah,ds:[si]
push cx
push si
mov cx,16
mov si,0
add si,160*10+80
mov bx,0
mov di,1
add di,160*10+80
s1:
mov al,[bx]
mov es:[bx+si],al
mov es:[bx+di],ah
inc bx
inc si
inc di
loop s1
pop si
inc si
pop cx
mov dx,es
add dx,0ah
mov es,dx
loop s
s2:
jmp short s2
mov ax,4c00h
int 21h
code ends
end start
实验结果