어셈블리 키보드 입력 및 텍스트 색상 변경

4063 단어 집성
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.

좋은 웹페이지 즐겨찾기