(汇编语言)编程,输入r g b字符颜色改变为红绿蓝

版权声明:斌哥版权,如有雷同,纯属虚构 https://blog.csdn.net/iostream992/article/details/84307834
assume cs:code
code segment
start:

     mov ah,0
     int 16h

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

     red:
       mov ah,4
       call setColor
       jmp short nothing
     blue:
       mov ah,1
       call setColor
       jmp short nothing
     green:
       mov ah,2
       call setColor
       jmp short nothing
nothing:nop
  mov ax,4c00h
  int 21h


 setColor:
    push bx
    push cx
    push es
    mov cx,0b800h
    mov es,cx
    mov cx,2000
    mov bx,1
    s:
     and byte ptr es:[bx],11111000b
     or es:[bx],ah
     add bx,2
    loop s
    pop es 
    pop cx
    pop bx
 ret

code ends
 end start

运行截图

 

猜你喜欢

转载自blog.csdn.net/iostream992/article/details/84307834