home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / network / pcb121.zip / BRIDGE.ASM < prev    next >
Assembly Source File  |  1992-01-23  |  5KB  |  183 lines

  1. ;;****************************************************************************
  2. ;;                      bridge.asm          bridge.asm
  3. ;;****************************************************************************
  4. ;;
  5. ;;  Copyright (C) 1989 Northwestern University, Vance Morrison
  6. ;;
  7. ;;
  8. ;; Permission to view, compile, and modify for LOCAL (intra-organization) 
  9. ;; USE ONLY is hereby granted, provided that this copyright and permission 
  10. ;; notice appear on all copies.  Any other use by permission only.
  11. ;;
  12. ;; Northwestern University makes no representations about the suitability 
  13. ;; of this software for any purpose.  It is provided "as is" without expressed 
  14. ;; or implied warranty.  See the copywrite notice file for complete details.
  15. ;;
  16. ;;*************************************************************************
  17. ;;
  18. ;; bridge.asm implemtents a simple two interface ethernet bridge
  19. ;;
  20. ;; AUTHOR: Vance Morrison
  21. ;; DATE:   5/24/89
  22. ;; ADDRESS: morrison@accuvax.nwu.edu
  23. ;;****************************************************************************
  24.  
  25.     dosseg
  26.     .model small
  27.     .stack 500h  
  28.     JUMPS                       ;; deal with long displacement
  29.                                 ;; jumps automaticly
  30.  
  31. ;; small helper macro
  32. MY_SET_MTU MACRO name, mtu
  33.     if_&name&_mtu = mtu
  34. ENDM
  35.  
  36.     include declare.inc
  37.  
  38.        .data
  39.     db  'Copywrite (c) 1989, Vance Morrison, Northwestern University', 13,10, 0
  40.     db  'VERSION 1.21 ', 0
  41.  
  42.         ; a place to put the command line
  43. comline_count db 0 
  44. comline       db 127 dup (0)        
  45.  
  46. baud_rate_div dw 0                      ;; used for remote bridging
  47.  
  48.  
  49. ;;************************************************************************
  50. ;; This routine converts the ASCII base ten number pointed to by SI and
  51. ;; returns the number in AX.  It also updates SI to point to the next
  52. ;; char in the string.  This routine skips preceeding space and stops
  53. ;; conversion at the first non-digit.  Clearly this routine can' handle
  54. ;; numbers up to 64K
  55.  
  56. ASCII_TO_BINARY_in_SI_out_AX_SI_const_BP_DI_ES MACRO
  57.     local top_loop, next_char, conv_string, space_loop, done
  58.  
  59.     space_loop:
  60.         mov CL, [SI]
  61.         cmp CL, ' '         ; skip space
  62.         jnz conv_string
  63.         inc SI
  64.         jmp space_loop
  65.     conv_string:
  66.  
  67.     xor AX, AX
  68.     xor CH, CH
  69.     top_loop:
  70.         sub CL, '0'         ; is it a digit
  71.         jl done
  72.         cmp CL, 9
  73.         jg done
  74.  
  75.         mov DX, AX          ; AX = AX * 10
  76.         shl AX, 1
  77.         shl AX, 1
  78.         add AX, DX
  79.         shl AX, 1
  80.         
  81.         add AX, CX
  82.     next_char:
  83.         inc SI
  84.     mov CL, [SI]
  85.     jmp top_loop
  86.  
  87.     done:
  88. ENDM
  89.  
  90.  
  91. ;;************************************************************************
  92.     .code
  93.  
  94.     ;; insert code for all interfaces
  95.     IRP idx,<1,2,3,4,5,6,7,8>
  96.        WDE_REAL_DEFINE idx     
  97.        I8250_REAL_DEFINE idx
  98.        PKT_REAL_DEFINE idx     
  99.        C507_REAL_DEFINE idx     
  100.     endm
  101.  
  102.     DB_DEFINE           
  103.  
  104. bridge_start:
  105.     ;; save the command line
  106.     mov SI, 80h
  107.     mov AX, @DATA 
  108.     mov ES, AX
  109.     mov DI, offset comline_count
  110.     mov CX, 40h
  111.     rep
  112.     movsw
  113.  
  114.     mov AX, @DATA       ;; initialize data segment
  115.     mov DS, AX
  116.     cld                 ;; direction forward
  117.  
  118.         ; if this is a remote bridge
  119.     ifdef i8250_declared
  120.         mov SI, offset comline
  121.         ASCII_TO_BINARY_in_SI_out_AX_SI_const_BP_DI_ES      ;; get the baud rate
  122.         cmp AX, 0
  123.         jnz not_default
  124.             mov AX, 19200                   ;; 19.2 is the default
  125.         not_default:
  126.         shr AX, 1                           ;; compute the baud rate div
  127.         mov BX, AX
  128.         mov AX, 57600
  129.         xor DX, DX
  130.         div BX
  131.         mov baud_rate_div, AX
  132.     endif
  133.  
  134.     IRP idx,<1,2,3,4,5,6,7,8>       ;; call definition code
  135.     if idx le num_dls
  136.         WDE_DEFINE idx     
  137.  
  138.         BUFF_DEFINE %(idx*10+1)
  139.         QUEUE_DEFINE %(idx*10+2)
  140.         BUFF_DEFINE %(idx*10+3)
  141.         QUEUE_DEFINE %(idx*10+4)
  142.         Q_IF_DEFINE idx     
  143.         SLIP_DEFINE idx     
  144.         mov BX, baud_rate_div 
  145.         I8250_DEFINE_in_BX idx, serial_fail
  146.  
  147.         PKT_DEFINE idx, packet_fail
  148.  
  149.         C507_DEFINE_out_AX idx, card_fail
  150.     endif
  151.     endm
  152.  
  153.     BDG_DEFINE %mybridge
  154.  
  155.     ;; start looking for packets
  156.     big_loop:
  157.     IRP idx,<1,2,3,4,5,6,7,8>
  158.     local next
  159.     if idx le num_dls
  160.         BDG_IF_R_ACCESS_out_BX_CX_ES idx, next
  161.         BDG_IF_R_FREE_const_BX_CX_BP_SI_DI_ES idx    ;; throw it away
  162.         next:
  163.     endif
  164.     endm
  165.     jmp big_loop
  166.  
  167.     card_fail:
  168.         print_reg <error configuring ethernet card.  Code = >, AX
  169.         jmp terminate
  170.  
  171.     packet_fail:
  172.         print <error configuring packet driver>
  173.         jmp terminate
  174.  
  175.     serial_fail:
  176.         print <error configuring serial port>
  177.     terminate:
  178.         mov AH, 4CH
  179.         int 21H
  180. END bridge_start
  181.  
  182.  
  183.