我在显示屏幕上的颜色时遇到问题,行数和列数不准确。这是我尝试过的。
.model small
.stack
.data
mes db'ENTER ANY NUMBER: $'
COUNTER DB '0'
.code
start:
mov ax,@data
mov ds,ax
TYPEAGAIN:
mov ah,02H
MOV bh,00
mov dh,13
mov dl,35
int 10h
mov ah,09h
mov dx,offset mes
int 21h
mov ah,01h
int 21h
INC COUNTER
CMP AL,'1'
JE WTOBLACK
JNE LABAS
WTOBLACK:
CMP COUNTER,'1'
JE BLACK
CMP COUNTER,'2'
JE BLUE
CMP COUNTER,'3'
JE GREEN
CMP COUNTER,'4'
JE CYAN
CMP COUNTER,'5'
JE RED
CMP COUNTER,'6'
JE MAGENTA
CMP COUNTER,'7'
JE YELLOW
CMP COUNTER,'8'
JE WHITE
JMP TYPEAGAIN
LABAS:
JMP EXIT
BLACK :
MOV AH,06H
mov bh,00000000b
JMP LOC
BLUE :
MOV AH,06H
mov bh,00010001b
JMP LOC
GREEN :
MOV AH,06H
mov bh,00100010b
JMP LOC
CYAN :
MOV AH,06H
mov bh,00110011b
JMP LOC
RED :
MOV AH,06H
mov bh,11001100b
JMP LOC
MAGENTA:
MOV AH,06H
mov bh,11011101b
JMP LOC
YELLOW:
MOV AH,06H
mov bh,11101110b
JMP LOC
WHITE :
MOV COUNTER,'0'
MOV AH,06H
mov bh,11111111b
JMP LOC
LOC:
mov ch,0;start row
mov cl,0;start column
mov dh,5;end row
mov dl,25;end column
int 10h
JMP TYPEAGAIN
EXIT:
mov ah,4ch
int 21h
end start
答案 0 :(得分:2)
首先,在我的编译器中,当标签和冒号分开时,例如:BLACK :
,这是一个错误,它必须是BLACK:
。
其次,在代码的底部,您使用int 10h
服务06H
,这意味着您要滚动屏幕区域。此中断需要一个您忘记的参数:您必须存储要在al
中滚动的行数。在你的情况下,AL总是包含' 1',这是49,所以你的代码在屏幕区域滚动49行。数字6会更加合适,因为你在评论中提到要将第0行滚动到第5行。但是,为了使它更有趣,我会选择数字1,因此它看起来像彩虹(你可以选择任何其他数字) )。
哦,是的,我添加了一些在汇编中非常重要的评论:
.model small
.stack
.data
mes db 'ENTER ANY NUMBER: $'
COUNTER DB '0'
.code
start:
mov ax,@data
mov ds,ax
TYPEAGAIN:
mov ah,02H
MOV bh,00
mov dh,13
mov dl,35
int 10h ;SET CURSOR POSITION.
mov ah,09h
mov dx,offset mes
int 21h ;DISPLAY STRING.
mov ah,01h
int 21h ;READ KEY.
INC COUNTER
CMP AL,'1'
JE WTOBLACK
JNE LABAS
WTOBLACK:
CMP COUNTER,'1'
JE BLACK
CMP COUNTER,'2'
JE BLUE
CMP COUNTER,'3'
JE GREEN
CMP COUNTER,'4'
JE CYAN
CMP COUNTER,'5'
JE RED
CMP COUNTER,'6'
JE MAGENTA
CMP COUNTER,'7'
JE YELLOW
CMP COUNTER,'8'
JE WHITE
JMP TYPEAGAIN
LABAS:
JMP EXIT
BLACK: ;FIXED LABEL.
MOV AH,06H
mov bh,00000000b
JMP LOC
BLUE: ;FIXED LABEL.
MOV AH,06H
mov bh,00010001b
JMP LOC
GREEN: ;FIXED LABEL.
MOV AH,06H
mov bh,00100010b
JMP LOC
CYAN: ;FIXED LABEL.
MOV AH,06H
mov bh,00110011b
JMP LOC
RED: ;FIXED LABEL.
MOV AH,06H
mov bh,11001100b
JMP LOC
MAGENTA:
MOV AH,06H
mov bh,11011101b
JMP LOC
YELLOW:
MOV AH,06H
mov bh,11101110b
JMP LOC
WHITE: ;FIXED LABEL.
MOV COUNTER,'0'
MOV AH,06H
mov bh,11111111b
JMP LOC
LOC:
mov al, 1 ;HOW MANY ROWS TO SCROLL.
mov ch,0;start row
mov cl,0;start column
mov dh,5;end row
mov dl,25;end column
int 10h ;SCROLL DOWN SCREEN AREA.
JMP TYPEAGAIN
EXIT:
mov ah,4ch
int 21h
end start