王爽汇编语言第三版实验9 双循环实现

编程:在屏幕中间分别显示绿色、绿底红色、白底蓝色的字符串welcome to masm!

效果图:

采用了双循环嵌套的写法,外层控制输出行数,内层逐字符读取ASCII码与对应行的属性。

loop s1改为loop s2有惊喜哦

所有实验答案在这里

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
assume cs:code,ss:data

code segment
mov ax,0b800h
mov ds,ax
mov bx,1760

mov ax,data
mov ss,ax
mov si,0

mov bp,0
mov cx,3
s1: mov ss:[19],cx
mov si,0
mov cx,16
s2: mov di,si
add di,di
mov al,ss:[si]
mov [bx+64+di],al
mov al,ss:[16+bp]
mov [bx+65+di],al
inc si
loop s2
inc bp
add bx,160
mov cx,ss:[19]
loop s1
mov ax,4c00h
int 21h
code ends

data segment
db 'welcome to masm!'
db 00000010b,00100100b,01110001b
dw 0
data ends

end