我初学汇编,写了一个学生成绩管理系统!
当我初次调试的时候,结果正如预期!但当我将学生的姓名换为相近的数字时,比如111111,111112,111113等,程序的有些功能,比如F查找,M修改就会出现错误,但理论上是不会的,请高手帮我看一下!
另外,带有条件转移指令汇编的宏是不是不能连续地被引用?(我用轻松汇编 II ,引用时老是出错示)
整个系统和编辑器都在以下以下文件中,请下载:
由于整个源程序太长,我只将F查找的源代码写入,如下:
.MODEL SMALL
.STACK
.DATA
NUMBER DW 2 DUP (?)
MATHS DW ?
ENGLISH DW ?
COMPUTER DW ?
CHINESE DW ?
LENSTR EQU (CHINESE-NUMBER)
SNUM DB 0DH,0AH,"NUMBER: ",'$'
SMATHS DB 0DH,0AH,"MATHS: ",'$'
SENGLISH DB 0DH,0AH,"ENGLISH: ",'$'
SCOMPUTER DB 0DH,0AH,"COMPUTER: ",'$'
SCHINESE DB 0DH,0AH,"CHINESE: ",'$'
SCREAT DB 0DH,0AH,"CREAT INFORMATIONS",0DH,0AH,"PLEASE INPUT THE DATA:",0DH,0AH,'$'
EXIT1 DB 0DH,0AH,"INPUT 'e' EXIT ",0DH,0AH,'$'
HANDLE DW ?
PATHNAM DB 'd:\mch\score.txt',0H
OPNMSG DB "OPEN ERROR",0DH,0AH,'$'
WRTMSG DB "WRITE ERROR",0DH,0AH,'$'
DATA DB 0DH,0AH,"NUMBER: ",0,0,0,0,0,0,0DH,0AH,"MATHS: ",0,0,0DH,0AH,"ENGLISH: ",0,0,0DH,0AH,"COMPUTER: ",0,0,0DH,0AH,"CHINESE: ",0,0,0DH,0AH
INFOR DB "PLEASE INPUT THE OPERATION: CREAT 'c' WATCH 'i' EXIT 'e'",0AH,0DH,'$'
LEN EQU $-DATA
BAO DB LEN DUP(0),'$'
NO1 DB 0AH,0DH,"NO THIS STUDENTS",0AH,0DH,'$'
SHOW MACRO ADDR1
LEA DX,ADDR1
MOV AH,09H
INT 21H
ENDM
SPUT DB "PLEASE INPUT THE NUMBER: ",0AH,0DH,'$'
PUTS DB 0,0,0,0,0,0,'$'
INPUT1 MACRO STR1
MOV SI,0
AGAIN:
MOV AH,01H
INT 21H
MOV [STR1+SI],AL
CMP SI,5
INC SI
JBE AGAIN
ENDM
.CODE
.startup
MOV AX,@DATA
MOV DS,AX
MOV ES,AX
SHOW SPUT
INPUT1 PUTS ;输入学生姓名,以便查找
MOV AH,3DH
LEA DX,PATHNAM
MOV AL,0
INT 21H
MOV HANDLE,AX ;找开文件
MOV DI,1
AG:
PUSH DI ;保护DI,其用来累加比较
MOV AH,3FH
LEA DX,BAO
MOV BX,HANDLE
MOV CX,LEN ;LEN为一个记录的长度
INT 21H ;读入数据
CMP AX,0
JE NEXT3
MOV CX,5
LEA SI,PUTS
LEA DI,BAO+11 ;读入数据中,学生姓名的存放起始点
CLD
REPE CMPSB
CMP CX,0 ;看所查找的是否与读入的相同
JZ OK1
POP DI
XOR CX,CX
MOV AX,LEN
MUL DI
MOV CX,DX
MOV DX,AX
MOV AH,42H
MOV AL,00H
MOV BX,HANDLE
INT 21H ;文件指针移动到下一个(好像有些多余,但改了后,整个系统就出错)
INC DI
JMP AG
OK1: SHOW BAO ;显示的查找的结果
JMP EX2
NEXT3: SHOW NO1 ;表明数据中,无此学生
EX2:
.EXIT 0
END
请大家帮我看看哪儿有不合理的(我已经搞昏了)。
联系我:mchmcy@hotmail.com ,也可以顶贴子
最后谢谢大家,本人感激不尽!
[此贴子已经被作者于2006-3-3 12:02:39编辑过]