主题:[原创]汇编语言实训案例-打字软件
*******************************************************************************
**2004学年—2005学年第二学期**
*******************************************************************************
**2003级通信工程<汇编语言程序设计>实训报告~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
********************************************
***** **班级:03通信工程** *****
***** *****
***** **姓名: 钟亦金 ** *****
***** *****
***** **题目:打字游戏** *****
*********************************************
###############################################################################
**联系方式:Golden8510@yahoo.com.cn**
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**时间:2005/6/13—2005/6/17(8:00-9:50)**
*******************************************************************************
**地点:江西理工大学南昌分校机房6**
*******************************************************************************
实训内容
编写一个打字软件,说明如下:
1,用户打开软件时先出现欢迎界面,当用户输入字符’1’时,再进入打字界面;当用户按的是”ESC”键时,退出打字游戏;当用户输入不是数字”1”或者不是按的”ESC”键时,屏幕不动作,直到用户输入数字”1”或者按的”ESC”键时;
2,打字字符从第二行开始显示(双数行为显示打字内容,单数行由用户输入);
打字内容:1), We will see his boat and then.We'll say goodbye to him.
2), He'll be away for two months.We are very proud of him.
3,用户输入的和上一行相对应相等时,表示输入正确,否则输入错误,则显示’#’;当用户按下”ESC”键,退出打字程序
4,显示用户打字的正确性,假如错误数小于10字符,显示” Very Good!”;否则显示” Very Bad!”;
5,当用户输入一次时,假如用户还想重新打字游戏,请按数字键”3”,否则按”ESC”键退出打字程序;
程序代码
stack1 segment stack
dw 256 dup(?)
stack1 ends ;堆栈段的定义
data1 segment
msg1 db "Welcome come to my dazi game!$" ;定义字符串msg1
n1=$-msg1-1; 字符串msg1的个数
msg2 db "1.enter dazi game -- 1$";定义字符串msg2
n2=$-msg2-1
msg3 db "2.exit -- esc$";定义字符串msg3
n3=$-msg3-1
msg40 db "Shu ru number 1 or esc:$";定义字符串msg40
msg41 db "Shu ru number 3 or esc:$";定义字符串msg41
enter1 db "1"
enter2 db "3"
exit1 equ 1bh ;退出
msg5 db "We will see his boat and then.We'll say goodbye to him.$"
n5=$-msg5-1
msg6 db "He'll be away for two months.We are very proud of him.$"
n6=$-msg6-1
msg7 db "Shu ru zi fu da effort:$"
n7=$-msg7-1
verygood db " Very Good! $"
verybad db " Very Bad! $"
msg8 db "1.Restart -- 3$"
bs equ 8h
space equ 20h
wronggeshu dw ?
data1 ends ;数据段的定义
code1 segment
assume cs:code1,ds:data1
start:mov ax,data1
mov ds,ax
mov ah,02h
mov bh,0 ;显示页码
mov dh,5
mov dl,20
int 10h ;定义光标的位置
lea dx,msg1
mov ah,09h
int 21h ;输出字符串msg1
mov ah,02h
mov bh,0 ;显示页码
mov dh,7
mov dl,25
int 10h
lea dx,msg2
mov ah,09h
int 21h ;输出字符串msg2
mov ah,02h
mov bh,0 ;显示页码
mov dh,9
mov dl,25
int 10h
lea dx,msg3
mov ah,09h
int 21h ;输出字符串msg3
mov ah,02h
mov bh,0 ;显示页码
mov dh,11
mov dl,25
int 10h
lea dx,msg40
mov ah,09h
int 21h ;输出字符串msg40
again0:mov ah,01h
int 21h ;输入字符
cmp al,enter1
jz again1
cmp al,exit1
jz again2
jmp again0
again1:mov ah,06h
mov al,0
mov bh,30
mov ch,0
mov cl,0
mov dh,24
mov dl,79
int 10h
mov ah,02h
mov bh,0 ;显示页码
mov dh,2
mov dl,11
int 10h
mov dx,offset msg5
mov ah,09h
int 21h ;输出字符串msg5
mov ah,02h
mov bh,0 ;显示页码
mov dh,3
mov dl,11
int 10h
mov cx,n5
lea si,msg5
again21:mov ah,08h
int 21h
cmp al,[si]
jz next22
cmp al,exit1
jz again2
mov dl,'#'
inc wronggeshu
jmp next23
next22:mov dl,al
next23:mov ah,02h
int 21h
inc si
loop again21 ;输入字符串msg5
mov ah,02h
mov bh,0 ;显示页码
mov dh,4
mov dl,11
int 10h
mov dx,offset msg6
mov ah,09h
int 21h ;输出字符串msg6
mov ah,02h
mov bh,0 ;显示页码
mov dh,5
mov dl,11
int 10h
mov cx,n6
lea si,msg6
again31:mov ah,08h
int 21h
cmp al,[si]
jz next32
cmp al,exit1
jz again2
mov dl,'#'
inc wronggeshu
jmp next33
next32:mov dl,al
next33:mov ah,02h
int 21h
inc si
loop again31 ;输入字符串msg6
mov ah,02h
mov bh,0 ;显示页码
mov dh,8
mov dl,20
int 10h
mov dx,offset msg7
mov ah,09h
int 21h ;输出字符串msg7
cmp wronggeshu,10d
jb b1 ;低于10
xor dx,dx
mov dx,offset verybad
mov ah,09h
int 21h
jmp c1
b1:xor dx,dx
mov dx,offset verygood
mov ah,09h
int 21h
c1:mov ah,02h
mov bh,0 ;显示页码
mov dh,10
mov dl,22
int 10h
mov dx,offset msg8
mov ah,09h
int 21h ;输出字符串msg8
mov ah,02h
mov bh,0 ;显示页码
mov dh,10
mov dl,37
int 10h
mov dx,offset msg3
mov ah,09h
int 21h ;输出字符串msg3
mov ah,02h
mov bh,0 ;显示页码
mov dh,12
mov dl,26
int 10h
mov dx,offset msg41
mov ah,09h
int 21h ;输出字符串msg41
again44:mov ah,01h
int 21h
cmp al,enter2
jz again1
cmp al,exit1
jz again2
jmp again44
again2:mov ax,4c00h
int 21h
code1 ends
end start
实训总结
1, 实训是一种团队合作的精神;
2,这次还是第一次自己编写完整的程序,虽然还有很多的功能没有显示,但是我已经尽力;
(共大家参考和学习用,不得转发)