home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / pcmagazi / 1989 / 22 / netnum.asm < prev    next >
Assembly Source File  |  1989-01-26  |  5KB  |  270 lines

  1. Title    Program to display network node number (NETNUM.com)
  2.  
  3. comment @
  4.     This will send a message to the standard output device
  5.         indicating the physical and logical node
  6.         numbers of a computer on a Novell-compatible
  7.         network
  8.  
  9.      Novell ELS networks return a physical address of 2,
  10.         regardless of the card settings @
  11.  
  12. doscall macro    the_fcn
  13.     mov    ah, the_fcn
  14.     int    21h
  15.     endm
  16.  
  17. std_exit    equ    0
  18. print_str    equ    9
  19. exit_with_code    equ    4ch
  20.  
  21. cr    equ    13
  22. lf    equ    10
  23. dos_prt_term    equ    '$'
  24.  
  25. ;    Network Functions
  26. net_log_num    equ    0dch
  27. net_phys_num    equ    0eeh
  28.  
  29.  
  30. cseg    segment 'code'
  31.     org    100h
  32.     assume    cs:cseg, ds:cseg
  33.  
  34. netnum    proc    near
  35. begin:    jmp    skip_dat
  36.  
  37. ;..........................................
  38. ;    Error message stuff
  39. err_code    dw    no_err
  40. no_err    equ    0
  41. not_on_net    equ    no_err + 1
  42.  
  43. no_err_msg    db    'This message should NOT ever be displayed.'
  44.     db    cr, lf, dos_prt_term
  45.  
  46. no_net_msg    db    'This computer is not on a '
  47.     db    'Novell-compatible network.'
  48.     db    cr, lf, dos_prt_term
  49.  
  50. err_msg_addr    dw    offset no_err_msg
  51.     dw    offset no_net_msg
  52. ;..........................................
  53.  
  54. exit_code    db    0    ;ERRORLEVEL on exit, 0 if error, lower
  55.             ; byte of physical address if no error
  56.  
  57. out_msg db    'The logical network address is: '
  58. log_num db    2 dup (?)
  59.     db    cr, lf
  60.     db    'The physical network address is: '
  61. phys_num    db    12 dup (?)
  62.     db    'h', cr, lf, dos_prt_term
  63.  
  64. skip_dat:
  65.     call    get_log_num
  66.     cmp    err_code, no_err
  67.     je    no_err1
  68.     call    disp_err_msg
  69.     jmp    exit
  70.  
  71. no_err1:
  72.     call    get_phys_num
  73.     call    print_msg
  74.  
  75. exit:
  76.     mov    al, exit_code
  77.     doscall exit_with_code
  78. netnum    endp
  79.  
  80. comment @
  81.     Procedure to get logical network node number
  82.     On Entry:
  83.         Nothing
  84.     On Exit:
  85.         DS:ERR_CODE will be changed if it appears that
  86.             the computer is not on a network
  87.             (node number = 255)
  88.         Number will be placed in DS:LOG_NUM
  89. @
  90. get_log_num    proc    near
  91.     push    cx
  92.     push    ax
  93.  
  94.     mov    cx, 'ff'        ;Will allow error check
  95.     doscall net_log_num
  96.     cmp    cx, 'ff'
  97.     jne    gln_ok
  98.  
  99. ;    Looks like this is not on a network.  Signal that and return
  100.     mov    err_code, not_on_net
  101.     jmp    gln_exit
  102.  
  103. gln_ok:
  104.     mov    log_num, cl
  105.     mov    log_num + 1, ch
  106.  
  107. gln_exit:
  108.     pop    ax
  109.     pop    cx
  110.     ret
  111. get_log_num    endp
  112.  
  113.  
  114. ;-------------------------------------------------
  115. comment @
  116.     Procedure to get physical network node number
  117.     On Entry:
  118.         Nothing
  119.     On Exit:
  120.         Number (12 hex digits) will be placed in DS:PHYS_NUM
  121.             and lower 8 bits will be placed in
  122.             EXIT_CODE
  123. @
  124. get_phys_num    proc    near
  125.     push    ax
  126.     push    bx
  127.     push    cx
  128.  
  129. ;    Zero registers first
  130.     mov    ax, 0
  131.     mov    bx, ax
  132.     mov    cx, ax
  133.  
  134.     doscall net_phys_num
  135.     mov    exit_code, al    ;Save for ERRORLEVEL
  136.     push    ax
  137.  
  138.     mov    ax, cx
  139.     mov    si, offset phys_num
  140.     call    word_to_chars
  141.  
  142.     mov    ax, bx
  143.     add    si, 4
  144.     call    word_to_chars
  145.  
  146.     pop    ax
  147.     add    si, 4
  148.     call    word_to_chars
  149.  
  150.     pop    cx
  151.     pop    bx
  152.     pop    ax
  153.     ret
  154. get_phys_num    endp
  155.  
  156.  
  157. ;----------------------------------------------
  158. comment @
  159.     Procedure to print the output message
  160.     On Entry:
  161.         Nothing
  162.     On Exit:
  163.         The message at DS:OUT_MSG will be sent to
  164.             the standard output device
  165. @
  166. print_msg    proc    near
  167.     mov    dx, offset out_msg
  168.     doscall print_str
  169.     ret
  170. print_msg    endp
  171.  
  172. ;--------------------------------------------------
  173. comment @
  174.     Procedure to print error message
  175.     On Entry:
  176.         DS:ERR_CODE holds the # of the error message
  177.         DS:ERR_MSG_ADDR[ERR_CODE * 2] holds the address
  178.              of the message
  179.  
  180.     On Exit:
  181.         The message will be sent to standard output
  182. @
  183. disp_err_msg    proc    near
  184.     push    bx
  185.     push    dx
  186.  
  187.     mov    bx, err_code
  188.     shl    bx, 1        ;Point to word offset in table
  189.     mov    dx, err_msg_addr[bx]    ;Get offset of message
  190.     doscall print_str        ;Display it
  191.  
  192.     pop    dx
  193.     pop    bx
  194.  
  195.     ret
  196. disp_err_msg    endp
  197. ;...................................................
  198. comment @
  199.     Procedure to convert AX to a string of 4 hex characters
  200.         in [SI]
  201. @
  202.  
  203. word_to_chars    proc    near
  204.  
  205.     push    bx        ;Save used registers
  206.     push    si
  207.  
  208. ;    Do higher byte first
  209.     mov    bx, ax        ;Save the word
  210.     mov    al, ah
  211.     call    byte_to_chars
  212.  
  213. ;    Do lower byte
  214.     mov    al, bl    ;Retrieve lower byte
  215.     inc    si    ;Point at correct chars
  216.     inc    si
  217.     call    byte_to_chars
  218.  
  219.     pop    si    ;Restore used registers
  220.     pop    bx
  221.     ret
  222. word_to_chars    endp
  223.  
  224. comment @
  225.     Procedure to convert AL to a string of 2 hex characters
  226.         in [SI]
  227. @
  228.  
  229. byte_to_chars    proc    near
  230.  
  231.     push    bx        ;Save used registers
  232.     push    cx
  233.  
  234. ;    Do higher nibble first
  235.     mov    bl, al        ;Save the word
  236.     mov    cl, 4
  237.     shr    al, cl        ;Move high nibble to low nibble
  238.     call    nbl_2_char        ;Do the conversion
  239.     mov    [si], al        ;Save the result to be printed
  240.  
  241. ;    Lower nibble
  242.     mov    al, bl
  243.     call    nbl_2_char
  244.     mov    [si + 1], al
  245.  
  246.     pop    cx    ;Restore used registers
  247.     pop    bx
  248.     ret
  249. byte_to_chars    endp
  250.  
  251. ;    Procedure to convert nibble to character
  252. ;    On Entry:
  253. ;        AL (lower 4 bits) is nibble to convert
  254. ;    On Exit:
  255. ;        AL contains character ("0" to "F")
  256.  
  257. xlat_str    db    '0123456789ABCDEF'
  258.  
  259. nbl_2_char    proc    near
  260.     push    bx
  261.     and    al, 0fh ;Zero out upper nibble
  262.     mov    bx, offset xlat_str
  263.     xlat
  264.     pop    bx
  265.     ret
  266. nbl_2_char    endp
  267.  
  268. cseg    ends
  269.     end    begin
  270.