编程:在屏幕中间分别显示绿色、绿底红色、白底蓝色的字符串'welcome to masm!'。
直接贴代码:
- assume cs:codesg
- data segment
- db 'welcome to masm!'
- db 00000010B,00100100B,01110001B
- data ends
- codesg segment
- start: mov ax,data
- mov ds,ax
- mov ax,0b800h
- mov es,ax
- mov di,11*160+64
- mov cx,3
- s: mov si,0
- mov bx,19
- sub bx,cx
- push cx
- mov cx,16
- add di,160
- push di
- s0: mov byte ptr al,[si]
- mov byte ptr es:[di],al
- mov byte ptr al,[bx]
- mov byte ptr es:[di+1],al
- inc si
- add di,2
- loop s0
- pop di
- pop cx
- loop s
- mov ax,4c00h
- int 21h
- codesg ends
- end start
运行结果如下图所示: