本文是介绍了一个用汇编实现的简易的学生档案管理系统.学生的属性有学号、姓名、性别、生日、地址、英语成绩、语文成绩、数学成绩和总成绩.四个成绩的精度到小数点后两位.系统的的运行过程是:开始一个登陆界面,需要输入密码(8位),当输入完8位,并且正确时,自动进入系统.首先看到的是一个菜单,菜单显示了改系统提供的所有操作,这些操作的选择使用上下键来操作,当选择一个选项时,再使用回车键去确认即可执行改操作.
该系统分为:
1、系统菜单。系统的主界面,提供给用户使用上下键和回车键进行操作的界面。
2、添加学生信息模块。按照系统提示数据学生的信息
3、删除学生信息模块。输入一个学生学号或者姓名,则删除该学生的信息
4、查找学生信息模块。输入学号或者姓名对学生信息进行查找
5、显示所有学生信息模块。显示存储在该系统中的所有学生的信息
6、修改密码模块。输入8位的新密码
下面介绍系统的源代码:
1、系统的菜单,即主窗口模块的代码:window.asm
extrn list:far
extrn insert:far
extrn delete:far
extrn search:far
extrn trans:far
;;clear
clr macro
push ax
push bx
push cx
push dx
mov ax,0600h
mov cx,0
mov dx,184fh
mov bh,9Eh
int 10h
pop dx
pop cx
pop bx
pop ax
endm
;;;scrooll
scrl macro lrow,lcol,rrow,rcol,color
push ax
push bx
push cx
push dx
mov ah,6
mov al,0
mov cl,lcol
mov ch,lrow
mov dh,rrow
mov dl,rcol
mov bh,color
int 10h
pop dx
pop cx
pop bx
pop ax
endm
;;she zhi shu biao
setcur macro row,col
push ax
push bx
push cx
push dx
mov ch,5
mov cl,7
mov ah,1
int 10h
mov dh,row
mov dl,col
mov bh,0
mov ah,2
int 10h
pop dx
pop cx
pop bx
pop ax
endm
display macro string
push dx
lea dx,string
mov ah,09
int 21h
pop dx
endm
pushxy macro
push ax
push bx
push cx
push dx
push di
push si
push bp
endm
popxy macro
pop bp
pop si
pop di
pop dx
pop cx
pop bx
pop ax
endm
DISALL MACRO
PUSH AX
PUSH BX
PUSH CX
PUSH DX
SETCUR 6,34
DISPLAY MS1
SETCUR 8,34
DISPLAY MS2
SETCUR 10,34
DISPLAY MS3
SETCUR 12,34
DISPLAY MS4
SETCUR 14,34
DISPLAY MS5
SETCUR 16,34
DISPLAY MS6
POP DX
POP CX
POP BX
POP AX
ENDM
stack segment para stack 'stack'
dw 280 dup(?)
stack ends
data segment para 'data'
string1 db 'ANHUI UNIVERSITY OF SCIENCE AND TECHNOLOGY',0ah,0dh,'$'
string2 db ' '
TM DB 2 DUP(?)
DB ':'
DB 2 DUP(?)
DB ':'
DB 2 DUP(?),'$'
ms1 db '1. ADD ',0AH,0DH,'$'
MS2 DB '2. DELET ',0AH,0DH,'$'
MS3 DB '3. SEARCH ',0AH,0DH,'$'
MS4 DB '4. LISTALL ',0AH,0DH,'$'
MS5 DB '5. PASSWORD',0AH,0DH,'$'
MS6 DB '6. QUIT ',0AH,0DH,'$'
CUR DB ?
CUR2 DB ?
CUR1 DB ?
prompt db 'Enter Password:',13,10,'$'
pass label byte
maxlen db 8
namelen db ?
password db 9 dUP(?),13,10,'$'
third db ?
fcbrec label byte
fcbdriv db 0
fcbname db 'password'
fcbext db 'txt'
fcbblk dw 0
fcbrcsz dw ?
dd ?
dw ?
dt ?
fcbsqrc db 0
dd ?
reclen equ 9
pwordfld db reclen dup(?),13,10,'$'
wordfld db 9 dup(?)
endcde db 0
openmsg db '* * * open error * * *','$'
readmsg db '* * * read error * * *','$'
msgpass db 'Input new password:$'
writemsg db 'write error!$'
creatmsg db 'creat error!$'
DATA ENDS
code segment para 'code'
assume cs:code,ds:data,es:data,ss:stack
main proc far
start:
push ds
sub ax,ax
push ax
mov ax,data
mov ds,ax
mov es,ax
mov ax,stack
mov ss,ax
mov third,0
call openf
cmp endcde,0
jnz jieshu
call readf
cmp endcde,0
jnz jieshu
lea dx,pwordfld
mov ah,09
int 21h
jmp ipa
jieshu:jmp _a
ipa: scrl 0,0,24,79,07h
setcur 12,20
cmp third,3
je shu
inc third
jmp chu
shu: ret
chu:
lea dx,prompt
mov ah,09h
int 21h
setcur 12,35
push si
push cx
mov si,0
mov cx,8
con:
mov ah,07h
int 21h
mov password[si],al
mov ah,02
mov dl,'*'
int 21h
inc si
loop con
pop cx
pop si
mov cx,8
lea di,password
lea si,pwordfld
cld
rep cmpsb
jne a
jmp _a
a:jmp ipa
_a:MOV AL,1CH
MOV AH,35H
INT 21H
PUSH ES
PUSH BX
PUSH DS
MOV DX,OFFSET TIMES
MOV AX,SEG TIMES
MOV DS,AX
MOV AL,1CH
MOV AH,25H
INT 21H
POP DS
STI
menu:
clr
SETCUR 2,19
DISPLAY STRING1
SCRL 6,34,19,50,06H
scrl 5,32,18,48,67h
SCRL 6,34,6,45,8FH
SETCUR 6,34
DISALL
SETCUR 6,34
MOV CUR,6
MOV CUR1,6
GET:
MOV AH,0
INT 16H
cop:CMP AH,01H
JE E
JMP NEQ
E: JMP EXIT
NEQ:
CMP AH,48H
JE UP
CMP AH,50H
JE DOWN
cmp ah,1ch
je ju
jmp _11
ju:jmp judge
_11:
CMP AH,02H
JE N1
CMP AH,03H
JE N2
CMP AH,04H
JE N3
CMP AH,05H
JE N4
CMP AH,06H
JE N5
CMP AH,07H
JE Y
JMP K
Y: JMP EXIT
K: JMP GET
N1:MOV CUR,6
JMP _UPDOWN
N2:MOV CUR,8
JMP _UPDOWN
N3:MOV CUR,10
JMP _UPDOWN
N4:MOV CUR,12
JMP _UPDOWN
N5:MOV CUR,14
JMP _UPDOWN
UP:
CMP CUR,6
JE ND
SUB CUR,2
SUB CUR1,2
JMP _UPDOWN
ND:MOV CUR,16
MOV CUR1,16
JMP _UPDOWN
DOWN:
CMP CUR,16
JE BEGIN1
ADD CUR,2
ADD CUR1,2
JMP _UPDOWN
BEGIN1:
MOV CUR,6
MOV CUR1,6
JMP _UPDOWN
_UPDOWN: scrl 5,32,18,48,67h
SCRL CUR,34,CUR,45,8FH
SETCUR CUR,34
DISALL
SETCUR CUR,34
MOV AH,0
INT 16H
CMP AH,1CH
JE judge
jmp cop
judge:
cmp cur,6
je begin_pro
cmp cur,10
je net1
jmp net2
net1:jmp search_pro
net2:
cmp cur,8
je del
jmp _net
del: jmp delet_pro
_net:
cmp cur,12
je list_pro
cmp cur,14
je pass_pro
cmp cur,16
je it
JMP menu
it:jmp exit
list_pro:
scrl 0,0,24,79,07h
call list
wai:mov ah,7
int 21h
cmp al,' '
jne wai
jmp menu
begin_pro:
scrl 0,0,24,79,07h
call insert
wai1:mov ah,7
int 21h
cmp al,' '
jne wai1
jmp menu
pass_pro:
call trans
jmp Menu
search_pro:
scrl 0,0,24,79,07h
call search
jmp menu
delet_pro:
scrl 0,0,24,79,07h
call delete
wai2:mov ah,7
int 21h
cmp al,' '
jne wai2
jmp menu
_DOWN:
scrl 5,32,18,48,67h
SCRL CUR,34,CUR,45,8FH
SETCUR CUR,34
DISALL
SETCUR CUR,34
MOV AH,0
INT 16H
CMP AH,1CH
JE judge1
JMP cop
judge1:
cmp cur,14
je list_p1r
JMP ccc
list_p1r:
call trans
jmp menu
ccc:
cmp cur,16
je it1
jmp get
it1:jmp exit
EXIT: pop dx
pop ds
MOV AL,1CH
MOV AH,25H
INT 21H
CLR
setcur 0,0
scrl 0,0,24,79,07h
ret
main endp
openf proc near
LEA DX,FCBREC
MOV AH,0FH
INT 21H
cMP AL,00
JNZ ERROR
MOV FCBRCSZ,RECLEN
MOV AH,1aH
LEA DX,PWORDFLD
INT 21H
RET
ERROR:MOV ENDCDE,01
RET
OPENF ENDP
READF PROC NEAR
MOV AH,14H
LEA DX,FCBREC
INT 21H
CMP PWORDFLD,1AH
JNE TESTS
MOV ENDCDE,01
JMP REND
TESTS:
cmp al,3
jz rend
CMP AL,0
JZ REND
CMP AL,1
JnZ REND
MOV ENDCDE,1
REND:
RET
READF ENDP
closef proc near
push ax
push dx
mov ah,10h
lea dx,fcbrec
int 21h
pop dx
pop ax
ret
closef endp
TIMES PROC NEAR
iret
PUSH DS
PUSH AX
PUSH CX
PUSH DX
PUSH SI
PUSH BX
MOV AX,DATA
MOV DS,AX
STI
LEA SI,TM
mov ah,2H
int 1ah
; jc b2
mov bx,cx
mov al,bh
mov cl,4
shr al,cl
add al,30h
mov [si],al
mov al,bh
and al,0fh
add al,30h
mov [si+1],al
mov al,bl
shr al,cl
add al,30h
mov [si+3],al
mov al,bl
and al,0dh
add al,30h
mov [si+4],al
mov al,dh
shr al,cl
add al,30h
mov [si+6],al
mov al,dh
and al,0fh
add al,30h
mov [si+7],al
SETCUR 24,68
LEA DX,TM
MOV AH,09H
INT 21H
SETCUR CUR,34
B2: CLI
POP BX
POP SI
POP DX
POP CX
POP AX
POP DS
IRET
TIMES ENDP
code ends
end start
2、添加学生信息模块 源代码: insert.ASM
public insert
data0 SEGMENT
CRLF DB 13,10,'$'
ERRCDE DB 0
name1 db 10 dup(?)
num db 6 dup(?)
sex db ?
birth db 8 dup(?)
place db 3 dup(?)
score1 db 5 dup(?)
score2 db 5 dup(?)
score3 db 5 dup(?)
total db 5 dup(?)
msnum db 0ah,0dh," Num :$"
msname db 0ah,0dh," Name :$"
mssex db 0ah,0dh," Sex :$"
msbirth db 0ah,0dh," Birth :$"
msplace db 0ah,0dh," Place :$"
msscore1 db 0ah,0dh," English :$"
msscore2 db 0ah,0dh," Chinese :$"
msscore3 db 0ah,0dh," Maths :$"
mstotal db 0ah,0dh," Total :$"
erfop db 0ah,0dh,'* * * open error ! * * *$'
erfwt db 0ah,0dh,'* * * write error ! * * *$'
erfct db 0ah,0dh,'* * * creat error ! * * *$'
continue db 0ah,0dh,' Press space to continue... $'
confirm db 0ah,0dh,' OK?..(y/n) $'
msg db 0ah,0dh,' Do you want to input another record...?(y/n)$'
mswrong db 0ah,0dh,' Input score is wrong!',0ah,0dh
db ' Please press Enter input again...$'
reclen equ 49
recordf label byte
maxlen db reclen
actlen db ?
recordfld db reclen dup(?)
fcb label byte
fcbdriv db 0
fcbname db 'students'
fcbext db 'txt'
fcbblk dw 0
fcbrcsz dw 0
dd ?
dw ?
dt ?
fcbsqrc db 0
dd ?
s db ?,?,?,'.',?,13,10,'$'
cff db 0
data0 ends
;;;display chars begin at addrs.
showms macro addrs
push dx
lea dx,addrs
mov ah,09h
int 21h
pop dx
endm
stoos macro target,source,count
lea di,target
lea si,source
mov cx,count
cld
rep movsb
endm
getin macro addrs,count1
local lop,zeroit,input_end,exi,lop1
mov bx,0
lop:
mov ah,1
int 21h
cmp al,0dh
jz input_end
cmp al,0ah
jz input_end
mov &addrs&[bx],al
inc bx
cmp bx,count1
jl lop
input_end: cmp bx,count1
je exi
mov ch,0
mov cx,count1
sub cx,bx
lop1:
mov &addrs&[bx],' '
inc bx
loop lop1
exi:
endm
clr macro
push ax
push bx
push cx
push dx
mov ax,0600h
mov cx,0
mov dx,184fh
mov bh,9Eh
int 10h
pop dx
pop cx
pop bx
pop ax
endm
;;she zhi shu biao
setcur macro row,col
push ax
push bx
push cx
push dx
mov ch,5
mov cl,7
mov ah,1
int 10h
mov dh,row
mov dl,col
mov bh,0
mov ah,2
int 10h
pop dx
pop cx
pop bx
pop ax
endm
calt macro n,cff,target
local exx,ae1,ag1
push ax
sub score1[n],30h
mov al,score1[n]
sub score2[n],30h
add al,score2[n]
sub score3[n],30h
add al,score3[n]
add al,cff
add score1[n],30h
add score2[n],30h
add score3[n],30h
cmp al,20
jae ae1
cmp al,10
jae ag1
add al,30h
mov target,al
mov cff,0
jmp exx
ae1:sub al,20
add al,30h
mov target,al
mov cff,2
jmp exx
ag1:sub al,10
add al,30h
mov target,al
mov cff,1
exx:
pop ax
endm
code0 segment
assume cs:code0,ds:data0,es:data0
insert proc far
push ds
push es
mov ax,data0
mov ds,ax
mov es,ax
clr
setcur 0,0
call openf
cmp errcde,0
jz contin
ret
contin:
call inputf
call closef
pop es
pop ds
ret
insert endp
openf proc near
mov ah,0fh
lea dx,fcb
int 21h
cmp al,0
jz found
showms erfop
mov ah,16h
lea dx,fcb
int 21h
or al,al
jz found
showms erfct
mov errcde,01
ret
found:
mov fcbrcsz,reclen
lea dx,recordfld
mov ah,1ah
int 21h
ret
openf endp
inputf proc near
agin:
showms msnum
getin num,6
showms msname
getin name1,10
showms mssex
getin sex,1
showms msbirth
getin birth,8
showms msplace
getin place,3
showms msscore1
getin score1,5
showms msscore2
getin score2,5
showms msscore3
getin score3,5
showms mstotal
getin total,5
showms crlf
calt 4,cff,s+4
calt 2,cff,s+2
calt 1,cff,s+1
calt 0,cff,s
push di
push si
push cx
lea di,s
lea si,total
mov cx,5
rep cmpsb
jne errr1
pop cx
pop si
pop di
jmp ru
errr1:
pop cx
pop si
pop di
showms mswrong
chon:mov ah,0
int 16h
cmp ah,1ch
je agin11
cmp ah,01h
je eeee
jmp chon
eeee:ret
agin11:
jmp agin
ru:showms crlf
showms confirm
ain:
mov ah,1
int 21h
cmp al,'n'
je gi
jmp n1
gi:jmp agin
n1:cmp al,'y'
je st1
jmp ain
st1:
cld
lea di,recordfld
mov al,20h
mov cx,49
rep stosb
serch_end:
mov ah,14h
lea dx,fcb
int 21h
cmp al,01
je wrif
cmp al,0
je serch_end
wrif:
stoos recordfld,num,6
stoos recordfld+6,name1,10
stoos recordfld+16,sex,1
stoos recordfld+17,birth,8
stoos recordfld+25,place,3
stoos recordfld+28,score1,5
stoos recordfld+33,score2,5
stoos recordfld+38,score3,5
stoos recordfld+43,total,5
mov recordfld+48,1ah
call writef
showms msg
aa12:mov ah,1
int 21h
cmp al,'y'
je an11
jmp n22
an11:jmp agin
n22:cmp al,'n'
je iend1
jmp aa12
iend1:
ret
inputf endp
writef proc near
mov ah,15h
lea dx,fcb
int 21h
cmp al,0
jz valid
showms erfwt
mov actlen,0
valid:
ret
writef endp
closef proc near
mov ah,10h
lea dx,fcb
int 21h
ret
closef endp
code0 ends
end
3、删除学生信息模块源代码:DELET.ASM
public delete
Psize equ 8
Rsize equ 49
dataseg segment
myfcb label byte
fcbdriv db 0
fcbname db 'students'
fcbext db 'txt'
fcbblk dw 0
fcbrcsz dw 0
dd ?
dw ?
dt ?
fcbwqrc db 0
dd ?
my_fcb label byte
fcb_driv db 0
fcb_name db 'students'
fcb_ext db 'txt'
fcb_blk dw 0
fcb_rcsz dw 0
dd ?
dw ?
dt ?
fcb_wqrc db 0
dd ?
dtapar label byte
maxl db 49
act db ?
dta db 49 dup(?)
dtap label byte
maxle db 49
actl db ?
mydta db 49 dup(?)
crlf db 13,10,'$'
num db 6 dup(?)
names db 10 dup(?)
sex db ?
birth db 8 dup(?)
place db 3 dup(?)
score1 db 5 dup(?)
score2 db 5 dup(?)
score3 db 5 dup(?)
total db 5 dup(?)
err_fopen db 0ah,0dh," File open error! $"
err_fcreat db 0ah,0dh," File creat error!$"
err_fread1 db 0ah,0dh," File read error in sequence manner! $"
err_fread2 db 0ah,0dh," File read error in random manner !$"
err_fclose db 0ah,0dh," File close error !$"
d_ms db 13,10,'Please input delet num :$'
del_sto db 40 dup(49 dup(?)),'$'
del_num db 6 dup(?),'$'
del_err db 13,10,'the file is end !$'
record_num1 db ?
record_num2 db ?
notar db 13,10,'this num is not in the queue!$'
del_creat db 'del_creat error!',13,10,'$'
erfwt db 'write error! ',13,10,'$'
del_suc db 'delete succesful!',13,10,'$'
dataseg ends
show macro addrs
;display a line started at addrs.
push dx
lea dx,addrs
mov ah,09h
int 21h
pop dx
endm
codeseg segment
assume cs:codeseg,ds:dataseg,es:dataseg
delete proc far
push ds
push es
mov ax,dataseg
mov es,ax
mov ds,ax
call delet
call closef
pop es
pop ds
ret
delete endp
openf proc near
mov ah,0fh
lea dx,myfcb
int 21h
or al,al
jz found
show err_fopen
found: mov fcbrcsz,49
mov ah,1ah
lea dx,dta
int 21h
ret
openf endp
closef proc near
mov ah,10h
lea dx,myfcb
int 21h
ret
closef endp
closef1 proc near
mov ah,10h
lea dx,my_fcb
int 21h
ret
closef1 endp
delet proc near
lea di,del_sto
call openf
or al,al
je del_be
jmp del_exit
del_be:
show d_ms
mov bx,0
del_in:
mov ah,1
int 21h
mov del_num[bx],al
inc bx
cmp bx,6
jl del_in
mov record_num1,0
mov record_num2,0
del_read:
lea dx,myfcb
mov ah,14h
int 21h
cmp al,01
jne del_m3
jmp del_fend
del_m3:
cmp al,0
je del_m4
cmp al,03
je del_fend
del_m4:
del_compar:
push di
lea di,dta
lea si,del_num
mov cx,6
cld
rep cmpsb
pop di
jz del_r
jmp del_writ
del_r:
inc record_num1
push di
push si
cld
lea di,dta
mov cx,24
mov ax,2020h
rep stosw
pop si
pop di
jmp del_read
del_writ:
inc record_num1
inc record_num2
lea si,dta
mov cx,49
cld
rep movsb
push di
push si
cld
lea di,dta
mov cx,24
mov ax,2020h
rep stosw
pop si
pop di
jmp del_read
del_fend:
call closef
mov al,record_num1
cmp al,record_num2
je no_tar
lea dx,my_fcb
mov ah,16h
int 21h
or al,al
jne del_exit
mov bx,0
dec record_num2
del_cre:
push di
push si
cld
lea di,mydta
mov cx,49
mov ax,2020h
rep stosb
pop si
pop di
lea si,del_sto[bx]
lea di,mydta
mov cx,49
cld
rep movsb
mov fcb_rcsz,49
mov ah,1ah
lea dx,mydta
int 21h
mov ah,15h
lea dx,my_fcb
int 21h
add bx,49
dec record_num2
jnz del_cre
call closef1
show crlf
show del_suc
jmp del_ret
no_tar: show notar
jmp del_ret
del_exit:
show del_creat
del_ret:
ret
delet endp
codeseg ends
end
4、查找学生信息模块:search.ASM
public search
Psize equ 8
Rsize equ 49
data2 segment
myfcb label byte
fcbdriv db 0
fcbname db 'students'
fcbext db 'txt'
fcbblk dw 0
fcbrcsz dw 0
dd ?
dw ?
dt ?
fcbwqrc db 0
dd ?
dtapar label byte
maxl db 49
act db ?
dta db 49 dup(?)
crlf db 13,10,'$'
num db 6 dup(?)
names db 10 dup(?)
sex db ?
birth db 8 dup(?)
place db 3 dup(?)
score1 db 5 dup(?)
score2 db 5 dup(?)
score3 db 5 dup(?)
total db 5 dup(?)
pcounter db ?
err_fopen db 0ah,0dh," File open error! $"
err_fcreat db 0ah,0dh," File creat error!$"
err_fread1 db 0ah,0dh," File read error in sequence manner! $"
err_fread2 db 0ah,0dh," File read error in random manner !$"
err_fclose db 0ah,0dh," File close error !$"
msnum db 13,10,' 1.num',13,10,'$'
msname db ' 2.name',13,10,'$'
mskey db ' key item :$'
msnumva db 13,10,' Input num value :$'
msnameva db 13,10,' Input name value :$'
numsto db 6 dup(?)
namesto db 10 dup(?)
inflag db ?
continue db 0ah,0dh," Press space to continue...$"
no_target db 13,10,'Sorry! Search wrong! Please confirm and again! (y/n)? $'
serch_another db 13,10,'Search another one ?(y/n): $'
data2 ends
show macro addrs
;display a line started at addrs.
push dx
lea dx,addrs
mov ah,09h
int 21h
pop dx
endm
show_item macro addrs,count1,count2
local iloop,spacelp
mov bx,0
iloop:
mov dl,&addrs&[bx]
mov ah,2
int 21h
inc bx
cmp bx,count1
jl iloop
mov cx,count2
spacelp:
mov dl," "
mov ah,2
int 21h
loop spacelp
endm
code2 segment
assume cs:code2,ds:data2,es:data2
search proc far
push ds
PUSH ES
mov ax,data2
mov es,ax
mov ds,ax
call _search
call closef
pop es
pop ds
ret
search endp
show_rec proc near
push ax
push bx
push cx
push dx
show_item num,6,2
show_item names,10,2
show_item sex,1,2
show_item birth,8,3
show_item place,3,2
show_item score1,5,2
show_item score2,5,2
show_item score3,5,2
show_item total,5,2
pop dx
pop cx
pop bx
pop ax
ret
show_rec endp
openf proc near
mov ah,0fh
lea dx,myfcb
int 21h
or al,al
jz found
show err_fopen
found: mov fcbrcsz,49
mov ah,1ah
lea dx,dta
int 21h
ret
openf endp
closef proc near
mov ah,10h
lea dx,myfcb
int 21h
ret
closef endp
_search proc near
s_begin:
mov fcbblk+1,0
call openf
or al,al
je se_be
jmp _exit_
se_be:
show msnum
show msname
show mskey
mov bx,0
_ag:mov ah,1
int 21h
mov inflag,al
cmp al,'1'
je _na
cmp al,'2'
jne _ag
show msnameva
ag_in:mov ah,1
int 21h
cmp al,0ah
je in_end_
cmp al,0dh
je in_end_
mov namesto[bx],al
inc bx
cmp bx,10
jl ag_in
in_end_:
push cx
mov cx,10
sub cx,bx
mov ch,0
lp_:mov namesto[bx],' '
inc bx
loop lp_
pop cx
jmp in_end
_na: show msnumva
_na_:mov ah,1
int 21h
mov numsto[bx],al
inc bx
cmp bx,6
jl _na_;
in_end:
se_re:
cmp inflag,'1'
jne _namese
se_one:
lea dx,myfcb
mov ah,14h
int 21h
cmp al,01
jne m3
jmp f_end
m3:
cmp al,0
je m4
;cmp al,03
;je f_end
m4:
mov bx,0
movin:
mov al,dta[bx]
mov num[bx],al
inc bx
cmp bx,RSize
jl movin
mov cx,6
lea di,num
lea si,numsto
cld
rep cmpsb
jne se_one
show crlf
call show_rec
call closef
jmp se_anone
f_end:show no_target
jmp jj
se_anone:
show serch_another
jj:mov ah,1
int 21h
cmp al,'y'
je s_begi
jmp _n_
s_begi:jmp s_begin
_n_:
cmp al,'n'
jne jj
jmp _exit_
_namese:
se_one_:
lea dx,myfcb
mov ah,14h
int 21h
cmp al,01
jne m3_
jmp f_end_
m3_:
cmp al,0
je m4_
cmp al,03
je f_end_
m4_:
mov bx,0
movin_:
mov al,dta[bx]
mov num[bx],al
inc bx
cmp bx,RSize
jl movin_
mov cx,10
lea di,num+6
lea si,namesto
cld
rep cmpsb
jne se_one_
show crlf
call show_rec
call closef
jmp se_anone_
f_end_:show no_target
jmp jj_
se_anone_:
show serch_another
jj_:mov ah,1
int 21h
cmp al,'y'
je s_be
jmp __n
s_be:jmp s_begin
__n:cmp al,'n'
jne jj_
jmp _exit_
_exit_:
ret
_search endp
code2 ends
end
5、显示所有学生信息模块: LIST.ASM
public list
Psize equ 8
Rsize equ 49
data1 segment para 'data1'
myfcb label byte
fcbdriv db 0
fcbname db 'students'
fcbext db 'txt'
fcbblk dw 0
fcbrcsz dw 0
dd ?
dw ?
dt ?
fcbwqrc db 0
dd ?
dtapar label byte
maxl db 49
act db ?
dta db 49 dup(?)
num db 6 dup(?)
names db 10 dup(?)
sex db ?
birth db 8 dup(?)
place db 3 dup(?)
score1 db 5 dup(?)
score2 db 5 dup(?)
score3 db 5 dup(?)
total db 5 dup(?)
lst1 db ' NUM NAME SEX BIRTH PLACE ENGLISH '
db 'CHINESE MATHS TOTAL',0AH,0DH,'$'
pc db 0
err_fopen db 0ah,0dh," File open error! $"
err_fcreat db 0ah,0dh," File creat error!$"
err_fread1 db 0ah,0dh," File read error in sequence manner! $"
err_fread2 db 0ah,0dh," File read error in random manner !$"
err_fclose db 0ah,0dh," File close error !$"
continue db 0ah,0dh," Press space to continue...$"
crlf db 13,10,'$'
data1 ends
show macro addrs
;display a line started at addrs.
push dx
lea dx,addrs
mov ah,09h
int 21h
pop dx
endm
show_item macro addrs,count1,count2
local iloop,spacelp
push ax
push bx
push cx
push dx
mov bx,0
iloop:
mov dl,&addrs&[bx]
mov ah,2
int 21h
inc bx
cmp bx,count1
jl iloop
mov cx,count2
spacelp:
mov dl," "
mov ah,2
int 21h
loop spacelp
pop dx
pop cx
pop bx
pop ax
endm
setcur macro row,col
push ax
push bx
push cx
push dx
mov ch,5
mov cl,7
mov ah,1
int 10h
mov dh,row
mov dl,col
mov bh,0
mov ah,2
int 10h
pop dx
pop cx
pop bx
pop ax
endm
code1 segment
assume cs:code1,ds:data1,es:data1
list proc far
push ds
push es
mov ax,data1
mov es,ax
mov ds,ax
call list_all
call closef
pop es
pop ds
ret
list endp
;********************************************
;list_all procedure lists the document *
;file in a page manner *
;********************************************
list_all proc near
setcur 0,0
show lst1
show crlf
call openf
or al,al
jz list_loop
jmp ext
list_loop:
lea dx,myfcb
mov ah,14h
int 21h ;read a record in sequence manner.
cmp al,01
jne n3
jmp file_end ;(al)=1:meets the end of file.
n3:
cmp al,0
je n4
cmp al,03
je n4
show err_fread1 ;read error
mov dl,"0"
add dl,al
mov ah,2
int 21h ;show error no.
jmp file_end
n4:
mov bx,0
moving:
mov al,dta[bx]
mov num[bx],al
inc bx
cmp bx,RSize
jl moving
show crlf
call show_rec
show crlf
jmp list_loop
file_end:
call closef
ext:
ret
list_all endp
show_rec proc near
push ax
push bx
push cx
push dx
show_item num,6,2
show_item names,10,2
show_item sex,1,2
show_item birth,8,3
show_item place,3,3
show_item score1,5,4
show_item score2,5,4
show_item score3,5,4
show_item total,5,2
pop dx
pop cx
pop bx
pop ax
ret
show_rec endp
openf proc near
mov ah,0fh
lea dx,myfcb
int 21h
or al,al
jz found
show err_fopen
found: mov fcbrcsz,49
mov ah,1ah
lea dx,dta
int 21h
ret
openf endp
closef proc near
mov ah,10h
lea dx,myfcb
int 21h
ret
closef endp
code1 ends
end
6、修改密码模块:tran.asm
public trans
DSEG SEGMENT PARA 'DATA'
RECLEN EQU 9
pass LABEL BYTE
MAXLEN DB RECLEN
passLEN DB ?
passDTA DB RECLEN DUP(' ')
FCBREC LABEL BYTE
FCBDRIV DB 0
FCBNAME DB 'password'
FCBEXT DB 'txt'
FCBBLK DW 0
FCBRCSZ DW ?
FCBFLSZ DD ?
DW ?
DT ?
FCBSQRC DB 0
DD ?
CRLF DB 13,10,'$'
ERRCDE DB 0
PROMPT DB 'Input new password(8bit):','$'
OPNMSG DB 'OPEN ERROR','$'
WRTMSG DB 'WRITE ERROR','$'
passw db reclen dup(?)
DSEG ENDS
setcur macro row,col
push ax
push bx
push cx
push dx
mov ch,5
mov cl,7
mov ah,1
int 10h
mov dh,row
mov dl,col
mov bh,0
mov ah,2
int 10h
pop dx
pop cx
pop bx
pop ax
endm
;;;scrooll
scrl macro lrow,lcol,rrow,rcol,color
push ax
push bx
push cx
push dx
mov ah,6
mov al,0
mov cl,lcol
mov ch,lrow
mov dh,rrow
mov dl,rcol
mov bh,color
int 10h
pop dx
pop cx
pop bx
pop ax
endm
CSEG SEGMENT PARA 'CODE'
trans PROC FAR
ASSUME CS:CSEG,DS:DSEG,ES:DSEG
PUSH DS
push es
MOV AX,DSEG
MOV DS,AX
MOV ES,AX
CALL CREATEF
CMP ERRCDE,0
JZ CONTIN
pop es
pop ds
RET
CONTIN:
CALL INPUTF
CALL CLSEF
pop es
pop ds
RET
trans ENDP
CREATEF PROC NEAR
MOV AH,16H
LEA DX,FCBREC
INT 21H
CMP AL,0
JNZ ERR1
MOV FCBRCSZ,RECLEN
LEA DX,passDTA
MOV AH,1AH
INT 21H
RET
ERR1:
LEA DX,OPNMSG
CALL ERRM
RET
CREATEF ENDP
INPUTF PROC NEAR
scrl 0,0,24,79,07h
setcur 0,0
MOV AH,9
LEA DX,PROMPT
INT 21H
mov cx,8
mov si,0
setcur 0,25
lop:
mov ah,7
int 21h
mov passw[si],al
inc si
mov ah,2
mov dl,'*'
int 21h
loop lop
mov cx,8
lea di,passdta
lea si,passw
cld
rep movsb
CALL DISP
BLANK:
CALL WRITEF
CLD
RET
INPUTF ENDP
DISP PROC NEAR
MOV AH,9
LEA DX,CRLF
INT 21H
RET
DISP ENDP
WRITEF PROC NEAR
MOV AH,15H
LEA DX,FCBREC
INT 21H
CMP AL,0
JZ VALID
LEA DX,WRTMSG
CALL ERRM
MOV passLEN,0
VALID:
RET
WRITEF ENDP
CLSEF PROC NEAR
MOV AH,10H
LEA DX,FCBREC
INT 21H
RET
CLSEF ENDP
ERRM PROC NEAR
MOV AH,9
INT 21H
MOV ERRCDE,01
RET
ERRM ENDP
CSEG ENDS
END
以上是该系统的所有源代码,系统运行时还有两个文本文件,
分别为存放学生信息数据的students.txt
和存放密码的password.txt
首先单个编译每个文件,然后再一起连接,生成可执行文件就可以了。
其中当密码文件里是空的时候不需要输入密码,就可以直接进入系统界面了