大家别怪我呀,我也是被逼的.
老师布置了汇编的课程设计,没什么人会,所以我将它发到CSDN上了,我知道这里高手很多,请大家不要见怪,会的帮帮忙,不会的捧个人场.进来就给100分.我的程序已经大概写得差不多了,但是还有点小问题,一是:遇到E有时能退出,有时退不出来.还有不能判断是不是闰年,输入数字,得出的结果是一样的.大家帮忙呀.
具体要求:
程序运行后,显示“input:” 然后输入任意四位数字年份,该年份必须显示在屏幕上,以回车键[ENTER]表示输入年份结束。若输入数字字符不足4个或多于4个,程序不予理睬并要求重新输入。然后进入程序判断,若是输入数字年份是闰年则输出一个五角星,若不是则输出一个三角星。将结果显示延时10秒,然后程序自动返回,重新要求输入新的年份数字。
当输入非数字字符时,不予理睬,当在任意位置输入字母“E”时,程序退出。
我写的程序:
datarea segment
msg db 'input:',13,10,'$'
datarea ends
;------------------------------
stack segment stack
db 200 dup(0)
stack ends
program segment
main proc far
assume cs:program,ss:stack,ds:datarea
;8----------------
start:
push ds
sub ax,ax
push ax
mov ax,datarea
mov ds,ax
;15----------------
;以下是显示input:字符
begin:
mov ah,9
mov dx,seg msg
mov ds,dx
mov dx,offset msg
int 21h
;22-----------------
;输入数字并回显,将数字存到bx中
init:
mov cx,0
mov bx,0
numinput:
mov ah,1
int 21h
inc cx
cmp al,0dh
je deal
cmp al,69d
je exit
sub al,30h
jl start
cmp al,9d
jg start
cbw
xchg ax,dx
mov dx,10d
mul dx
xchg ax,bx
add bx,ax
jmp numinput
;44------------------
deal:
cmp cx,5d
jne start
mov ax,bx
mov cx,ax
jmp compute
;49-------------------
;判断是不是闰年
compute:
mov bx,100d
div bx
cmp al,0
je next1
cmp al,0
jne next2
;57-------------------
next1: mov ax,cx
mov bx,400d
div bx
cmp al,0
je yes
cmp al,0
jne no
;64-------------------
next2: mov ax,cx
mov bx,4d
div bx
cmp al,0
je yes
cmp al,0
jne no
;71------------------
;是闰年输出笑脸
yes:
mov al,02d
mov dl,al
mov ah,2
int 21h
call delay
jmp start
;79-------------------
;不是,输出一个字符
no:
mov al,029d
mov dl,al
mov ah,2
int 21h
call delay
jmp start
;87-------------------
exit:
ret
main endp
;91**************************
;以下是10s延时程序,正确的,抄书的
waitsec proc near
push ax
waitf:
in al,61h
and al,10h
cmp al,ah
je waitf
mov ah,al
loop waitf
pop ax
ret
waitsec endp
;104**************************
delay proc near
mov bl,20d
delayf:
mov cx,33144
call waitsec
dec bl
jne delayf
ret
delay endp
;114**************************
program ends
end main
最后感谢大家阅读!