您的位置:首页 > 其它

汇编获取键盘输入,及改变文本颜色

2015-04-29 15:53 218 查看
data segment
pkey db "press (rgb) key to change color:$"
ends

stack segment
dw   128  dup(0)
ends

code segment
start:
mov ax,data
mov ds,ax
lea dx, pkey
mov ah, 9
int 21h        ; output string at ds:dx

mov ah,0
int 16h  ;wait key

mov ah,1
cmp al,'r'
je red
cmp al,'g'
je green
cmp al,'b'
je blue
jmp short sret

red:
shl ah,1
green:
shl ah,1
blue:
mov bx,0b800h
mov es,bx
mov bx,1
mov cx,20
s:
and byte ptr es:[bx],11111000b
or es:[bx],ah    ; change forecolor
add bx,2
loop s

sret:
mov ax, 4c00h ; exit to operating system.
int 21h
ends
end start ; set entry point and stop the assembler.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐