home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / ASSEMBLE / 80X0992 / NET_SN.ASM < prev    next >
Assembly Source File  |  1992-07-30  |  3KB  |  98 lines

  1. %PAGESIZE 55,200
  2. %TITLE "NetWare serial number routine"
  3. ; Net_SN.Asm
  4. ;
  5. ; written on Mon  06-01-1992 by Ed Beroset
  6. ; released to the public domain
  7. ;
  8.  
  9.   .MODEL SMALL
  10.   IDEAL
  11.  
  12.  STACK 100h
  13.  DATASEG
  14.  
  15. STDOUT    = 1   ; handle for stdout
  16.  
  17.     STRUC SNREQBUFF
  18.     Length      DW  1       ; request structure length - 2
  19.     Function    DB  12h     ; function number of GetNetworkSerialNumber
  20.     ENDS SNREQBUFF
  21.  
  22.     STRUC SNREPLYBUFF
  23.     Length      DW  6       ; reply structure length - 2
  24.     NetSN       DD  0       ; network serial number in big endian packed BCD
  25.     AppNumber   DW  0       ; Application number in same format
  26.     ENDS SNREPLYBUFF
  27.  
  28.     U_Request SNREQBUFF    <>
  29.     U_Reply   SNREPLYBUFF  <>
  30.     SerialNum  DB  "00000000",0dh, 0ah
  31.     SerialLen  = $ - SerialNum
  32.  
  33.  CODESEG
  34. ;
  35. ; Test code gets network serial number and prints it to stdout
  36. ;
  37. Start:
  38.   mov  ax,@data
  39.   mov  ds,ax                ; set up the data segment
  40.   call NetworkSN
  41. Exit:
  42.   mov  ah,04ch              ; return with error code preset in AL
  43.   int  21h
  44.  
  45. ;
  46. ; here's the Network stuff
  47. ;
  48. PROC    NetworkSN
  49.     push    ds
  50.     push    si
  51.     push    di
  52.     push    es
  53.     push    dx
  54.     push    cx
  55.  
  56.     lea     si,[U_Request]      ; prepare to request data
  57.     lea     di,[U_Reply  ]      ; prepare to receive data
  58.     mov     ax,ds
  59.     mov     es,ax
  60.     mov     ah,0e3h             ; Get File Server Serial Number
  61.     int     21h
  62.     jc      @@NoMore
  63.  
  64.     lea     si,[U_Reply.NetSN]  ; point ds:si at binary data
  65.     lea     di,[SerialNum]      ; and point es:di at target ASCII string
  66.     mov     cx,4                ; loop four times (once for each SN digit pair)
  67.     cld                         ; count up
  68.  
  69. @@convbyte:
  70.     lodsb                       ; read a byte
  71.     aam     16                  ; convert to two-digit BCD in ah,al
  72.     xchg    ah,al               ; swap so that memory image will be correct
  73.     or      ax,3030h            ; convert both to ASCII numbers
  74.     stosw                       ; put 'em in our table
  75.     loop    @@convbyte
  76.  
  77.     lea     dx,[SerialNum]      ; we're going to point ds:dx to string
  78.     mov     cx,SerialLen        ; load the length of the string
  79.     mov     bx,STDOUT           ; print to STDOUT
  80.     mov     ah,40h              ; DOS function to print string
  81.     int     21h                 ; do it
  82.     mov     al,0                ; return with appropriate error code
  83.  
  84. @@NoMore:
  85.     pop     cx
  86.     pop     dx
  87.     pop     es
  88.     pop     di
  89.     pop     si
  90.     pop     ds
  91.     ret
  92.  
  93. ENDP        NetworkSN   ;end of proc
  94.  
  95.   END Start
  96.  
  97. ; EOF NET_SN.ASM
  98.