home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / lan / net_time / netclock.asm next >
Assembly Source File  |  1988-01-21  |  7KB  |  172 lines

  1. ;
  2. ; netclock.asm  -  From PC Magazine . August '87, pp468-470
  3. ;
  4. ;    NETCLOCK runs on the IBM PCLAN and PCNP programs and obtains the time and
  5. ; date from a network server running SRVCLOCK.exe or SRVCLOKF.EXE.  NETCLOCK
  6. ; must be executed in a workstation after the "NET START" command.
  7. ;
  8. cr            equ    0dh
  9. lf            equ    0ah
  10.  
  11. cseg  segment para   public   'code'
  12. net           proc   far
  13.               assume cs:cseg,ds:netdata,ss:stack,es:netdata
  14.               push   ds
  15.               xor    ax,ax
  16.               push   ax
  17.               mov    ax,netdata
  18.               mov    ds,ax
  19.               mov    es,ax
  20.               mov    cx,00h
  21. ;
  22. ; netbios adapter status - get machine name (wait for completion)
  23. ;
  24. adapter_stat: mov    command,33h             ; Command 33=adapter status
  25.               mov    buffer@+2,ds            ; high word buffer=data segment
  26.               mov    ax,offset ret@          ; move offset of
  27.               mov    buffer@,ax              ; return area into NCB buffer
  28.               mov    buf_length,60           ; minimum possible space=60
  29.               mov    bx,offset mcb           ; point BX to MCB
  30.               int    5ch                     ; call to NETBIOS
  31.               cmp    retcode,06h             ; return code should be an
  32.                                              ; error of buffer to small (06)
  33.               je     get_name                ; get machine name returned
  34.               mov    dx,offset stat_err      ; else status error message
  35.               jmp    error                   ;
  36. get_name:     mov    si,offset ret@          ; move machine name to position
  37.               mov    di,offset our_name+10   ; after 10 bytes of 00h
  38.               mov    cx,6                    ; 6 byes = machine name
  39.      repnz    movsb                          ;
  40. ;
  41. ; change call name to srv_clock
  42. ;                                            ;
  43.               mov    si,offset server_name   ; Move server name
  44.               mov    di,offset callname      ; into MCB
  45.               mov    cx,16                   ; use all 16 bytes
  46.      repnz    movsb                          ;
  47. ;
  48. ; do netbios call (wait for completion)
  49. ;
  50. call:         mov    command,10h             ; Move call command code to MCB
  51.               mov    bx,offset mcb           ; point BX at MCB
  52.               int    5ch                     ; call NETBIOS
  53.               cmp    al,00h                  ; check completion code
  54.               je     get_time                ; if ok, receive server time
  55.               mov    dx,offset cal_err       ; else write error message
  56.               jmp    error                   ;
  57. ;
  58. ; receive time from server
  59. ;
  60. get_time:     mov    command,15h             ; Move receive command to MCB
  61.               mov    buffer@,offset clock    ; point buffer to clock area
  62.               mov    buffer@+2,ds            ; initialize segment
  63.               mov    buf_length,08           ; clock needs 8 bytes
  64.               int    5ch                     ; call NETBIOS
  65.               cmp    al,00h                  ; check for errors
  66.               je     hangup                  ; if none close the session
  67.                                              ; time and date now in CLOCK
  68.                                              ; area
  69.               mov    dx,offset rcv_err       ; else receive error
  70.               jmp    error                   ;
  71. ;
  72. ; hangup session
  73. ;
  74. hangup:       mov    command,12h             ; Move hang-up command to MCB
  75.               int    5ch                     ; NETBIOS call
  76.                                              ;
  77.               mov    ah,09h                  ; display success
  78.               mov    dx,offset success       ; message to user
  79.               int    21h                     ;
  80. ;
  81. ; install date and time
  82. ;
  83.               mov    cx,year                 ; prepare to set
  84.               mov    dh,month                ; the date
  85.               mov    dl,day                  ; using DOS function call
  86.               mov    ah,2bh                  ; 2bH
  87.               int    21h                     ;
  88.                                              ;
  89.               mov    ch,hours                ; and set the date
  90.               mov    cl,minutes              ; using data in
  91.               mov    dh,seconds              ; clock area
  92.               mov    dl,hundredths           ; using DOS function
  93.               mov    ah,2dh                  ; call 2dH
  94.               int    21h                     ;
  95.               jmp    quit                    ;
  96. ;
  97. ; error message and closing
  98. ;
  99. error:        mov    ah,09h                  ; write error message to screen
  100.               int    21h                     ;
  101.               mov    command,12h             ; hang-up session if any
  102.               int    5ch                     ;
  103. quit:         ret
  104. net           endp
  105.  
  106. cseg          ends
  107. ;
  108. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  109. ;
  110. ;                           message data
  111. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  112. netdata segment para public 'data'
  113.  
  114. stat_err      db     cr,lf,'"get name" command failed',cr,lf,'$'
  115. cal_err       db     cr,lf,'"call" command failed',cr,lf,'$'
  116. rcv_err       db     cr,lf,'"receive" command failed',cr,lf,'$'
  117. success       db     cr,lf,'network clock installed',cr,lf,'$'
  118. server_name   db     'srv_clock       '
  119. ;
  120. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  121. ;
  122. ;                       clock data area
  123. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  124. clock         equ    $
  125. year          dw     0000h
  126. month         db     00h
  127. day           db     00h
  128. hours         db     00h
  129. minutes       db     00h
  130. seconds       db     00h
  131. hundredths    db     00h
  132. ;
  133. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  134. ;
  135. ;                 message control block data
  136. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  137. mcb           equ    $
  138. command       db     00h
  139. retcode       db     00h
  140. lsn           db     00h
  141. num           db     00h
  142. buffer@       dw     0000h
  143.               dw     0000h
  144. buf_length    dw     0000h
  145. callname      db     '*               '
  146. our_name      db     16 dup(0)
  147. rto           db     00h
  148. sto           db     00h
  149. post@         dw     0000h
  150.               dw     0000h
  151. adapter_num   db     00h
  152. cmd_stat      db     00h
  153. reserve       db     14 dup(0)
  154. ;
  155. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  156. ;
  157. ;                 buffer for adapter status request
  158. ;
  159. ; (Minimum allowable adapter status buffer=60,
  160. ;  this program uses only first 6)
  161. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  162. ret@          equ    $
  163. id_num        db     6 dup(0)
  164. filler        db     54 dup(0)
  165. netdata       ends
  166.  
  167. stack         segment para stack 'stack'
  168.               db      32 dup('stack   ')
  169. stack         ends
  170.               end
  171.  
  172.