home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
lan
/
netclk
/
netclock.asm
next >
Wrap
Assembly Source File
|
1989-01-28
|
5KB
|
191 lines
title NETCLOCK
page 58,132
;.RM100/
;NETCLOCK obtains the date and time by calling SRVCLOCK.
;
;
; Alan Queen (208) 384-9137
; Boise, ID 83712
; Last update: 03/18/88
CR EQU 0DH ;carriage return
LF EQU 0AH ;line feed
MAX_RETRY EQU 3 ;max times to retry call, increase
;this if experiencing "CALL" command
;failed errors
CODE SEGMENT PARA PUBLIC 'CODE'
ASSUME CS:CODE,DS:CODE,ES:CODE
ORG 100H
START: JMP BEGIN
;
;message data
STAT_ERR DB CR,LF,'"GET NAME" COMMAND FAILED',CR,LF,'$'
CAL_ERR DB CR,LF,'"CALL" COMMAND FAILED',CR,LF,'$'
RCV_ERR DB CR,LF,'"RECEIVE" COMMAND FAILED',CR,LF,'$'
NETBIOS_ERR DB CR,LF,'NETBIOS INTERFACE NOT PRESENT',CR,LF,'$'
SUCCESS DB CR,LF,'User Clock Synchronized to Server Clock',CR,LF,'$'
SERVER_NAME DB 'SRV_CLOCK '
ERR_COUNT DB 0 ;Call counter
;
;clock data area
CLOCK EQU $
YEAR DW 0000H
MONTH DB 00H
DAY DB 00H
HOURS DB 00H
MINUTES DB 00H
SECONDS DB 00H
HUNDREDTHS DB 00H
;
;a netbios message control block data
MCB EQU $ ;
COMMAND DB 00H ;Netbios command
RETCODE DB 00H ;the return code
LSN DB 00H ;the local session number
NUM DB 00H ;number of application name
BUFFER@ DW 0000H ;pointer to message buffer
DW 0000H ;segment:offset
BUF_LENGTH DW 0000H ;length of the buffer
CALLNAME DB '* ' ;name to call
OUR_NAME DB 16 dup(0) ;place for our name
RTO DB 10H ;receive time out
STO DB 10H ;send time out
POST@ DW 0000H ;post address for
DW 0000H ;no wait commands
ADAPTER_NUM DB 00H ;the adapter 0 or 1
CMD_STAT DB 00H ;command status
RESERVE DB 14 DUP(0) ;
;
;buffer for adapter status request
;(Minimum allowable adapter status buffer=60, this program uses only first 6)
RET@ EQU $
ID_NUM DB 6 dup(0)
FILLER DB 54 dup(0)
;
; Check if interrupt 5C has a vector
;
BEGIN:
PUSH ES ;save ES
MOV AH,35H ;get interrupt 5C vector
MOV AL,5CH
INT 21H
MOV AX,ES
POP ES ;get back ES
CMP AX,0 ;is segment 0
JNE ADAPTER_STAT ;not 0 an interface is present
LEA DX,NETBIOS_ERR ;else error message
JMP ERROR1 ;
;
;do netbios adapter status to obtain machine name (wait for completion)
;NOTE: This may be a problem for some netbios clones. If so replace this
;section with an add name routine that adds a unique name
;
ADAPTER_STAT: MOV COMMAND,33H ;Command 33=adapter status
MOV BUFFER@+2,DS ;high word buffer=data segment
MOV AX,OFFSET RET@ ;move offset of
MOV BUFFER@,AX ;return area into NCB buffer
MOV BUF_LENGTH,60 ;minimum possible space=60
MOV BX,OFFSET MCB ;point BX to MCB
INT 5CH ;call to netbios
CMP RETCODE,06H ;return code should be an
;error of buffer to small(06)
JE GET_NAME ;get machine name returned
CMP RETCODE,0 ;if only netbios loaded
JE GET_NAME ;return will be a 0
CMP AL,0FBH ;netbios not loaded?
JNE ADP1 ;if not FB then something else
MOV DX,OFFSET NETBIOS_ERR ;netbios error message
JMP ERROR ;
ADP1:
MOV DX,OFFSET STAT_ERR ;else status error message
JMP ERROR ;
GET_NAME:
MOV SI,OFFSET RET@ ;move machine name to position
MOV DI,OFFSET OUR_NAME+10 ;after 10 bytes of 00h
MOV CX,6 ;6 bytes = machine name
REPNZ MOVSB ;
;
;change callname to SRV_CLOCK
; ;
MOV SI,OFFSET SERVER_NAME ;Move server name
MOV DI,OFFSET CALLNAME ;into MCB
MOV CX,16 ;use all 16 bytes
REPNZ MOVSB ;
;
;do netbios call (wait for completion)
;
NETCALL: MOV COMMAND,10H ;Move call command code to MCB
MOV BX,OFFSET MCB ;point BX at MCB
INT 5CH ;call netbios
CMP AL,00H ;check completion code
JE GET_TIME ;if ok, receive server time
INC ERR_COUNT ;else increment call counter
CMP ERR_COUNT,MAX_RETRY ;have we tried to the max? If not
JL NETCALL ;try again, SRVCLOCK may be busy
MOV DX,OFFSET CAL_ERR ;if too many write error message
JMP ERROR ;
;
;receive time from server
;
GET_TIME: MOV COMMAND,15H ;Move receive command to MCB
MOV BUFFER@,OFFSET CLOCK ;point buffer to clock area
MOV BUFFER@+2,DS ;initialize segment
MOV BUF_LENGTH,08 ;clock needs 8 bytes
INT 5CH ;call netbios
CMP AL,00H ;check for errors
JE HANGUP ;if none close the session
;time and date now in CLOCK
;area
MOV DX,OFFSET RCV_ERR ;else receive error
JMP ERROR ;
;
;hangup session
;
HANGUP: MOV COMMAND,12H ;Move hang-up command to MCB
INT 5CH ;Netbios call
;
MOV AH,09H ;display success
MOV DX,OFFSET SUCCESS ;message to user
INT 21H ;
;
;install the date and time
; ;
MOV CX,YEAR ;Prepare to set
MOV DH,MONTH ;the date
MOV DL,DAY ;using function call
MOV AH,2BH ;2BH
INT 21H ;
;
MOV CH,HOURS ;and set the date
MOV CL,MINUTES ;using data in
MOV DH,SECONDS ;clock area
MOV DL,HUNDREDTHS ;using function
MOV AH,2DH ;call 2DH
INT 21H ;
MOV AX,4C00H ;exit code no error
JMP QUIT
;
;error message and closing
;
ERROR: MOV COMMAND,12H ;hang-up session if any
INT 5CH ;
ERROR1: MOV AH,09H ;write error message to screen
INT 21H ;
MOV AX,4C01H ;exit with error 1
QUIT: INT 21H
CODE ENDS
END START