汇编网首页登录博客注册
njutyangxiao的学习博客
博客首页博客互动【做检测题】论坛求助

我的博客

个人首页 |  我的文章 |  我的相册 |  我的好友 |  最新访客 |  文章收藏 |  论坛提问 |  友情链接 |  给我留言  
图片载入中
  •  原泉混混,不舍昼夜。盈科而后进,放乎四海,有本着如是,是之取尔!
  • 『姓名』:杨逍
  • 『性别』:男『发送消息
  • 个人说明:
  • 详细信息『加为好友』
学习动态
最新留言

[2009-09-17 19:19] 第十七章第二节题

图片载入中
题目:编程,接受用户的键盘输入,输入‘r’,将屏幕上的字符设置为红色;输入‘g’,将屏幕上的字符设置为绿色;输入‘b’时,将屏幕上的字符设置为蓝色。

源代码:

assume cs:codesg
codesg segment

    start:

    mov ax,0
    int 16h;调用int 16h的0号功能读取键盘输入的字符,输入的字符的ascii码放在了al中,ah中放的是扫面码

    cmp al,72h;如果是字母‘r’,则跳转到show_red处
    je show_red
    cmp al,67h;如果是字母‘g’,则跳转到show_green处
    je show_green
    cmp al,62h;如果是字母‘b’,则跳转到show_blue处
    je show_blue

print:
    mov ax,0b800h
    mov es,ax
    mov di,1
    mov cx,2000
lp_changecol:
    and byte ptr es:[di],11111000b
    or byte ptr es:[di],bl
    add di,2
    loop lp_changecol
    

    mov ax,4c00h
    int 21h

show_red:
    mov bl,4h;用书上左移一位的的那种方法更加好吧
    jmp short print

show_green:
    mov bl,2h
    jmp short print

show_blue: 
    mov bl,1h
    jmp short print


codesg ends
end start
评论次数(0)  |  浏览次数(664)  |  类型(Assembly's Road) |  收藏此文  | 
 
 请输入验证码  (提示:点击验证码输入框,以获取验证码