home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-387-Vol-3of3.iso
/
m
/
memres41.zip
/
TABLEV.ASM
< prev
next >
Wrap
Assembly Source File
|
1988-05-20
|
6KB
|
132 lines
; Ed Jordan 201 Smallacombe Drive, Scranton, Pa. 18508
; Version 1 - December 1986
; Version 1a - May 1988 - write table to disk from buffer instead of 0:0
cr equ 13 ; carriage return
lf equ 10 ; line feed
el equ '$' ; end of string sign
eof equ 1ah ; end of file mark
esc equ 1bh ; escape character
stdin equ 0 ; standard input
stdout equ 1 ; standard output
stderr equ 2 ; standard error handle
stdaux equ 3 ; standard aux
stdprn equ 4 ; standard printer handle
stackseg segment stack para 'stack'
db 40 dup('stack')
stackseg ends
dataseg segment public para 'data'
error1 db 'Vector table found in current directory.',cr,lf
db 'Press any key to revise this table or <ESC>',cr,lf
db 'to exit.',cr,lf,el
error2 db cr,lf,'Error creating file <VECTOR.TBL>.',cr,lf,el
mesg1 db cr,lf,'Copying vector table... ',el
mesg2 db 'done.',cr,lf,el
mesg3 db 'VECTOR.TBL',0
handle dw ?
mesg4 db eof
mesg5 db 'TABLEV.EXE version 1a - May 1988'
db cr,lf,'Author: Ed Jordan',cr,lf,el
buffer db 400h dup (0)
dataseg ends
codeseg segment public para 'code'
assume cs:codeseg,ds:dataseg,es:nothing,ss:stackseg
tablev proc far
mov ax,dataseg
mov ds,ax
mov es,ax
lea dx,mesg5
call printerr
lea dx,mesg3 ; point to asciiz
call open_file ; open file
jnb tbl1 ; if error file not found
tbl3: lea dx,mesg3
call create_file ; make file if not found
jnb tbl4
tbl5: lea dx,error2 ; signal if error encountered
call printerr
jmp short tbl2
tbl1: lea dx,error1
call printerr
call wait_response ; wait for keyboard resp
cmp al,esc ; test for escape key
jz tbl2 ; exit if pressed
jmp tbl3
tbl4: mov handle,ax ; store file handle
lea dx,mesg1
call printerr
push ds
lea di,buffer ; point to buffer
xor ax,ax
mov ds,ax
xor si,si
mov cx,0400h
rep movsb ; copy bytes to buffer
pop ds
mov bx,handle
lea dx,buffer ; ds:dx = data to write
mov cx,0400h ; size of vector table
mov ah,40h ; write file
int 21h
jb tbl5
mov ax,dataseg ; reset the data segment
mov ds,ax
call close_file ; close the file
jb tbl5
lea dx,mesg2
call printerr
tbl2: mov ah,4ch
int 21h ; exit
tablev endp
open_file proc near
mov ah,3dh ; open file
mov al,2 ; read/write access code
int 21h
ret
open_file endp
wait_response proc near
mov ax,0c08h ; no need to make
int 21h ; keyboard response capital
ret ; letters only
wait_response endp
close_file proc near
mov ah,3eh ; bx= handle
int 21h
ret
close_file endp
create_file proc near
mov ah,3ch ; ds:dx= asciiz
xor cx,cx ; attribute of file
int 21h
ret
create_file endp
printerr proc near
push es ; ds:dx = message
push ds
pop es
mov cx,250 ; max number of char per
mov al,el ; message
mov di,dx ; look for end of string
repne scasb
mov cx,di ; get string size
sub cx,dx ; number of bytes to write
dec cx ; don't print the last byte
mov bx,stderr
mov ah,40h ; write to file function
int 21h
pop es
ret
printerr endp
codeseg ends
end