getin macro addrs,count2
local zeroit,lp,input_end,exit
push bx
push ax
mov bx,0
zeroit: mov addrs[bx],' '
inc bx
cmp bx,15
jl zeroit
mov bx,0
lp: mov ah,1
int 21h
cmp al,0ah
jz input_end
cmp al,0dh
jz input_end
mov addrs[bx],al
inc bx
cmp bx,count2
jl lp
input_end: cmp al,0dh
jz exit
cmp al,0ah
jz exit
mov ah,7
int 21h
jmp input_end
exit:
pop ax
pop bx
endm
code segment
main proc far
assume cs:code,ds:data,es:data
start:
mov ax,data
mov ds,ax
mov ah,0
mov al,3
int 10h
clear
show mess1
show mess2
show mess13
show mess3
show mess4
show mess5
show mess6
show mess7
show mess8
show mess9
newline
show mess10
set_p3
w: mov ah,7
int 21h
cmp al,'i'
jnz n1
call insert
jmp w
n1: cmp al,'m'
jnz n2
call modify
jmp w
n2: cmp al,'d'
jnz n3
call delete
jmp w
n3: cmp al,'q'
jnz n4
call query
jmp w
n4: cmp al,'c'
jnz n5
call cot
jmp w
n5: cmp al,'p'
jnz n6
call print
jmp w
n6: cmp al,'l'
jnz n7
call list
jmp w
n7: cmp al,'e'
jz exitf
jmp w
exitf:
mov ah,4ch
int 21h
ret
main endp
insert proc near
push ax
push bx
push cx
push dx
mov dx,offset fname
mov al,2
mov ah,3dh
int 21h
mov bx,ax
clear1
set_p1 4
call get_rec
mov cx,0 ;move file pointer to end
mov dx,0
mov al,2
mov ah,42h
int 21h
mov cx,23 ;write file
mov dx,offset buffer1
mov ah,40h
int 21h
mov ah,3eh
int 21h
set_p3
pop dx
pop cx
pop bx
pop ax
ret
insert endp
get_rec proc near
push ax
push bx
getin buffer2,15
mov bx,0
mov cx,15
continue: mov al,buffer2[bx]
mov buffer1[bx],al
inc bx
loop continue
set_p1 5
getin buffer2,2
mov al,buffer2
mov buffer1[bx],al
inc bx
mov al,buffer2+1
mov buffer1[bx],al
inc bx
set_p1 6
getin buffer2,2
mov al,buffer2
mov buffer1[bx],al
inc bx
mov al,buffer2+1
mov buffer1[bx],al
inc bx
set_p1 7
getin buffer2,2
mov al,buffer2
mov buffer1[bx],al
inc bx
mov al,buffer2+1
mov buffer1[bx],al
inc bx
set_p1 8
getin buffer2,2
mov al,buffer2
mov buffer1[bx],al
inc bx
mov al,buffer2+1
mov buffer1[bx],al
inc bx
pop bx
pop ax
ret
get_rec endp
openf proc near
mov dx,offset fname
mov al,02
mov ah,3dh
int 21h
mov handle,ax
ret
openf endp
query proc near
push ax
push bx
push cx
push dx
clear1
clear2
mov dx,offset fname
mov al,2
mov ah,3dh
int 21h
mov bx,ax
set_p2
getin buffer1,15
lea dx,mess11
mov ah,9
int 21h
b:
mov ah,3fh
mov cx,23
mov dx,offset buffer2
int 21h
lea si,buffer2
lea di,buffer1
mov cx,15
c:
mov al,byte ptr[si]
cmp al,byte ptr[di]
jnz b
inc si
inc di
loop c
mov [buffer2+23],'$'
show_item buffer2
mov ah,3eh
int 21h
pop dx
pop cx
pop bx
pop ax
ret
query endp