求助 :帮我修改一下程序
编程实现屏幕设置和字串显示功能,即程序运行后屏幕显示如下主选单:
SETUP SCREEN ATTRIBUTE AND DISPLAY
====================================================
1) clear the screen
2) display the character string at define row & col
3) setup background color
4) setup frontground color
=====================================================
Please choose the number(1-4,Esc-quit):
要求:
用户键入“1”后实现清屏
用户键入“2”后,依提示用户可从键盘输入一个字符串,按下[ENTER]键后在指定的行列位置显示这个字符串,返回主选单。
用户键入“3”后,按下[SPACE]键改变当前屏显背景颜色,按下[ESC]键返回主选单
用户键入“4”后,按下[SPACE]键改变当前屏显前景颜色,按下[ESC]键返回主选单
下面是我的程序 ,大家帮我修改一下,看看有什么问题???
ASSUME CS:code ,ds:data
data segment
welcom DB "SETUP SCREEN ATTRIBUTE AND DISPLAY",0
-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
winmenu DB 1) " clear the screen",0
DB 2) " display the character string at define row & col" ,0
DB 3) " setup backgroud color" ,0
DB 4) " setup frontgroud color" ,0
choose DB "Please choose the number (1-4,esc-quit)",0
-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
data ends
code SEGMENT
start:
mysysstart:
CALL cleprint ;初始化清屏
MOV AX,CS ;显示主界面
MOV ES,AX
MOV BP,OFFSET welcom-OFFSET 0b800h
MOV DX,040ah
MOV AX,0021h
MOV CX,7
choose:
MOV AH,0
INT 16h
CMP AL,1+30h
JB choose
CMP AL,4+30h
JA choose
SUB AL,31h
CALL setscreen
cmp ah,01h; esc的扫描码
je esc
call setscreen
cmp ah,3
je quit
call setscreen
JMP mysysstart
MOV AX,data
MOV ES,AX
MOV BP,OFFSET welcom-OFFSET 0b800h
lea dx,welcom
MOV ah,9
int 21h
mov bh,0
mov dh,1
mov dl,0
mov ah,2
int 10h
lea dx,winmenu
mov ah,9
int 21h ;显示字符串winmenu
mov ah,1 ;从设置前景色开始进行循环
mov al,1 ; 颜色属性初始为1(1为蓝色)
cleprint:
PUSH BX
PUSH CX
PUSH ES
MOV BX,0b800h
MOV ES,BX
SUB BX,BX
MOV CX,2000h
func: push ax
cmp ah,3
ja quit
call setscreen
call delay
pop ax
inc ah ;功能号加1
inc al ;颜色属性加1后变为绿色
jmp short func
quit: mov ah,0 ;跳出循环后则清屏
call setscreen
mov ax,4c00h
int 21h
cleprint:
PUSH BX
PUSH CX
PUSH ES
MOV BX,0b800h
MOV ES,BX
SUB BX,BX
MOV CX,2000h
setscreen proc near ;设置屏幕函数的子程序
jmp short set
table: dw sub1,sub2,sub3,sub4
set: push ax
push bx
cmp ah,3
ja sret
mov bl,ah
mov bh,0
add bx,bx
call word ptr table[bx]
sret: pop bx
pop ax
ret
setscreen endp
delay proc near ;延迟函数,让CPU执行15000000h次减法。
push ax
push dx
mov dx,1500h
mov ax,0
s1: sub ax,1
sbb dx,0
cmp ax,0
jne s1
cmp dx,0
jne s1
pop dx
pop ax
ret
delay endp
sub1 proc near ;清屏的子过程定义
push bx
push cx
push es
mov bx,0b800h
mov es,bx
mov bx,0
mov cx,2000
sub1s: mov byte ptr es:[bx],0
add bx,2
loop sub1s
pop es
pop cx
pop bx
ret
sub1 endp
sub2 proc near
mov dx,offset 0b800h
mov ah,0ah
int 21h
push cx
push si
push di
push es
push ds
mov si,ob800h
mov es,si
mov ds,si
mov si,160 ;ds:si 指向第n+1行
mov di,0 ;es:di指向第n行
cld
mov cx,1
sub2s:
push cx
push cx,160
rep movsb
pop cx
loop sub4s
mov cx,80
mov si,0
sub2s1: mov byte ptr [160*1+si]
add si,2
loop sub2s1
pop ds
pop es
pop di
pop si
ret
cmp ah,1ch
je enter
call sub2 proc near
sub2 endp
sub3 proc near
push bx
push cx
push es
mov cl,4
shl al,cl
mov bx,0b800h
mov es,bx
mov bx,1
mov cx,2000
sub3s: and byte ptr es:[bx],11111000b
shl al,1
shl al,1
shl al,1
shl al,1
or es:[bx],al
add bx,2
loop sub3s
pop es
pop cx
pop bx
ret
cmp ah,01h
je esc
call mysystart
cmp ah,39h
je space
call sub3 proc near
sub3s endp
sub4 proc near
push bx
push cx
push es
mov bx,0b800h
mov es,bx
mov bx,1
mov cx,2000
sub4s : and byte ptr es:[bx],11111000b
or es:[bx] ,al
add bx,2
loop sub2
pop es
pop cx
pop bx
ret
cmp ah,01h
je esc
call mysystart
cmp ah,39h
je space
call sub4 proc near
sub4 endp
setcreenret:
POP DX
POP CX
POP BX
POP AX
RET
code ENDS
END start