|
发表于 2012-5-3 17:11:15
|
显示全部楼层
- ;=============================================================
- ; 实验九: 在屏幕中间显示3行不同前景,背景色的字符
- ;=============================================================
- assume cs:codesg, ds:datasg, ss:stacksg
- datasg segment
- db 'welcome to masm!' ;显示的字符
- db 00000010b, 00100100b, 01110001b ;颜色属性
- datasg ends
- stacksg segment
- db 8 dup(0)
- stacksg ends
- codesg segment
- start:
- mov ax, stacksg
- mov ss, ax
- mov sp, 8
- mov ax, datasg
- mov ds, ax
- mov ax, 0B872H ;显示中间行中间列偏移地址
- mov es, ax
-
- mov di, 0 ;行偏移,每行 +160
- mov si, 0 ;颜色属性字节偏移 ds:16[si]
-
- mov cx, 3
- S: ;外循环,3次,一次为一行 di
- mov bx, 0 ;字符字节偏移
-
- push cx
-
- mov cx, 16
- s0: ;内循环,一次1字节字符(写入显示地址为2字节) bx
- mov al, [bx]
- push bx ;保存 bx,下面可用2*(bx) 来完成显示地址偏移
- add bx, bx
- mov es:[bx + di], al
- mov al, 16[si]
- mov es:1[bx + di], al
- pop bx
-
- inc bx
-
- loop s0
-
- add di, 160
- inc si
-
- pop cx
-
- loop S
-
- mov ax, 4c00H
- int 21H
-
- codesg ends
- end start
复制代码 同分享,俺独立写的代码,才发现与小甲鱼的,还有网上参考答案出入比较大...但试验了一下,还是可以的...求优化... |
|