home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
WWIV2.ZIP
/
LOADER.ASM
< prev
next >
Wrap
Assembly Source File
|
1992-08-16
|
7KB
|
246 lines
.MODEL TINY
.CODE
org 100h
start:
jmp start1
flag db 0 ; set to 1 if rerun BBS
prog_name: ; store secondary program to run
db 81 dup (0)
bbs_name: ; name of the BBS executable
db 'BBS.EXE',0
path_ptr:
dw 0 ; pointer into pathname
bbs_path: ; full pathname of BBS executable
db 'A:\'
db 81 dup (0)
;
; Set up stack and release extra memory
;
start1:
mov ax,cs
mov ss,ax
mov sp,OFFSET stack_top ; set the stack
mov es,ax
mov bx,OFFSET stack_top ; last byte used
mov cl,4
shr bx,cl ; get paragraph count
add bx,1 ; add 1 for luck
mov ah,4ah ; func 4AH = SETBLOCK
int 21h ; give back most of memory to DOS
;
; Make all our segments equal to CS
;
push cs
push cs
pop ds
pop es
;
; Set up full pathname of bbs
;
mov ah,19h ; get current disk
int 21h
add byte ptr[bbs_path],al ; set current disk in path
mov ah,47h ; Get current directory
mov dl,0 ; current disk
mov si,OFFSET bbs_path
add si,3 ; skip "X:\"
int 21h ; get pathname
mov di,OFFSET bbs_path
loop1: ; search for end of pathname
inc di
cmp byte ptr [di],0
jne loop1 ; find end of path
mov ah,[di - 1] ; see if there is a backslash on end
cmp ah,'\'
je yes
mov byte ptr[di],'\' ; add a backslash
mov word ptr[path_ptr],di ; store pointer to backslash
inc di
yes:
mov si,OFFSET bbs_name ; point to BBS.EXE
loop2:
mov ah,[si] ; copy over a char
mov [di],ah
inc si
inc di
cmp ah,0 ; at the end of it?
jne loop2
push cs
pop ax
mov word ptr [parm_block+4],ax ; Set CS in parm_block
;
; Run the BBS
;
exec_bbs:
push cs ; set all the segments to CS again
push cs
pop ds
pop es
mov byte ptr [flag],0 ; clear flag
;
; Add on the argument "/Xssss:oooo" where ssss:oooo points to "flag"
;
mov si,80h
mov al,byte ptr[si] ; get length of BBS.EXE arguments
mov ah,0
mov di,81h
add di,ax ; point di to end of BBS.EXE args
mov byte ptr[di],' ' ; add on " /X"
inc di
mov byte ptr[di],'/'
inc di
mov byte ptr[di],'X'
inc di
push cs ; convert CS to hex
pop bx
call hex_cnv
mov byte ptr[di],':' ; add in ":"
inc di
mov bx,OFFSET flag ; convert offset of flag into nex
call hex_cnv
mov byte ptr[di],0 ; null terminate args
sub di,81h
mov ax,di
mov byte ptr[si],al ; store length
;
; Set the default drive and path correctly
;
mov dl,byte ptr[bbs_path] ; get disk
sub dl,'A'
mov ax,0e00h ; select disk
int 21h
mov di,word ptr[path_ptr] ; point to backslash
mov byte ptr[di],0 ; null terminate path
mov dx,OFFSET bbs_path
add dx,2 ; point to backslash for full path
mov ax,3b00h ; chdir
int 21h
mov di,word ptr[path_ptr]
mov byte ptr[di],'\' ; add back backslash
;
; Actually run the BBS
;
mov dx,OFFSET bbs_path
mov bx,OFFSET parm_block
mov ax,4b00h
int 21h ; run the BBS
push cs ; reset args after spawn call
push cs
pop ds
pop es
cmp byte ptr [flag],0 ; see if we're done
je terminate ; yep, exit
;
; Now run the secondary program, and then re-run the BBS
;
mov dx,OFFSET prog_name ; get program name offset
mov bx,OFFSET parm_block ; get offset of parm block
mov ax,4b00h ; fun 4b00 is exec
int 21h ; run the secondary program
mov di,80h
mov byte ptr cs:[di],0 ; clear the arguments
jmp exec_bbs ; rerun the BBS
;
; Convert bx to a hex ASCII string, store in di and increment di to end
;
hex_cnv:
mov dx,4 ; number of hex digits
mov cl,4 ; number of bits in hex digit
loop_cnv:
mov al,bh ; get the high order byte
shr al,cl ; get high nybble in low nybble of al
cmp al,0ah
jl hex_num ; in the range 0..9
sub al,0ah ; in range A..F
add al,'A'
jmp hex_pt
hex_num:
add al,'0'
hex_pt:
mov byte ptr[di],al ; store the char
inc di ; point to next location
shl bx,cl ; rip off nybble we converted
dec dx ; one less to go
jnz loop_cnv ; done?
ret
terminate:
mov ah,4dh
int 21h ; get return code
mov ah,4ch ; terminate
int 21h
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
parm_block dw 0 ; environment
dw 80h ; CMD line offset
dw 0 ; CMD line seg, set to CS
dd 0 ; who cares about the FCB's?
dd 0
stack_bottom db 128 dup (0)
stack_top:
END start