home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BBS 1
/
BBS#1.iso
/
maximus
/
bbslimit.arj
/
LIMITCNV.ASM
< prev
next >
Wrap
Assembly Source File
|
1991-05-12
|
12KB
|
531 lines
.model tiny
.code
.startup
.286
check_file struc
req_name dw ? ; pointer on end of requested name
chg_name dw ? ; pointer on end of name to change
chg_size db ? ; size of chg_name
day db ? ; binary package for checked days
; all,mon,sun,sat,fri,the,wed,tue
time_from dw ? ; begin changing in BCD
time_to dw ? ; end changing in BCD
ends
jmp begin
days db 'ALL'
db 'MON'
db 'SUN'
db 'SAT'
db 'FRI'
db 'THU'
db 'WED'
db 'TUE'
name_pointer dw offset filenames ;pointer on end of current filename
struct_counter dw 0 ;number of fully filled structure
inc_size dw 0 ;size of compiled filename (current)
token db '[]: ',13 ;control characters
file_position dw 0 ;current position in file buffer
file_segment dw 0 ;segment of loaded file
file_size dw 0 ;size of file
file_name db 'limits.ext',0 ;input filename
out_name db 'limits.use',0 ;output filename
little_buffer db 0 ;buffer for get_token
position dw 0 ;position in current string
string_number dw 0 ;current_string
error_message dw 0
get_token proc near
push ds
push si
lds si,dword ptr cs:file_position
cld
lodsb
mov cs:file_position,si
inc word ptr cs:position ;next position in line
cmp si,cs:file_size ;EOF?
ja end_of_file
gt_1:
pop si
pop ds
mov little_buffer,al
ret
end_of_file:
mov al,-2 ;end of file reached
jmp gt_1
endp
wait_for proc near
;procedure for first pass
; input al == requested token
; reading, while token comes or EOL
mov dl,al
wf3:
call get_token
cmp al,-2 ;EOF?
je wf1
cmp al,dl
je token_accepted
cmp al,0dH
jne wf3
call error
token_accepted:
cmp al,0dH
jne wf2
mov position,0 ;new line
inc word ptr string_number
call get_token ;discard 0aH
mov al,0dH
wf2:
clc
ret
wf1:
stc
ret
endp
toupper proc near
cmp al,'A'
jb do_nothing
cmp al,'z'
ja do_nothing
and al,11011111B
do_nothing:
ret
endp
input_while proc near
; input while requested control character comes
; al == requested ctrl-char
; ds:si == buffer to output
mov dx,ax
push cs
pop es
cld
next_token:
mov di,offset token
mov cx,5 ;number of control character
call get_token
cmp dl,al ;is this requested token?
je iw_ok
cmp dh,al
je iw_ok
repne scasb
je error_in_file
call toupper
mov ds:[si],al ;store character in buffer
inc si
jmp next_token
error_in_file:
cmp al,' ' ;is this SPACE
je next_token
cmp al,0dH
je next_token
call error
iw_ok:
ret
endp
check_char proc near
mov si,name_pointer
mov ah,0ffH
call input_while
cmp si,name_pointer
jne cc_ok
mov error_message,offset empty_field
call error
cc_ok:
ret
endp
check_token proc near
mov error_message,offset missing
call wait_for
jnc ct1
call error
ct1:
ret
endp
error proc near
push cs
pop ds
mov dx,error_message
mov ah,9
int 21H
int 20h
endp
pass_one proc near
mov cx,2
po1:
push cx
mov al,'['
call check_token
mov al,']'
call check_char
pop cx
loop po1 ;check filenames
mov al,'['
call check_token
mov al,']'
call check_char ;check days
mov cx,2
check_date:
push cx
mov al,'['
call check_token
mov al,':'
call check_char
mov al,']'
call check_char
pop cx
loop check_date
inc word ptr struct_counter
mov al,13 ;check EOL
call wait_for
jc po_ok
mov al,'[' ;pre-check
mov ah,-2
call input_while
dec word ptr cs:file_position
cmp al,-2
jne pass_one
po_ok:
ret
endp
set_day_bits proc near
mov di,80H ;place of day (in ASCII)
mov si,offset days
mov dl,80H
cld
next_day:
push si
mov cx,3
repe cmpsb
pop si
je day_found
add si,3
mov di,80H
shr dl,1
jnc next_day
mov error_message,offset unk_day
call error
day_found:
or bx[day],dl
ret
endp
get_hour proc near
mov error_message,offset bad_time_format
mov si,80H
cld
lodsb
sub al,30H
cmp al,2
jbe gh1
call error
gh1:
mov cl,4
shl al,cl
mov ah,al
lodsb
sub al,30h
cmp al,9
jbe gh2
call error
gh2:
or ah,al
cmp ah,0
jne gh3
mov ah,24H
gh3:
mov byte ptr bx[time_from+1],ah
cmp ah,24H
jbe gh_ok
call error
gh_ok:
ret
endp
get_min proc near
mov error_message,offset bad_time_format
mov si,80H
cld
lodsb
sub al,30H
cmp al,6
jbe gm1
call error
gm1:
mov cl,4
shl al,cl
mov ah,al
lodsb
sub al,30h
cmp al,9
jbe gm2
call error
gm2:
or ah,al
mov byte ptr bx[time_from],ah
cmp ah,60H
jb gh_ok
call error
gm_ok:
ret
endp
pass_two proc near
mov bx,offset headers
pt_again:
mov al,'['
call check_token ;begin 1st name
mov al,']'
call check_char
dec si
mov bx[req_name],si ;store current pointer on fname
sub bx[req_name],offset filenames
inc si
mov ax,si
sub ax,name_pointer ;si == size of name
mov name_pointer,si
mov bx[chg_size],al ;store size of name
mov al,'['
call check_token ;begin 2nd name
mov al,']'
call check_char
mov ax,si
dec ax
mov bx[chg_name],ax ;pointer on changing name
sub bx[chg_name],offset filenames
inc ax
sub ax,name_pointer ;get size of 2nd filename
mov name_pointer,si ;store new filenames pointer
cmp al,bx[chg_size]
je pt1
mov error_message,offset size_mismatch
call error
pt1: ;first two field processed!
;*************** GET WEEK DAY *************
mov al,'['
call check_token
pt3:
mov al,']' ;read while ] or SPACE comes
mov ah,' '
mov si,80H
call input_while
push ax
call set_day_bits
pop ax
cmp al,']' ;is it end of fields
je pt2
jmp pt3
;************** GET TIME ******************
pt2:
mov bp,2
pt4:
mov al,'['
call check_token
mov al,':'
mov ah,0ffh
mov si,80H
call input_while
call get_hour
mov al,']'
mov ah,0ffH
mov si,80H
call input_while
call get_min
add bx,2 ;next time field
dec bp
jnz pt4
sub bx,4
;check time
mov ax,bx[time_from]
cmp ah,24H
jne pt5
mov ah,0
pt5:
mov error_message,offset incorrect_time
mov dx,bx[time_to]
cmp dh,24H
jne pt7
mov dh,0
pt7:
cmp ax,dx
jbe pt6
call error
pt6:
jne pt8
or bx[time_from],8000H
pt8:
dec byte ptr struct_counter
jz pt_ok
mov al,13 ;check EOL
call wait_for
mov al,'[' ;pre-check
call input_while
dec word ptr cs:file_position
add bx,10
jmp pt_again
pt_ok:
ret
endp
adjust_offset proc near
mov bx,offset headers
mov ax,struct_counter
push ax
mov cl,10
mul cl
mov dx,ax
pop cx
next_struct:
add bx[req_name],dx
add bx[chg_name],dx
add bx,10
loop next_struct
ret
endp
write_file proc near
mov error_message,offset error_write
mov ah,3cH
mov dx,offset out_name
mov cx,20H
int 21H
jnc wrf1
call error
wrf1:
mov bx,ax
mov ah,40H
mov cx,2
mov dx,offset struct_counter
int 21H
jnc wrf4
call error
wrf4:
mov ax,struct_counter
mov cl,10
mul cl
mov cx,ax
mov dx,offset headers
mov ah,40H
int 21H
jnc wrf2
call error
wrf2:
mov cx,name_pointer
sub cx,offset filenames
mov dx,offset filenames
mov ah,40H
int 21H
jnc wrf3
call error
wrf3:
mov ah,3eH
int 21H
ret
endp
begin:
mov ah,9
mov dx,offset copyright
int 21H
mov error_message,offset file_not_found
mov ax,3d12H
mov dx,offset file_name
int 21H
jnc open_ok
call error
open_ok:
mov bx,ax
xor cx,cx
xor dx,dx
mov ax,4202H
int 21H
jnc m1
call error
m1:
mov error_message,offset file_to_big
or dx,dx
je m2
call error
m2:
mov file_size,ax
mov cx,ax
mov ax,ds
add ax,1000H
mov error_message,offset not_memory
mov ds,ax
mov cs:file_segment,ax
push cx
shr cx,1
shr cx,1
shr cx,1
shr cx,1
add ax,cx ;check_memory
pop cx
cmp ax,9fffH
jna m3
call error
m3:
mov ax,4200H
xor cx,cx
xor dx,dx
int 21H
mov cx,cs:file_size
mov ah,3fH
mov dx,0
int 21H
jnc m4
call error
m4:
mov ah,3eH
int 21H
push cs
pop ds
mov ah,9
mov dx,offset pass1
int 21H
call pass_one
mov ah,9
mov dx,offset ok
int 21H
mov dx,offset pass2
mov ah,9
int 21H
mov word ptr file_position,0
mov position,0
mov string_number,0
mov name_pointer,offset filenames
push word ptr struct_counter
call pass_two
mov ah,9
mov dx,offset ok
int 21h
pop ax
mov struct_counter,ax
call adjust_offset
call write_file
int 20H
empty_field db 'Empty Field!',10,13,24H
missing db 'Control Character missing!',10,13,24H
file_not_found db 'Input File not found!',10,13,24H
file_to_big db 'File too big!',10,13,24H
bad_time_format db 'BAD Time format !',10,13,24H
size_mismatch db 'Size of filenames not equal!',10,13,24H
not_memory db 'Not Enough memory!',10,13,24H
unk_day db 'Unknown Day!',10,13,24H
incorrect_time db 'Incorrect time setting!',10,13,24H
error_write db 'Write error!',10,13,24H
pass1 db 10,13,'Pass one...',24H
pass2 db 'Pass two...',24H
ok db 'Ok!',10,13,24H
copyright db "Dynamical BBS's access file converter. Copyright (C) AlexQ 1991.",10,13
db ' Red Rat Club Moscow,Russia.',10,13
db ' Free!',10,13,24H
headers label word
org 10*100 + offset headers
filenames label word
end