home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Hall of Fame
/
HallofFameCDROM.cdr
/
lant
/
transf.arc
/
EXPORT.ASM
next >
Wrap
Assembly Source File
|
1991-04-12
|
5KB
|
207 lines
TITLE - EXPORT transmits files via NETBIOS to IMPORT
ASSUME CS:MAIN_CODE, DS:MAIN_DATA
;
; Typical usage:
;
; EXPORT NETNAME <FILENAME
;
; Sends standard input across network from name EXPORT_NETNAME<10>
; to name IMPORT_NETNAME<10>.
;
; Network traffic is overlapped with Disk I/O to demonstrate the
; use of the No-Wait function of NETBIOS without needing an interrupt
; handler (POST=0). This program takes best advantage of
; intelligent adapters with network coprocessors.
;
; Author: Jack Schoof, President, ARTISOFT, Inc.
;
; (C) 1988 ARTISOFT, Inc. Tucson, AZ
; This program may be distributed free without modification
;
;
; NCB DEFINITION
;
NCBDEF STRUC
NCB_COMMAND DB 0
NCB_RETCODE DB 0
NCB_LSN DB 0
NCB_NUM DB 0
NCB_BUFFER DD 0 ;POINTER TO MESSAGE BUFFER
NCB_LENGTH DW 0 ;NUMBER OF BYTES IN BUFFER
NCB_CALLNAME DB 16 DUP (0)
NCB_NAME DB 16 DUP (0)
NCB_RTO DB 0
NCB_STO DB 0
NCB_POST DD 0 ;POINTER TO POST ADDRESS
NCB_LANA_NUM DB 0
NCB_CMD_CPLT DB 0
NCB_RESERVED DB 14 DUP (0) ;RESERVED
NCBDEF ENDS
;
; NCB COMMANDS
;
NO_WAIT EQU 80H
NCB_ADD_NAME EQU 30H
NCB_CALL EQU 10H
NW_DELETE_NAME EQU 31H+NO_WAIT
NW_HANG_UP EQU 12H+NO_WAIT
NW_SEND EQU 14H+NO_WAIT
MAIN_DATA SEGMENT PUBLIC 'DATA'
CNCB NCBDEF <>
ORG CNCB.NCB_NAME
DB 'EXPORT_' ;OUR NAME IS EXPORT_NETNAME
ORG CNCB.NCB_NAME+15
DB 10 ;10 TO NOT CONFLICT WITH NETWORK OPERATING
ORG CNCB.NCB_CALLNAME ;SYSTEMS LIKE IBM PC LAN OR LANTASTIC NOS
DB 'IMPORT_' ;RECEIVER'S NAME IS IMPORT_NETNAME
ORG CNCB.NCB_CALLNAME+15
DB 10 ;A 10 ON THE END TOO
ORG CNCB+SIZE NCBDEF
FLENGTH DW 0 ;KEEPS THE LENGTH OF THE RECEIVED PACKET
BUFFER_ONE DB 4000H DUP (?) ;DISK BLOCK BUFFERS
BUFFER_TWO DB 4000H DUP (?) ;16K EACH
MAIN_DATA ENDS
MAIN_CODE SEGMENT PUBLIC 'CODE'
BEGIN: PUSH ES
POP DS ;PUT PSP SEGMENT IN DS
MOV AX,SEG MAIN_DATA
MOV ES,AX ;OUR DATA SEGMENT IN ES
MOV SI,5DH ;GET THE NAME POINTER
MOV DI,OFFSET CNCB.NCB_NAME+7
MOV CX,8
REP MOVSB ;MAKE EXPORT_NETNAME<10>
MOV SI,5DH
MOV DI,OFFSET CNCB.NCB_CALLNAME+7
MOV CX,8
REP MOVSB ;MAKE IMPORT_NETNAME<10>
MOV DS,AX
MOV WORD PTR CNCB.NCB_BUFFER+2,AX ;SET UP THE BUFFER SEGMENT FOR LATER
MOV CNCB.NCB_COMMAND,NCB_ADD_NAME
CALL NETBIOS
JNZ BAD_EXIT ;ADD OUR NAME TO THE ADAPTER
CALLUM: MOV CNCB.NCB_COMMAND,NCB_CALL ;CALL THE IMPORTER
CALL NETBIOS
JNZ DELETE_NAME ;NO ONE HOME? QUIT
;
; HERE IS WHERE WE SEND THE FILE
;
MAIN_LOOP:
MOV DX,OFFSET BUFFER_ONE
CALL READ_BUFFER
JC HANG_UP ;PROBLEMS ON READ, HANG UP
CALL SEND_BUFFER ;SEND THE BUFFER WITH NO WAIT
JNZ HANG_UP ;PROBLEMS? THEN QUIT
CMP FLENGTH,0 ;ARE WE DONE?
JZ CLOSE_FILE ;YES
MOV DX,OFFSET BUFFER_TWO
CALL READ_BUFFER ;GET THE NEXT ONE OFF THE DISK
CALL WAIT_MYSELF ;WAIT FOR THE PREVIOUS NCB
JNZ HANG_UP
CALL SEND_BUFFER
JNZ HANG_UP ;PROBLEMS?
CALL WAIT_MYSELF ;NOW WAIT FOR THE NCB
JNZ HANG_UP
CMP FLENGTH,0 ;ARE WE DONE?
JZ CLOSE_FILE ;YES
JMP MAIN_LOOP ;CONTINUE
CLOSE_FILE:
MOV AH,3EH
XOR BX,BX
INT 21H ;CLOSE THE INPUT FILE
HANG_UP:
MOV CNCB.NCB_COMMAND,NW_HANG_UP
CALL NETBIOS ;HANG UP NOW
JNZ DELETE_NAME
CALL WAIT_MYSELF
JNZ DELETE_NAME
DELETE_NAME:
MOV CNCB.NCB_COMMAND,NW_DELETE_NAME
CALL NETBIOS ;GET RID OF OUR NAME
JNZ BAD_EXIT
CALL WAIT_MYSELF
JNZ BAD_EXIT
MOV AX,4C00H ;NO ERROR RETURN CODE
INT 21H ;AND EXIT
BAD_EXIT:
MOV AX,4C01H ;SET AN ERROR RETURN CODE
INT 21H ;AND EXIT
WAIT_MYSELF:
MOV AL,CNCB.NCB_CMD_CPLT ;WAIT FOR THE COMMAND
CMP AL,0FFH ;TO HAVE DONE SOMETHING
JZ TEST_CHAR ;WAIT FOR A CHARACTER
XOR AL,AL
RET ;Z FLAG IS ON
TEST_CHAR:
MOV AH,1
INT 16H ;IS A CHARACTER AVAILABLE?
JZ WAIT_MYSELF
XOR AH,AH
INT 16H
OR AL,0FFH ;NZ FLAG IS ON
RET
READ_BUFFER PROC
MOV AH,3FH
XOR BX,BX
MOV CX,SIZE BUFFER_ONE
INT 21H ;READ IN THE BUFFER POINTED TO BY DX
MOV FLENGTH,AX ;SAVE THE ACTUAL LENGTH
RET
READ_BUFFER ENDP
SEND_BUFFER PROC
MOV WORD PTR CNCB.NCB_BUFFER,DX ;WHAT TO SEND
MOV AX,FLENGTH
MOV CNCB.NCB_LENGTH,AX ;LENGTH TO SEND
MOV CNCB.NCB_COMMAND,NW_SEND
NETBIOS PROC
MOV BX,OFFSET CNCB ;ES:BX POINTS TO NCB
INT 5CH ;CALL THE ADAPTER
TEST AL,AL ;CHECK FOR PROBLEMS
RET ;AND RETURN WITH FLAGS SET
NETBIOS ENDP
SEND_BUFFER ENDP
MAIN_CODE ENDS
MAIN_STACK SEGMENT STACK
DW 100H DUP (?) ;DEFAULT STACK
MAIN_STACK ENDS
END BEGIN