求助 :帮我修改一下程序

vistalong 2007-06-19 10:01:12
编程实现屏幕设置和字串显示功能,即程序运行后屏幕显示如下主选单:
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
...全文
185 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
dongyi940333 2007-06-20
  • 打赏
  • 举报
回复
http://community.csdn.net/Expert/topic/5603/5603419.xml?temp=.5531275

这个帖子也是你的

用户键入“1”后实现清屏

可以用INT 10H的功能06H上卷屏幕实现

pusha
mov ax,0600h ; scroll window up
mov cx,0 ; upper left corner (0,0)
mov dx,184Fh ; lower right corner (24,79)
mov bh,7 ; normal attribute
int 10h ; call BIOS
mov ah,2 ; locate cursor at 0,0
mov bh,0 ; video page 0
mov dx,0; row 0, column 0
int 10h
popa

用户键入“2”后,依提示用户可从键盘输入一个字符串,按下[ENTER]键后在指定的行列位置显示这个字符串,返回主选单?
我觉得你调用INT21H的功能0AH输入字符串后,用INT10H的功能2设置光标位置,然后再调用INT21H的功能9输出.

至于: 用户键入“3”后,按下[SPACE]键改变当前屏显背景颜色,按下[ESC]键返回主选单
用户键入“4”后,按下[SPACE]键改变当前屏显前景颜色,按下[ESC]键返回主选单
改变前景和背景色这个你查一下相应的资料,
这里有一个:

免费的《EGA_VGA程序员手册》(1991年出版的),
(由mengshijie_1981 (云中雀)提供)
http://download.csdn.net/search/EGA_VGA

http://download.csdn.net/source/193464
http://download.csdn.net/down/193464

初学不对之处请原谅!!!!




vistalong 2007-06-20
  • 打赏
  • 举报
回复
谢谢你的指导
zara 2007-06-20
  • 打赏
  • 举报
回复
前两天好像看过一次的. 楼主这个代码, 看起来有些无从下手的感觉. 功能的描述和程序主体结构上有些问题.

21,458

社区成员

发帖
与我相关
我的任务
社区描述
汇编语言(Assembly Language)是任何一种用于电子计算机、微处理器、微控制器或其他可编程器件的低级语言,亦称为符号语言。
社区管理员
  • 汇编语言
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧