代碼解釋如下:
;從鍵盤緩沖區中讀取字節,根據讀取的不同內容改變屏幕顏色assume cs:codecode segmentstart: mov ah,0 ;ah去控制顏色 int 16h ;從鍵盤緩沖區讀取出數據 , ah存字符的通碼,al為字符的ASCII碼 mov ah,1 cmp al,'r' ;若按下r je red cmp al,'g' ;按下g je green cmp al,'b' ;按下b je blue jmp short startRet ;否則就結束red: shl ah,1green: shl ah,1blue: mov bx,0b800h mov es,bx mov cx,2000 mov bx,1s: and byte ptr es:[bx],11111000B ;循環修改字符的顏色,每個字符2個字節,奇數位字節控制顏色,一頁是2000個字符 or es:[bx],ah add bx,2 loop sstartRet: mov ax,4c00h int 21h;========================================================= code endsend start
新聞熱點
疑難解答