当前位置: 代码迷 >> 汇编语言 >> 字符打字训练程序设计,该怎么解决
  详细解决方案

字符打字训练程序设计,该怎么解决

热度:2592   发布时间:2013-02-26 00:00:00.0
字符打字训练程序设计
汇编程序设计要求:fenfen8818@163.com
设计一个打字训练程序,随机输出字符,用户按照这个字符输入,并判断用户输入的是否与要求的字符一致,每轮10个字符给出成绩。

------解决方案--------------------------------------------------------
从网上下载了一个,你看合不合你的要求。
我刚刚编译了以下,可以运行的!
stack segment para stack 'stack'
db 256 dup(0)
top label word
stack ends
data segment para public 'data'
buffer db 16h dup(0)
bufpt1 dw 0
bufpt2 dw 0
kbflag db 0
prompt db ' *please practise typing*',0dh,0ah,'$'
scantab db 0,0,'1234567890-=',8,0
db 'qwertyuiop[]',0dh,0
db 'asdfghjkl;',0,0,0,0
db 'zxcvbnm,./',0,0,0
db ' ',0,0,0,0,0,0,0,0,0,0,0,0,0
db '789-456+1230.'
even
oldcs9 dw ?
oldip9 dw ?
str1 db 'abcd efgh ijkl mnop qrst uvwx yz.'
db 0dh,0ah,'$'
str2 db 'there are some newspapers on the table.'
db 0dh,0ah,'$'
str3 db 'there are some clouds in the sky.'
db 0dh,0ah,'$'
str4 db 'she always eats her lunch at noon.'
db 0dh,0ah,'$'
str5 db 'i do not like autumn and winter.'
crlf db 0dh,0ah,'$'
colon db ':','$'
even
saddr dw str1,str2,str3,str4,str5
count dw 0
sec dw 0
min dw 0
hours dw 0
save_lc dw 2 dup(?)
data ends
code segment
assume cs:code,ds:data,es:data,ss:stack
main proc far
start:
mov ax,stack
mov ss,ax
mov sp,offset top

push ds
sub ax,ax
push ax
mov ax,data
mov ds,ax
mov es,ax

; mov ah,0
; mov al,4
; int 21h
; mov ah,0bh
; mov bh,0
; mov bl,4
; int 11h 
mov ah,35h
mov al,09h
int 21h
mov oldcs9,es
mov oldip9,bx

push ds
mov dx,seg kbint
mov ds,dx
mov dx,offset kbint
mov al,09h
mov ah,25h
int 21h
pop ds

mov ah,35h
mov al,1ch
int 21h
mov save_lc,bx
mov save_lc+2,es

push ds
mov dx,seg clint
mov ds,dx
mov dx,offset clint
mov al,1ch
mov ah,25h
int 21h
pop ds

in al,21h
and al,11111100b
out 21h,al
 

first: mov ah,0
mov al,3
int 10h

mov dx,offset prompt
mov ah,9
int 21h

mov si,0
next: mov dx,saddr[si]
mov ah,09h
int 21h

mov count,0
mov sec,0
mov min,0
mov hours,0

sti
forever:
call kbget
test kbflag,80h
jnz endint
push ax
call dispchar
pop ax
cmp al,0dh
jnz forever
mov al,0ah
call dispchar

call disptime
lea dx,crlf
mov ah,09h
int 21h

add si,2
cmp si,5*2
jne next
jmp first
endint: cli
push ds
mov dx,save_lc
mov ax,save_lc+2
mov ds,ax
mov al,1ch
mov ah,25h
int 21h
pop ds

push ds
mov dx,oldip9
mov ax,oldcs9
mov ds,ax
mov al,09h
mov ah,25h
int 21h
pop ds

sti
ret
main endp
clint proc near
push ds
mov bx,data
mov ds,bx
  相关解决方案