Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. ;
  2. ;    PPP.ASM
  3. ;
  4. ;    Compile with FASM for Menuet
  5. ;    This program dials into an ISP and establishes a PPP connection
  6. ;
  7. ;    Version 11    26th January 2004
  8. ;
  9. ;    This code is a port of the PPP dialer program by Microchip, from
  10. ;    their application note AN724
  11. ;    It has been ported by Mike Hibbett mikeh@oceanfree.net for Menuet
  12. ;
  13. ;    26/1/04 - Mike Hibbett - added support for com port selected by
  14. ;                             stackcfg
  15. ;    2/5/03 - Shrirang - Added Abort Strings To sendwait to get out early
  16. ;                        if modem sends abort strings like NO CARRIER etc.
  17. ;
  18. ;    The original copyright statement follows
  19. ;//////////////////////////////////////////////////////////////////////////
  20. ;//
  21. ;//PING.C  version 1.10  July 29/99 (C)opyright by Microchip Technology Inc
  22. ;//
  23. ;//////////////////////////////////////////////////////////////////////////
  24.  
  25. FALSE               equ 0
  26. TRUE                equ 1
  27. DEBUG_OUTPUT        equ TRUE       ; If FALSE, not debugging info outputted
  28. DEBUG_PPP_OUTPUT    equ TRUE        ; write PPP status msgs to debug board?
  29. DEBUG_PORT2_OUTPUT  equ TRUE       ; write debug data also to com2
  30.  
  31.  
  32. BAUD_9600       equ         12
  33. BAUD_57600      equ         2
  34. ; The next line sets the baud rate of the connection to the modem
  35. BAUDRATE        equ         BAUD_57600
  36.  
  37.  
  38. LINE_END        equ         0x0D        ; End of input data character
  39.  
  40.  
  41. ; Defines for Internet constants
  42. REQ         equ      1   ; Request options list for PPP negotiations
  43. PPP_ACK     equ      2   ; Acknowledge options list for PPP negotiations
  44. PPP_NAK     equ      3   ; Not acknowledged options list for PPP neg
  45. REJ         equ      4   ; Reject options list for PPP negotiations
  46. TERM            equ  5   ; Termination packet for LCP to close connectio
  47. LCP_ECHO_REQ    equ  9
  48. LCP_ECHO_REP    equ  10
  49. IP        equ    0x0021   ; Internet Protocol packet
  50. IPCP      equ    0x8021   ; Internet Protocol Configure Protocol packet
  51. CCP       equ    0x80FD   ; Compression Configure Protocol packet
  52. LCP       equ    0xC021   ; Link Configure Protocol packet
  53. PAP       equ    0xC023   ; Password Authenication Protocol packet
  54.  
  55.  
  56. MaxRx           equ         1500
  57. MaxTx           equ         1500
  58.  
  59.  
  60.  
  61.  
  62. use32
  63.  
  64.      org     0x0
  65.  
  66.      db      'MENUET00'      ; 8 byte id
  67.      dd      38              ; required os
  68.      dd      STARTAPP        ; program start
  69.      dd      I_END           ; program image size
  70.      dd      0x100000        ; required amount of memory
  71.         ; esp = 0x7FFF0
  72.      dd      0x00000000      ; reserved=no extended header
  73.  
  74.  
  75. include "lang.inc"
  76. include "macros.inc"
  77. include "chat.inc"                  ; Hosts modem chatting routine
  78.  
  79.  
  80. STARTAPP:
  81. ;    mov     eax, 0x3f8
  82. ;    mov     [comport], eax
  83. ;    mov     eax, 4
  84. ;    mov     [comirq], eax
  85.  
  86.     ; Get the com port & IRQ to use from the kernel stack config option
  87.  
  88.     mov   eax, 52                 ; Stack Interface
  89.     mov   ebx, 0     ; read configuration word
  90.     int   0x40
  91.     mov  ecx, eax
  92.     shr  ecx, 16     ; get the port address
  93.     mov  [comport], ecx
  94.     shr  eax, 8
  95.     and  eax, 0x000000FF   ; get the irq
  96.  mov  [comirq], eax
  97.  
  98.  
  99.  mov  eax, [comport]
  100.  add  eax, 0x01000000
  101.  mov [irqtable], eax
  102.  
  103.  
  104.     call    enable_port
  105.  
  106. appdsp:
  107.     mov     eax, welcomep
  108.     mov     [prompt], eax               ; set up prompt to display
  109.     mov     al, [welcomep_len]
  110.     mov     [prompt_len], al
  111.  
  112.     call    draw_window                 ; at first, draw the window
  113.  
  114.  
  115. apploop:
  116.     mov     eax, 23                     ; wait here for event
  117.     mov     ebx, 20
  118.     int     0x40
  119.  
  120.     cmp     eax, 1                      ; redraw request ?
  121.     je      red
  122.     cmp     eax, 2                      ; key in buffer ?
  123.     je      key
  124.     cmp     eax, 3                      ; button in buffer ?
  125.     je      button
  126.     mov     ebx, [comirq]
  127.     add     ebx, 16
  128.     cmp     eax, ebx
  129.     je      flush_input                 ; Dont want serial data yet
  130.     jmp     apploop
  131.  
  132. red:                                    ; redraw
  133.     call    draw_window
  134.     jmp     apploop
  135.  
  136. key:                                    ; key - ignore
  137.     mov     eax, 2                      ; just read it
  138.     int     0x40
  139.     jmp     apploop
  140.  
  141. button:                                 ; button
  142.     mov     eax, 17                     ; get id
  143.     int     0x40
  144.  
  145.     cmp     ah, 1                       ; close program ?
  146.     jne     noclose
  147.  
  148.     mov     esi, hangupWait
  149.     mov     edi, hangupSend
  150.     mov     edx, 1000                   ; Allow sendwait 10s
  151.     call    sendwait
  152.  
  153.     call    disable_port
  154.  
  155.     mov     eax, -1                     ; close this program
  156.     int     0x40
  157.     jmp     apploop
  158.  
  159. noclose:
  160.     cmp     ah, 2                       ; Dial Button pressed?
  161.     jne     apploop
  162.  
  163.     mov     eax, conp
  164.     mov     [prompt], eax               ; set up prompt to display
  165.     mov     al,[conp_len]
  166.     mov     [prompt_len], al
  167.     call    draw_window
  168.  
  169.     jmp     dialloop                    ; connect to the host
  170.  
  171.  
  172.     ; Data received, so get it, and throw it away at this point
  173. flush_input:
  174.     mov  eax,42
  175.     mov  ebx, [comirq]
  176.     int  0x40
  177.  
  178.     mov  eax,11                     ; This will return 0 most of the time
  179.     int  0x40
  180.     mov     ebx, [comirq]
  181.     add     ebx, 16
  182.     cmp     eax, ebx
  183.    je   flush_input
  184.     jmp  apploop
  185.  
  186.  
  187. dialloop:
  188.     call    modem_chat                  ; Try chatting with the modem
  189.  
  190.     cmp     eax, 1                      ; Did it work? ( = 1)
  191.     jne     appdsp
  192.  
  193.     ; OK, we are now connected.
  194.  
  195.     mov     eax, pppOnp
  196.     mov     [prompt], eax               ; set up prompt to display
  197.     mov     al,[pppOnp_len]
  198.     mov     [prompt_len], al
  199.     call    draw_window
  200.  
  201.     mov     eax, 23
  202.     mov     ebx, 100
  203.     int     0x40                        ; wait for 1s to display message
  204.  
  205.     call    PPPStateMachine         ; This is the main code
  206.  
  207.     jmp     appdsp
  208.  
  209.  
  210.  
  211.  
  212. ;****************************************************************************
  213. ;    Function
  214. ;       PPPStateMachine
  215. ;
  216. ;   Description
  217. ;       Handles PPP link establishment
  218. ;
  219. ;****************************************************************************
  220. PPPStateMachine:
  221.     ; Start the timer
  222.     xor     eax, eax
  223.     call    settimer
  224.  
  225. PPPLoop:
  226.  
  227.     mov     eax, 11                 ; check event
  228.     int     0x40
  229.     cmp     eax, 3
  230.     jne     PPPLred
  231.         ; button pressed
  232.     mov     eax, 17                     ; get id
  233.     int     0x40
  234.  
  235.  
  236.     mov     eax, hangp
  237.     mov     [prompt], eax               ; set up prompt to display
  238.     mov     al,[hangp_len]
  239.     mov     [prompt_len], al
  240.     call    draw_window
  241.  
  242.     mov     esi, hangupWait
  243.     mov     edi, hangupSend
  244.     mov     edx, 1000                   ; Allow sendwait 10s
  245.     call    sendwait
  246.  
  247.     call    disable_port
  248.     mov     eax, -1                     ; close this program
  249.     int     0x40
  250.     jmp     PPPLoop
  251.  
  252. PPPLred:
  253.     cmp     eax, 1                      ; redraw request ?
  254.     jne     PPPLoop0
  255.  
  256.     call    draw_window
  257.     jmp     PPPLoop
  258.  
  259. PPPLoop0:
  260.     mov     ebx, [comirq]
  261.     add     ebx, 16
  262.     cmp     eax, ebx
  263.     jne     ppp_002                    ; check for tx to send
  264.  
  265.  
  266.     ; we have data in the rx buffer, get it
  267.  
  268.     mov     eax, 42
  269.     mov     ebx, [comirq]      ; ecx will return 0 =data read, 1 =no data
  270.     int     0x40               ; or 2 =not irq owner
  271.  
  272.     inc     dword [rxbytes]
  273.  
  274.     cmp     bl, 0x7E
  275.     jne     ppp_001a
  276.  
  277.     mov     eax, [rx_ptr]
  278.     cmp     eax, 0
  279.     jz      ppp_001
  280.     mov     eax, [checksum1]
  281.     cmp     eax, 0xf0b8
  282.     jne     ppp_001
  283.  
  284.  
  285.     movzx   eax, byte [rx_str + 3]
  286.     mov     ah, [rx_str + 2]
  287.     mov     [packet], eax
  288.  
  289. ppp_001:
  290.     mov     eax, [extended]
  291.     and     eax, 0x7e
  292.     mov     [extended], eax
  293.     xor     eax, eax
  294.     mov     [rx_ptr], eax
  295.  
  296.     mov     eax, 0xffff
  297.     mov     [checksum1], eax
  298.     jmp     ppp_003
  299.  
  300. ppp_001a:
  301.     cmp     bl, 0x7D
  302.     jne     ppp_001b
  303.  
  304.     mov     eax, [extended]
  305.     or      eax, 0x01
  306.     mov     [extended], eax
  307.     jmp     ppp_003
  308.  
  309. ppp_001b:
  310.     mov     eax, [extended]
  311.     test    eax, 0x01
  312.     jz      ppp_001c
  313.  
  314.     xor     bl, 0x20
  315.     and     eax, 0xFE
  316.     mov     [extended], eax
  317.  
  318. ppp_001c:
  319.     mov     edx, [rx_ptr]
  320.     cmp     edx, 0
  321.     jnz     ppp_001d
  322.     cmp     bl, 0xff
  323.     je      ppp_001d
  324.  
  325.     mov     [rx_str + edx], byte 0xff
  326.     inc     edx
  327.  
  328. ppp_001d:
  329.     cmp     edx, 1
  330.     jnz     ppp_001e
  331.     cmp     bl, 0x03
  332.     je      ppp_001e
  333.  
  334.     mov     [rx_str + edx], byte 0x03
  335.     inc     edx
  336.  
  337. ppp_001e:
  338.     cmp     edx, 2
  339.     jnz     ppp_001f
  340.     test    bl, 0x01
  341.     jz      ppp_001f
  342.  
  343.     mov     [rx_str + edx], byte 0
  344.     inc     edx
  345.  
  346. ppp_001f:
  347.     mov     [rx_str + edx], bl
  348.     inc     edx
  349.     mov     [rx_ptr], edx
  350.  
  351.     cmp     edx, MaxRx
  352.     jle     ppp_001g
  353.     mov     edx, MaxRx
  354.     mov     [rx_ptr], edx
  355.  
  356. ppp_001g:
  357.     ; do checksum calc
  358.     mov     eax, [checksum1]
  359.     xor     bh, bh
  360.     xor     ax, bx
  361.     call    calc
  362.     mov     ebx, [checksum1]
  363.     and     ebx, 0xffff
  364.     shr     ebx, 8
  365.     xor     eax, ebx
  366.     mov     [checksum1], eax
  367.     jmp     ppp_003
  368.  
  369. ppp_002:
  370.     mov     eax, [tx_end]
  371.     cmp     eax, 0
  372.     jz      ppp_003
  373.  
  374.     mov     ebx, [tx_ptr]
  375.     mov     cl, [tx_str + ebx]
  376.  
  377.     cmp     ebx, eax
  378.     jne     ppp_002a
  379.     mov     [tx_end], dword 0
  380.     mov     cl, '~'
  381.     jmp     ppp_002d
  382.  
  383. ppp_002a:
  384.     mov     eax, [extended]
  385.     and     eax, 0x02
  386.     jz      ppp_002b
  387.  
  388.     xor     cl, 0x20
  389.     mov     eax, [extended]
  390.     and     eax, 0xFD
  391.     mov     [extended], eax
  392.     inc     [tx_ptr]
  393.     jmp     ppp_002d
  394.  
  395. ppp_002b:
  396.     cmp     cl, 0x20
  397.     jl      ppp_002b1
  398.     cmp     cl, 0x7d
  399.     je      ppp_002b1
  400.     cmp     cl, 0x7e
  401.     je      ppp_002b1
  402.     jmp     ppp_002c
  403.  
  404. ppp_002b1:
  405.     mov     eax, [extended]
  406.     or      eax, 0x02
  407.     mov     [extended], eax
  408.     mov     cl, 0x7d
  409.     jmp     ppp_002d
  410.  
  411. ppp_002c:
  412.     mov     eax, [tx_ptr]
  413.     cmp     eax, 0
  414.     jnz     ppp_002c1
  415.     mov     cl, '~'
  416.  
  417. ppp_002c1:
  418.     inc     [tx_ptr]
  419.  
  420. ppp_002d:
  421.     ; Test for tx ready.
  422.  
  423.     push    ecx
  424.  
  425. wait_txd2:
  426.     mov     eax,43
  427.     mov     ecx, [comport]
  428.     add     ecx, 0x80000000 + 5
  429.     int     0x40
  430.     and     bl, 0x40
  431.     cmp     bl, 0
  432.     jz      wait_txd2                  ; loop until free
  433.  
  434.     pop     ebx
  435.  
  436.  
  437.     ; send the character
  438.  
  439.     inc     dword [txbytes]
  440.  
  441.     mov     ecx, [comport]
  442.     mov     eax, 43
  443.     int     0x40
  444.  
  445. ppp_003:
  446.     mov     eax, [packet]
  447.     cmp     eax, LCP
  448.     jne     ppp_004
  449.  
  450.     mov     al, [rx_str + 4]
  451.     cmp     al, REQ
  452.     jne     ppp_003b
  453.  
  454.     ; Debugging output to debug board
  455.     pusha
  456.     mov     esi, RX_LCP_REQ
  457.     call    debug_output
  458.     popa
  459.  
  460.     mov     eax, [state]
  461.     and     eax, 0xfd
  462.     mov     [state], eax
  463.  
  464.     mov     ebx, 0xc6
  465.     push    eax
  466.     call    TestOptions
  467.     pop     eax
  468.     cmp     edx, 0
  469.     jz      ppp_003g
  470.  
  471.     cmp     edx, 1
  472.     jle     ppp_003h
  473.  
  474.     mov     edx, PPP_ACK
  475.     cmp     eax, 3
  476.     jge     ppp_003i
  477.  
  478.     or      eax, 0x02
  479.     mov     [state], eax
  480.     jmp     ppp_003i
  481.  
  482. ppp_003h:
  483.     mov     bl, 0xc0
  484.     mov     [rx_str + 10], bl
  485.     mov     edx, PPP_NAK
  486.     jmp     ppp_003i
  487.  
  488. ppp_003g:
  489.     mov     edx, REJ
  490.  
  491. ppp_003i:
  492.  
  493.     mov     ebx, LCP
  494.     mov     ecx, edx
  495.     movzx   edx, byte [rx_str + 5]
  496.     mov     esi, rx_str + 7
  497.     call    MakePacket
  498.  
  499.     mov     eax, 0
  500.     call    settimer
  501.     jmp     ppp_003a
  502.  
  503. ppp_003b:
  504.     cmp     al, PPP_ACK
  505.     jne     ppp_003c
  506.  
  507.     ; Debugging output to debug board
  508.     pusha
  509.     mov     esi, RX_LCP_ACK
  510.     call    debug_output
  511.     popa
  512.  
  513.     mov     eax, [number]
  514.     cmp     al, [rx_str+5]
  515.     jne     ppp_003a
  516.  
  517.     mov     eax, [state]
  518.     cmp     eax, 3
  519.     jge     ppp_003a
  520.     or      eax, 0x01
  521.     mov     [state], eax
  522.     jmp     ppp_003a
  523.  
  524. ppp_003c:
  525.     cmp     al, PPP_NAK
  526.     jne     ppp_003d
  527.  
  528.     ; Debugging output to debug board
  529.     pusha
  530.     mov     esi, RX_LCP_NAK
  531.     call    debug_output
  532.     popa
  533.  
  534.     mov     eax, [state]
  535.     and     eax, 0xfe
  536.     mov     [state], eax
  537.     jmp     ppp_003a
  538.  
  539. ppp_003d:
  540.     cmp     al, REJ
  541.     jne     ppp_003e
  542.  
  543.     ; Debugging output to debug board
  544.     pusha
  545.     mov     esi, RX_LCP_REJ
  546.     call    debug_output
  547.     popa
  548.  
  549.     mov     eax, [state]
  550.     and     eax, 0xfe
  551.     mov     [state], eax
  552.     jmp     ppp_003a
  553.  
  554. ppp_003e:
  555.     cmp     al, TERM
  556.     jne     ppp_003j
  557.     jmp     ppp_003a
  558.  
  559. ppp_003j:
  560.     cmp     al, LCP_ECHO_REQ
  561.     jne     ppp_003a
  562.  
  563.     ; Debugging output to debug board
  564.     pusha
  565.     mov     esi, RX_LCP_ECHO_REQ
  566.     call    debug_output
  567.     popa
  568.  
  569.     mov     al, 0
  570.     mov     [rx_str+8],al
  571.     mov     [rx_str+9],al
  572.     mov     [rx_str+10],al
  573.     mov     [rx_str+11],al
  574.  
  575.     mov     ebx, LCP
  576.     mov     ecx, LCP_ECHO_REP
  577.     movzx   edx, byte [rx_str + 5]
  578.     mov     esi, rx_str + 7
  579.     call    MakePacket
  580.  
  581. ppp_003a:
  582.     mov     eax, [state]
  583.     cmp     eax, 3
  584.     jne     ppp_013
  585.  
  586.     mov     eax, 4
  587.     mov     [state], eax
  588.  
  589.     jmp     ppp_013
  590.  
  591.  
  592. ppp_004:
  593.     cmp     eax, PAP
  594.     jne     ppp_005
  595.  
  596.     mov     al, [rx_str + 4]
  597.     cmp     al, PPP_ACK
  598.     jne     ppp_013
  599.  
  600.     ; Debugging output to debug board
  601.     pusha
  602.     mov     esi, RX_PAP_ACK
  603.     call    debug_output
  604.     popa
  605.  
  606.     mov     eax, 5
  607.     mov     [state],eax
  608.     jmp     ppp_013
  609.  
  610. ppp_005:
  611.     cmp     eax, IPCP
  612.     jne     ppp_006
  613.  
  614.     mov     al, [rx_str + 4]
  615.     cmp     al, REQ
  616.     jne     ppp_005a
  617.  
  618.     ; Debugging output to debug board
  619.     pusha
  620.     mov     esi, RX_IPCP_REQ
  621.     call    debug_output
  622.     popa
  623.  
  624.     mov     ebx, 0x04
  625.     call    TestOptions
  626.     cmp     edx, 0
  627.     jz      ppp_005b
  628.     mov     ecx, PPP_ACK
  629.     mov     eax, 6
  630.     mov     [state], eax
  631.     jmp     ppp_005c
  632. ppp_005b:
  633.     mov     ecx, REJ
  634.  
  635. ppp_005c:
  636.     mov     ebx, IPCP
  637.     movzx   edx, byte [rx_str + 5]
  638.     mov     esi, rx_str + 7
  639.     call    MakePacket
  640.     jmp     ppp_013
  641.  
  642. ppp_005a:
  643.     cmp     al, PPP_ACK
  644.     jne     ppp_005d
  645.  
  646.     ; Debugging output to debug board
  647.     pusha
  648.     mov     esi, RX_IPCP_ACK
  649.     call    debug_output
  650.     popa
  651.  
  652.     mov     al, [rx_str + 5]
  653.     mov     ecx, [number]
  654.     cmp     al, cl
  655.     jne     ppp_013
  656.  
  657.     mov     eax, 7
  658.     mov     [state], eax
  659.     mov     eax, 5800
  660.     call    settimer
  661.  
  662.     mov     eax, IPOnp
  663.     mov     [prompt], eax               ; set up prompt to display
  664.     mov     al,[IPOnp_len]
  665.     mov     [prompt_len], al
  666.     call    draw_window
  667.  
  668.     jmp     ppp_013
  669.  
  670. ppp_005d:
  671.     cmp     al, PPP_NAK
  672.     jne     ppp_005e
  673.  
  674.     ; Debugging output to debug board
  675.     pusha
  676.     mov     esi, RX_IPCP_NAK
  677.     call    debug_output
  678.     popa
  679.  
  680.     mov     al, [rx_str + 10]
  681.     mov     [addr1], al
  682.     mov     al, [rx_str + 11]
  683.     mov     [addr2], al
  684.     mov     al, [rx_str + 12]
  685.     mov     [addr3], al
  686.     mov     al, [rx_str + 13]
  687.     mov     [addr4], al
  688.  
  689.     pusha
  690.     call    draw_window
  691.  
  692.     mov     eax,52
  693.     mov     ebx,3
  694.     mov     cl, [addr4]
  695.     shl     ecx, 8
  696.     mov     cl, [addr3]
  697.     shl     ecx, 8
  698.     mov     cl, [addr2]
  699.     shl     ecx, 8
  700.     mov     cl, [addr1]
  701.     int     0x40                       ; Set the stacks IP address
  702.  
  703.     popa
  704.  
  705.     mov     ebx, IPCP  ;; added 28/4/03
  706.     mov     ecx, REQ
  707.     movzx   edx, byte [rx_str + 5]
  708.     mov     esi, rx_str + 7
  709.     call    MakePacket
  710.     jmp     ppp_013
  711.  
  712. ppp_005e:
  713.     cmp     al, REJ
  714.     jne     ppp_005f
  715.     jmp     ppp_013
  716.  
  717. ppp_005f:
  718.     cmp     al, TERM
  719.     jne     ppp_013
  720.     jmp     ppp_013
  721.  
  722. ppp_006:
  723.     cmp     eax, IP
  724.     jne     ppp_007
  725.  
  726.  
  727. ;;
  728. ;;
  729. ;;
  730. ;; This is where we will pass the IP packet up to the stack
  731. ;;
  732. ;;
  733. ;;
  734.     mov     eax, 52
  735.     mov     ebx, 6
  736.     mov     edx, 1500   ; this should be exact amount
  737.     mov     esi, rx_str + 4
  738.     int     0x40
  739.  
  740.     ; Debugging output to debug board
  741.     pusha
  742.     mov     esi, RX_IP
  743.     call    debug_output
  744.     popa
  745.  
  746.     jmp     ppp_013
  747.  
  748. ppp_007:
  749.     cmp     eax, CCP
  750.     jne     ppp_008
  751.  
  752.     mov     al, [rx_str + 4]
  753.     cmp     al, REQ
  754.     jne     ppp_013
  755.  
  756.     ; Debugging output to debug board
  757.     pusha
  758.     mov     esi, RX_CCP_REQ
  759.     call    debug_output
  760.     popa
  761.  
  762.     mov     ebx, 0x04
  763.     call    TestOptions
  764.     cmp     edx, 0
  765.     jz      ppp_007b
  766.     mov     ecx, PPP_ACK
  767.     jmp     ppp_007c
  768. ppp_007b:
  769.     mov     ecx, REJ
  770.  
  771. ppp_007c:
  772.     mov     ebx, CCP
  773.     movzx   edx, byte [rx_str + 5]
  774.     mov     esi, rx_str + 7
  775.     call    MakePacket
  776.  
  777.     jmp     ppp_013
  778.  
  779. ppp_008:
  780.     cmp     eax, 0
  781.     jz      ppp_009
  782.  
  783.     jmp     ppp_013
  784.  
  785. ppp_009:
  786.     mov     eax, [tx_end]
  787.     cmp     eax, 0
  788.     jnz     ppp_010
  789.     call    gettimer
  790.     cmp     eax, 100
  791.     jle     ppp_010
  792.  
  793.     mov     eax, [state]
  794.     cmp     eax, 0
  795.     je      ppp_009a
  796.     cmp     eax, 2
  797.     jne     ppp_010
  798.  
  799. ppp_009a:
  800.  
  801.     ; Debugging output to debug board
  802.     pusha
  803.     mov     esi, TX_LCP_REQ
  804.     call    debug_output
  805.     popa
  806.  
  807.     inc     [number]
  808.     mov     eax, 0
  809.     call    settimer
  810.  
  811.     mov     ebx, LCP
  812.     mov     ecx, REQ
  813.     mov     edx, [number]
  814.     mov     esi, LCPREQStr
  815.     call    MakePacket
  816.  
  817.     jmp     ppp_013
  818.  
  819. ppp_010:
  820.     mov     eax, [tx_end]
  821.     cmp     eax, 0
  822.     jnz     ppp_011
  823.     call    gettimer
  824.     cmp     eax, 100
  825.     jle     ppp_011
  826.     mov     eax, [state]
  827.     cmp     eax, 4
  828.     jne     ppp_011
  829.     mov     eax, 0
  830.     call    settimer
  831.     inc     [number]
  832.  
  833.     ; Debugging output to debug board
  834.     pusha
  835.     mov     esi, TX_PAP_REQ
  836.     call    debug_output
  837.     popa
  838.  
  839.     mov     ebx, PAP
  840.     mov     ecx, REQ
  841.     mov     edx, [number]
  842.     mov     esi, PAPREQStr
  843.     call    MakePacket
  844.  
  845.     jmp     ppp_013
  846.  
  847. ppp_011:
  848.     mov     eax, [tx_end]
  849.     cmp     eax, 0
  850.     jnz     ppp_012
  851.     call    gettimer
  852.     cmp     eax, 100
  853.     jle     ppp_012
  854.     mov     eax, [state]
  855.     cmp     eax, 6
  856.     jne     ppp_012
  857.     inc     [number]
  858.     mov     eax, 0
  859.     call    settimer
  860.  
  861.     ; Debugging output to debug board
  862.     pusha
  863.     mov     esi, TX_IPCP_REQ
  864.     call    debug_output
  865.     popa
  866.  
  867.     mov     ebx, IPCP
  868.     mov     ecx, REQ
  869.     mov     edx, [number]
  870.     mov     esi, IPCPREQStr
  871.     call    MakePacket
  872.  
  873.     jmp     ppp_013
  874.  
  875. ppp_012:
  876.     mov     eax, [tx_end]
  877.     cmp     eax, 0
  878.     jnz     ppp_013
  879.     mov     eax, [state]
  880.     cmp     eax, 7
  881.     jne     ppp_013
  882.  
  883.     ; 10ms Delay suggested by Ville
  884.     mov     eax,23     ; over here
  885.     mov     ebx,1
  886.     int     0x40
  887.  
  888.  
  889.  
  890.     call    gettimer
  891.     cmp     eax, 200
  892.     jle     ppp_012a
  893.  
  894.  ; every 2s, when things are quiet, redraw window
  895.     call    draw_window_limited
  896.  
  897.     mov     eax, 0
  898.     call    settimer
  899.  
  900. ppp_012a:
  901.  
  902.     mov     eax, 52
  903.     mov     ebx, 8
  904.     mov     esi, ip_buff
  905.     int     0x40
  906.  
  907.     cmp     eax, 0
  908.     je      ppp_013
  909.  
  910.     call    MakeIPPacket
  911.  
  912.     ; Debugging output to debug board
  913.     pusha
  914.     mov     esi, TX_IP
  915.     call    debug_output
  916.     popa
  917.  
  918. ppp_013:
  919.     mov     eax, [packet]
  920.     cmp     eax, 0
  921.     jz      PPPLoop
  922.  
  923.     mov     eax, 0
  924.     mov     [packet], eax
  925.  
  926.     mov     edi, rx_str
  927.     mov     ecx, MaxRx + 1
  928.     rep     stosb
  929.     jmp     PPPLoop
  930.  
  931.  
  932.  
  933. ;****************************************************************************
  934. ;    Function
  935. ;       calc
  936. ;
  937. ;   Description
  938. ;       Adds a character to the CRC checksum
  939. ;       byte in lsb of eax
  940. ;
  941. ;
  942. ;****************************************************************************
  943. calc:
  944.     and     eax, 0xFF
  945.     push    ecx
  946.     mov     ecx, 8
  947. calc_001:
  948.     test    al, 0x01
  949.     jz      calc_002
  950.     shr     eax, 1
  951.     xor     eax, 0x8408
  952.     and     eax, 0xffff
  953.     jmp     calc_003
  954. calc_002:
  955.     shr     eax, 1
  956. calc_003:
  957.     loop    calc_001
  958.     pop     ecx
  959.     ret
  960.  
  961.  
  962. ;****************************************************************************
  963. ;    Function
  964. ;       add2tx
  965. ;
  966. ;   Description
  967. ;       Adds a character into the tx buffer
  968. ;       byte in low byte of eax
  969. ;
  970. ;
  971. ;****************************************************************************
  972. add2tx:
  973.     pusha
  974.     mov     esi, tx_str
  975.     add     esi, [tx_ptr]
  976.     inc     [tx_ptr]
  977.     mov     [esi], al               ; Save byte in buffer
  978.     mov     ecx, [checksum2]
  979.     and     eax, 0xff
  980.     xor     eax, ecx
  981.     call    calc
  982.     shr     ecx, 8
  983.     and     ecx, 0xff
  984.     xor     eax, ecx
  985.     mov     [checksum2], eax
  986.     popa
  987.     ret
  988.  
  989.  
  990.  
  991. ;****************************************************************************
  992. ;    Function
  993. ;       MakeIPPacket
  994. ;
  995. ;   Description
  996. ;       Creates a PPP packet for transmission to the host from the
  997. ;       IP packet extracted from the stack
  998. ;
  999. ;       IP data is in ip_buff
  1000. ;
  1001. ;****************************************************************************
  1002. MakeIPPacket:
  1003.     mov     [tx_ptr], dword 1
  1004.     mov     edi, tx_str
  1005.     mov     [edi], byte ' '
  1006.     mov     eax, 0xffff
  1007.     mov     [checksum2], eax
  1008.     mov     al, 0xff
  1009.     call    add2tx
  1010.     mov     al, 3
  1011.     call    add2tx
  1012.     mov     al, IP / 256
  1013.     call    add2tx
  1014.     mov     al, IP
  1015.     call    add2tx
  1016.  
  1017.     movzx   ecx, byte [ip_buff + 3]
  1018.     mov     ch, byte [ip_buff + 2]
  1019.  
  1020.     mov     esi, ip_buff
  1021.  
  1022. mip001:
  1023.     mov     al, byte [esi]
  1024.     call    add2tx
  1025.     inc     esi
  1026.     loop    mip001
  1027.  
  1028.     mov     eax, [checksum2]
  1029.     not     eax
  1030.     call    add2tx
  1031.     shr     eax, 8
  1032.     call    add2tx
  1033.  
  1034.     mov     eax, [tx_ptr]
  1035.     mov     [tx_end], eax
  1036.     xor     eax, eax
  1037.     mov     [tx_ptr], eax
  1038.     ret
  1039.  
  1040.  
  1041. ;****************************************************************************
  1042. ;    Function
  1043. ;       MakePacket
  1044. ;
  1045. ;   Description
  1046. ;       Creates a PPP packet for transmission to the host
  1047. ;
  1048. ;       Packet type in ebx
  1049. ;       Code is in ecx
  1050. ;       num is in edx
  1051. ;       str is pointed to by esi
  1052. ;
  1053. ;****************************************************************************
  1054. MakePacket:
  1055.     mov     [tx_ptr], dword 1
  1056.     mov     edi, tx_str
  1057.     mov     [edi], byte ' '
  1058.     mov     eax, 0xffff
  1059.     mov     [checksum2], eax
  1060.     mov     al, 0xff
  1061.     call    add2tx
  1062.     mov     al, 3
  1063.     call    add2tx
  1064.     mov     al, bh                  ; packet/256
  1065.     call    add2tx
  1066.     mov     al, bl                  ; packet&255
  1067.     call    add2tx
  1068.  
  1069.     cmp     ebx, IP                 ; is packet type IP?
  1070.     jne     mp_001                  ; No - its a lower layer packet
  1071.  
  1072.     ; Do IP packet assembly
  1073.  
  1074.     jmp     mp_002
  1075.  
  1076. mp_001:
  1077.     ; Do PPP layer packet assembly
  1078.     mov     al, cl
  1079.     call    add2tx
  1080.     mov     al, dl
  1081.     call    add2tx
  1082.     mov     al, 0
  1083.     call    add2tx
  1084.  
  1085.     movzx   ecx, byte [esi]         ; length = *str - 3
  1086.     sub     ecx, 3
  1087.  
  1088. mp_002:                             ; Now copy the data acros
  1089.     mov     al, byte [esi]
  1090.     call    add2tx
  1091.     inc     esi
  1092.     loop    mp_002
  1093.  
  1094.     mov     eax, [checksum2]
  1095.     not     eax
  1096.     call    add2tx
  1097.     shr     eax, 8
  1098.     call    add2tx
  1099.  
  1100.     mov     eax, [tx_ptr]
  1101.     mov     [tx_end], eax
  1102.     xor     eax, eax
  1103.     mov     [tx_ptr], eax
  1104.     ret
  1105.  
  1106.  
  1107. ;****************************************************************************
  1108. ;    Function
  1109. ;       TestOptions
  1110. ;
  1111. ;   Description
  1112. ;       Test a PPP packets options fields for valid entries
  1113. ;
  1114. ;       option ebx
  1115. ;
  1116. ;       Returns result in edx, but may also modify rx_str
  1117. ;
  1118. ;****************************************************************************
  1119. TestOptions:
  1120.     mov     esi, 8                  ; ptr1
  1121.     mov     edi, 8                  ; ptr2
  1122.     mov     edx, 3                  ; edx is the return value
  1123.     movzx   ecx, byte [rx_str + 7]
  1124.     add     ecx, 4                  ; ecx is size
  1125.     cmp     ecx, MaxRx
  1126.     jle     to_001
  1127.     mov     ecx, MaxRx
  1128. to_001:
  1129.     cmp     esi, ecx
  1130.     jge      to_002
  1131.     mov     al, byte [esi + rx_str]
  1132.     cmp     al, 3
  1133.     jne     to_001a
  1134.     mov     al, byte [esi + rx_str + 2]
  1135.     cmp     al, 0x80
  1136.     je      to_001a
  1137.     ; bug fix for chap authenticate reject below
  1138.     mov     al, byte [esi + rx_str + 2]
  1139.     cmp     al, 0xc2
  1140.     jne     to_001a
  1141.     and     edx, 0xfd
  1142. to_001a:
  1143.     push    ecx
  1144.     mov     cl, [esi + rx_str]
  1145.     dec     cl
  1146.     mov     eax, 1
  1147.     shl     eax, cl
  1148.     and     eax, ebx
  1149.     and     eax, 0xffff
  1150.     pop     ecx
  1151.     cmp     eax, 0
  1152.     jnz     to_001b
  1153.     xor     edx,edx
  1154. to_001b:
  1155.     movzx   eax, byte [esi+rx_str+1]
  1156.     add     esi, eax
  1157.     jmp     to_001
  1158. to_002:
  1159.     ; if (!(pass&2))...
  1160.     test    edx, 2
  1161.     jnz     to_exit
  1162.     test    edx, 1
  1163.     jz      to_002a
  1164.     mov     ebx, 0xFFFB
  1165. to_002a:
  1166.     mov     esi, 8
  1167. to_002b:                            ; for loop
  1168.     cmp     esi, ecx
  1169.     jge      to_003
  1170.  
  1171.     push    ecx
  1172.     mov     cl, [esi + rx_str]
  1173.     dec     cl
  1174.     mov     eax, 1
  1175.     shl     eax, cl
  1176.     and     eax, ebx
  1177.     and     eax, 0xffff
  1178.     pop     ecx
  1179.     cmp     eax, 0
  1180.     jnz     to_002c
  1181.     movzx   edx, byte [esi+rx_str+1]
  1182. to_002d:
  1183.     cmp     esi, ecx
  1184.     jge      to_002b
  1185.     cmp     edx, 0
  1186.     jz      to_002b
  1187.     mov     al, [esi + rx_str]
  1188.     mov     [edi + rx_str], al
  1189.     inc     esi
  1190.     inc     edi
  1191.     dec     edx
  1192.     jmp     to_002d
  1193. to_002c:
  1194.     movzx   eax, byte [esi+rx_str+1]
  1195.     add     esi, eax
  1196.     jmp     to_002b                 ; end of for loop
  1197. to_003:
  1198.     mov     eax, edi
  1199.     sub     al, 4
  1200.     mov     [rx_str+7], al
  1201.     xor     edx, edx
  1202.     cmp     ebx, 0xfffb
  1203.     jne     to_exit
  1204.     inc     edx
  1205. to_exit:
  1206.     ; Return value in EDX
  1207.     ret
  1208.  
  1209.  
  1210.  
  1211. ;***************************************************************************
  1212. ;    Function
  1213. ;        disable_port
  1214. ;
  1215. ;   Description;
  1216. ;       Releases this applications use of the com port
  1217. ;
  1218. ;***************************************************************************
  1219. disable_port:
  1220. if DEBUG_PORT2_OUTPUT = TRUE
  1221.     mov      eax, 46                 ; free port area
  1222.     mov      ebx, 1
  1223.  
  1224.     mov      ecx, 0x2f8
  1225.     and      ecx, 0xFF0
  1226.     mov      edx, ecx
  1227.     or       edx, 0x00F
  1228.     int      0x40
  1229. end if
  1230.  
  1231.     mov      eax, 45                 ; free irq 4
  1232.     mov      ebx, 1
  1233.     mov      ecx, [comirq]
  1234.     int      0x40
  1235.  
  1236.     mov      eax, 46                 ; free port area
  1237.     mov      ebx, 1
  1238.  
  1239.     mov      ecx, [comport]
  1240.     and      ecx, 0xFF0
  1241.     mov      edx, ecx
  1242.     or       edx, 0x00F
  1243.     int      0x40
  1244.     ret
  1245.  
  1246.  
  1247.  
  1248. ;***************************************************************************
  1249. ;    Function
  1250. ;        enable_port
  1251. ;
  1252. ;   Description;
  1253. ;    Takes control of the com port, defining the IRQ table and initialising
  1254. ;     the uart chip.
  1255. ;
  1256. ;***************************************************************************
  1257. enable_port:
  1258.     pusha
  1259. if DEBUG_PORT2_OUTPUT = TRUE
  1260.     mov      eax, 46
  1261.     mov      ebx, 0
  1262.     mov      ecx, 0x2f8
  1263.     and      ecx, 0xFF0
  1264.     mov      edx, ecx
  1265.     or       edx, 0x00F
  1266.     int      0x40                     ; reseve port memory to this process
  1267.  
  1268.     mov      eax, 45                  ; reserve irq 3
  1269.     mov      ebx, 0
  1270.     mov      ecx, 3
  1271.     int      0x40
  1272.  
  1273.  
  1274.     mov      ecx, 0x2f8             ; data format register
  1275.     add      ecx, 3
  1276.     mov      bl, 0x80               ; enable access to divisor latch
  1277.     mov      eax, 43                ; send data to device - com port setup
  1278.     int      0x40
  1279.  
  1280.     mov      ecx, 0x2f8          ; interrupt enable register
  1281.     inc      ecx
  1282.     mov      bl, 0                    ; No interruts enabled
  1283.     mov      eax, 43                  ; send data to device (modem)
  1284.     int      0x40
  1285.  
  1286.     mov      ecx, 0x2f8                 ; Divisor latch LSB
  1287.     mov      bl, BAUDRATE             ; set baud rate
  1288.     mov      eax, 43                  ; send data to device (modem)
  1289.     int      0x40
  1290.  
  1291.     mov      ecx, 0x2f8             ; Data format register
  1292.     add      ecx, 3
  1293.     mov      bl, 3                    ; 8 data bits
  1294.     mov      eax, 43                  ; send data to device (modem)
  1295.     int      0x40
  1296.  
  1297.     mov      ecx, 0x2f8        ; Modem control register
  1298.     add      ecx, 4                ; ** bl must be 0x0b for modem to dial!
  1299.     mov      bl, 0x0b              ; 0x08 -> out2 enabled. No handshaking.
  1300.        ; 0xb ->  out2 enabled, RTS/DTR enabled
  1301.     mov      eax, 43               ; send data to device (modem)
  1302.     int      0x40
  1303.  
  1304. ;    mov      ecx, 0x2f8        ; interrupt enable register
  1305. ;    inc      ecx
  1306. ;    mov      bl, 1                 ; rx data interrupt enabled, othrs not
  1307. ;    mov      eax, 43               ; send data to device (modem)
  1308. ;    int      0x40
  1309.  
  1310. end if
  1311.  
  1312.     mov      eax, 46
  1313.     mov      ebx, 0
  1314.     mov      ecx, [comport]
  1315.     and      ecx, 0xFF0
  1316.     mov      edx, ecx
  1317.     or       edx, 0x00F
  1318.     int      0x40                     ; reseve port memory to this process
  1319.  
  1320.     mov      eax, 45                  ; reserve irq 4
  1321.     mov      ebx, 0
  1322.     mov      ecx, [comirq]
  1323.     int      0x40
  1324.  
  1325.     mov      eax, 44                  ; setup irq table
  1326.     mov      ebx, irqtable
  1327.     mov      ecx, [comirq]
  1328.     int      0x40
  1329.  
  1330.     mov      ecx, [comport]             ; data format register
  1331.     add      ecx, 3
  1332.     mov      bl, 0x80               ; enable access to divisor latch
  1333.     mov      eax, 43                ; send data to device - com port setup
  1334.     int      0x40
  1335.  
  1336.     mov      ecx, [comport]          ; interrupt enable register
  1337.     inc      ecx
  1338.     mov      bl, 0                    ; No interruts enabled
  1339.     mov      eax, 43                  ; send data to device (modem)
  1340.     int      0x40
  1341.  
  1342.     mov      ecx, [comport]                 ; Divisor latch LSB
  1343.     mov      bl, BAUDRATE             ; set baud rate
  1344.     mov      eax, 43                  ; send data to device (modem)
  1345.     int      0x40
  1346.  
  1347.     mov      ecx, [comport]             ; Data format register
  1348.     add      ecx, 3
  1349.     mov      bl, 3                    ; 8 data bits
  1350.     mov      eax, 43                  ; send data to device (modem)
  1351.     int      0x40
  1352.  
  1353.     mov      ecx, [comport]        ; Modem control register
  1354.     add      ecx, 4                ; ** bl must be 0x0b for modem to dial!
  1355.     mov      bl, 0x0b              ; 0x08 -> out2 enabled. No handshaking.
  1356.        ; 0xb ->  out2 enabled, RTS/DTR enabled
  1357.     mov      eax, 43               ; send data to device (modem)
  1358.     int      0x40
  1359.  
  1360.     mov      ecx, [comport]        ; interrupt enable register
  1361.     inc      ecx
  1362.     mov      bl, 1                 ; rx data interrupt enabled, othrs not
  1363.     mov      eax, 43               ; send data to device (modem)
  1364.     int      0x40
  1365.  
  1366.     mov      ecx, [comirq]
  1367.     add      ecx, 16
  1368.     mov      ebx, 1
  1369.     shl      ebx, cl
  1370.     add      ebx, 111b
  1371.     mov      eax,40                  ; enable irq 4 data
  1372.     int      0x40
  1373.  
  1374.     popa
  1375.     ret
  1376.  
  1377.  
  1378.  
  1379. ;**************************************************************************
  1380. ;    Function
  1381. ;        draw_window
  1382. ;
  1383. ;   Description;
  1384. ;       Normal window definition and text layout for application
  1385. ;**************************************************************************
  1386. draw_window:
  1387.     mov      eax, 12                 ; function 12:tell os about windowdraw
  1388.     mov      ebx, 1                  ; 1, start of draw
  1389.     int      0x40
  1390.          ; DRAW WINDOW
  1391.     mov      eax, 0                  ; function 0 : define and draw window
  1392.     mov      ebx, 100*65536+250      ; [x start] *65536 + [x size]
  1393.     mov      ecx, 100*65536+150      ; [y start] *65536 + [y size]
  1394.     mov      edx,0x03224466            ; color of work area RRGGBB
  1395.     mov      esi,0x00334455            ; color of grab bar  RRGGBB
  1396.     mov      edi,0x00ddeeff            ; color of frames    RRGGBB
  1397.     int      0x40
  1398.          ; WINDOW LABEL
  1399.     mov      eax, 4                  ; function 4 : write text to window
  1400.     mov      ebx, 8*65536+8          ; [x start] *65536 + [y start]
  1401.     mov      ecx, 0x00ffffff         ; color of text RRGGBB
  1402.     mov      edx, labelt             ; pointer to text beginning
  1403.     mov      esi, labellen-labelt    ; text length
  1404.     int      0x40
  1405.        ; DIAL BUTTON
  1406.     mov      eax, 8                  ; function 8 : define and draw button
  1407.     mov      ebx, (50)*65536+40      ; [x start] *65536 + [x size]
  1408.     mov      ecx, 130*65536+12       ; [y start] *65536 + [y size]
  1409.     mov      edx, 2                  ; button id
  1410.     mov      esi, 0x5599cc           ; button color RRGGBB
  1411.     int      0x40
  1412.  
  1413.     mov      ebx, 55*65536+133       ; Draw button text
  1414.     mov      ecx, 0x00FFFFFF
  1415.     mov      edx, button1_text
  1416.     xor      eax, eax
  1417.     mov      al,  [button1_text_len]
  1418.     mov      esi, eax
  1419.     mov      eax, 4
  1420.     int      0x40
  1421.       ; DISCONNECT BUTTON
  1422.     mov      eax, 8                  ; function 8 : define and draw button
  1423.     mov      ebx, (150)*65536+65     ; [x start] *65536 + [x size]
  1424.     mov      ecx, 130*65536+12       ; [y start] *65536 + [y size]
  1425.     mov      edx, 3                  ; button id
  1426.     mov      esi, 0x5599cc           ; button color RRGGBB
  1427.     int      0x40
  1428.  
  1429.     mov      ebx, 155*65536+133      ; Draw button text
  1430.     mov      ecx, 0x00FFFFFF
  1431.     mov      edx, button3_text
  1432.     xor      eax, eax
  1433.     mov      al,  [button3_text_len]
  1434.     mov      esi, eax
  1435.     mov      eax, 4
  1436.     int      0x40
  1437.  
  1438.     mov      ebx, 5*65536+40         ; draw info text with function 4
  1439.     mov      ecx, 0x00FFFFFF
  1440.     mov      edx, [prompt]
  1441.     xor      eax, eax
  1442.     mov      al,  [prompt_len]
  1443.     mov      esi, eax
  1444.     mov      eax, 4
  1445.     int      0x40
  1446.  
  1447.     ; Draw IP address
  1448.     mov      edx, 10*65536+60
  1449.     mov      esi, 0x00FFFFFF
  1450.     mov      ebx, 0x00030000
  1451.     movzx    ecx, byte [addr1]
  1452.     mov      eax, 47
  1453.     int      0x40
  1454.     mov      edx, 31*65536+60
  1455.     mov      esi, 0x00FFFFFF
  1456.     mov      ebx, 0x00030000
  1457.     movzx    ecx, byte [addr2]
  1458.     mov      eax, 47
  1459.     int      0x40
  1460.     mov      edx, 52*65536+60
  1461.     mov      esi, 0x00FFFFFF
  1462.     mov      ebx, 0x00030000
  1463.     movzx    ecx, byte [addr3]
  1464.     mov      eax, 47
  1465.     int      0x40
  1466.     mov      edx, 73*65536+60
  1467.     mov      esi, 0x00FFFFFF
  1468.     mov      ebx, 0x00030000
  1469.     movzx    ecx, byte [addr4]
  1470.     mov      eax, 47
  1471.     int      0x40
  1472.  
  1473.     ; Status byte
  1474.     mov      edx, 100*65536+60
  1475.     mov      esi, 0x00FFFFFF
  1476.     mov      ebx, 0x00010000
  1477.     movzx    ecx, byte [state]
  1478.     mov      eax, 47
  1479.     int      0x40
  1480.  
  1481.     ; bytes sent / received
  1482.     mov      eax, 4                  ; function 4 : write text to window
  1483.     mov      ebx, 10*65536+80          ; [x start] *65536 + [y start]
  1484.     mov      ecx, 0x00ffffff         ; color of text RRGGBB
  1485.     mov      edx, txmsg              ; pointer to text beginning
  1486.     mov      esi, txmsglen-txmsg    ; text length
  1487.     int      0x40
  1488.  
  1489.     mov      eax, 4                  ; function 4 : write text to window
  1490.     mov      ebx, 10*65536+100          ; [x start] *65536 + [y start]
  1491.     mov      ecx, 0x00ffffff         ; color of text RRGGBB
  1492.     mov      edx, rxmsg              ; pointer to text beginning
  1493.     mov      esi, rxmsglen-rxmsg    ; text length
  1494.     int      0x40
  1495.  
  1496.     call    draw_window_limited
  1497.  
  1498.     mov      eax, 12                 ; end of redraw
  1499.     mov      ebx, 2
  1500.     int      0x40
  1501.  
  1502.     ret
  1503.  
  1504.  
  1505.  
  1506. draw_window_limited:
  1507.     mov     eax,13
  1508.     mov     ebx,80*65536+10*6
  1509.     mov     ecx,80*65536+10
  1510.     mov     edx,0x03224466
  1511.     int     0x40
  1512.     mov     eax,13
  1513.     mov     ebx,80*65536+10*6
  1514.     mov     ecx,100*65536+10
  1515.     mov     edx,0x03224466
  1516.     int     0x40
  1517.  
  1518.     mov     ebx, 0x000A0000
  1519.     mov     ecx, [txbytes]
  1520.     mov     esi, 0x00ffffff         ; color of text RRGGBB
  1521.     mov     eax, 47                  ; function 47 : write number to window
  1522.     mov     edx, 80*65536+80          ; [x start] *65536 + [y start]
  1523.     int     0x40
  1524.  
  1525.     mov     ebx, 0x000A0000
  1526.     mov     ecx, [rxbytes]
  1527.     mov     esi, 0x00ffffff         ; color of text RRGGBB
  1528.     mov     eax, 47                  ; function 47 : write number to window
  1529.     mov     edx, 80*65536+100          ; [x start] *65536 + [y start]
  1530.     int     0x40
  1531.     ret
  1532.  
  1533.  
  1534. ;****************************************************************************
  1535. ;    Function
  1536. ;       settimer
  1537. ;
  1538. ;   Description
  1539. ;       sets the general purpose timer to a given value in eax
  1540. ;       All times are in 1/100s
  1541. ;
  1542. ;
  1543. ;****************************************************************************
  1544. settimer:
  1545.     push    eax
  1546.     mov     eax, 26
  1547.     mov     ebx, 9
  1548.     int     0x40        ; get 100th second counter
  1549.     pop     ebx
  1550.     sub     eax, ebx    ; This could have some funny side effecs if PPP
  1551.    ; called within ebx seconds of startup
  1552.     mov     [timerValue], eax
  1553.     ret
  1554.  
  1555.  
  1556. ;****************************************************************************
  1557. ;    Function
  1558. ;       gettimer
  1559. ;
  1560. ;   Description
  1561. ;       gets the general purpose timer count in eax
  1562. ;       All times are in 1/100s
  1563. ;
  1564. ;
  1565. ;****************************************************************************
  1566. gettimer:
  1567.     mov     eax, 26
  1568.     mov     ebx, 9
  1569.     int     0x40        ; get 100th second counter
  1570.  
  1571.     sub     eax, [timerValue]
  1572.     ret
  1573.  
  1574.  
  1575.  
  1576.  
  1577. ;****************************************************************************
  1578. ;    Function
  1579. ;       sendwait
  1580. ;
  1581. ;   Description
  1582. ;       Sends a command string to the modem, then waits for a defined rsp
  1583. ;
  1584. ;       esi points to string to wait for
  1585. ;       edi points to string to send
  1586. ;       edx holds wait time, in ms
  1587. ;
  1588. ;       Returns 1 if OK or 0 if timeout occurred
  1589. ;
  1590. ;****************************************************************************
  1591. sendwait:
  1592.     mov     [sendwaitTime], edx
  1593.  
  1594.     ; Shrirang 2/5/03
  1595.     mov     byte [abortcnt], 0      ; reset the abort counter
  1596.     ;--!
  1597.  
  1598.     ; Start the timer
  1599.     xor     eax, eax
  1600.     call    settimer
  1601.  
  1602.     ; Check for incoming data
  1603.  
  1604.     xor     edx, edx
  1605.     xor     eax, eax
  1606.  
  1607. sw_001:
  1608.     push    eax
  1609.     push    edx
  1610.  
  1611.     ; Has connection timer expired?
  1612.     call    gettimer
  1613.     cmp     eax, [sendwaitTime]
  1614.     jl      sw_000
  1615.  
  1616.     pop     edx
  1617.     pop     eax
  1618.  
  1619.     xor     eax, eax
  1620.  
  1621.     jmp     sw_exit                 ; Exit indicating an error ( timeout )
  1622.  
  1623. sw_000:
  1624.     ; any data from modem?
  1625.  
  1626.     mov     eax,11                     ; This will return 0 most of the time
  1627.     int     0x40
  1628.     mov     ecx, eax
  1629.     pop     edx
  1630.     pop     eax
  1631.  
  1632.  
  1633.     cmp     ecx, 1                      ; redraw request ?
  1634.     je      red1
  1635.     cmp     ecx, 3                      ; button in buffer ?
  1636.     je      button1
  1637.     mov     ebx, [comirq]
  1638.     add     ebx, 16
  1639.     cmp     ecx,ebx
  1640.     jne     sw_002
  1641.     jmp     sw_000a
  1642.  
  1643. red1:
  1644.     pusha
  1645.     call    draw_window
  1646.     popa
  1647.     push    eax
  1648.     push    edx
  1649.  
  1650.     jmp     sw_000
  1651.  
  1652. button1:
  1653.     mov     eax, 0
  1654.     jmp     sw_exit
  1655.  
  1656. sw_000a:
  1657.     ; there was data, so get it
  1658.  
  1659.     push    edx
  1660.     push    eax
  1661.     mov     eax,42
  1662.     mov     ebx, [comirq]
  1663.     int     0x40
  1664.     pop     eax
  1665.     pop     edx
  1666.  
  1667.  
  1668.     ; Shrirang 2/5/03
  1669.     ; Now that the expected response is not got we check if we
  1670.     ; got the abort part, before we reset the fsm
  1671.  
  1672.     cmp     bl, 0x0d     ; AT commands normally start and end with \r\n
  1673.     je      checkabort
  1674.  
  1675.     cmp     bl, 0x0a
  1676.     je      checkabort
  1677.  
  1678.     push    eax
  1679.     xor     eax, eax
  1680.     mov     al, [abortcnt]
  1681.     mov     byte [abortres+eax], bl         ; update abort response
  1682.     inc     byte [abortcnt]
  1683.     pop     eax
  1684.  
  1685.     jmp     noabort
  1686.  
  1687.  
  1688. checkabort :
  1689.  
  1690.     cmp     byte [abortcnt], 2  ; if we got valid abort this cannot happen!
  1691.     jbe     noabortflush
  1692.  
  1693.     push    eax
  1694.     push    esi
  1695.     push    edi
  1696.     push    ecx
  1697.  
  1698.     mov     esi, abortres
  1699.     mov     edi, aborts
  1700.     xor     ecx, ecx
  1701.     mov     cl, byte [abortcnt]
  1702.     call    scanaborts                       ; scan 'em
  1703.  
  1704.     pop     ecx
  1705.     pop     edi
  1706.     pop     esi
  1707.  
  1708.     and     eax, eax
  1709.     jz      noabortdec
  1710.  
  1711.     pop     eax
  1712.     xor     eax, eax
  1713.     jmp     sw_exit
  1714.  
  1715. noabortdec:
  1716.  
  1717.     pop     eax
  1718.  
  1719. noabortflush:
  1720.  
  1721.     mov byte [abortcnt], 0
  1722.  
  1723. noabort:
  1724.  
  1725. ;--!
  1726.  
  1727.     cmp     [esi+edx], bl
  1728.     je      sw_003
  1729.  
  1730.  
  1731.     xor     edx, edx
  1732.  
  1733.     ; Added 28/4/03
  1734.     cmp     [esi+edx], bl
  1735.     je      sw_003
  1736.  
  1737.     jmp     sw_001
  1738.  
  1739. sw_003:                             ; They are the same
  1740.     inc     edx
  1741.     cmp     [esi+edx], byte 0
  1742.     jne     sw_001
  1743.  
  1744.  
  1745.     xor     eax, eax
  1746.     inc     eax
  1747.     jmp     sw_exit
  1748.  
  1749. sw_002:
  1750.     ; Test for data to send to modem
  1751.     cmp     [ edi + eax ], byte 0
  1752.     je      sw_001
  1753.  
  1754.     ; Is it a '|' character?
  1755.     cmp     [ edi + eax ], byte '|'
  1756.     jne     sw_004
  1757.  
  1758.     push    eax
  1759.     call    gettimer
  1760.     cmp     eax, 100
  1761.     pop     eax
  1762.     jl      sw_001
  1763.  
  1764.     ; restart the timer
  1765.     push    eax
  1766.     xor     eax, eax
  1767.     call    settimer
  1768.     pop     eax
  1769.  
  1770.     ; Move to next character
  1771.     inc     eax
  1772.     jmp     sw_001
  1773.  
  1774.  
  1775. sw_004:
  1776.     push    edx
  1777.     push    eax
  1778.  
  1779.     ; restart the timer
  1780.     xor     eax, eax
  1781.     call    settimer
  1782.  
  1783.     ; Test for tx ready.
  1784.     ; OR, wait then send
  1785.     push    edi
  1786.     mov     eax, 5
  1787.     mov     ebx, 1
  1788.     int     0x40        ; 10ms delay
  1789.     pop     edi
  1790.  
  1791.     ; send the character
  1792.     pop     eax
  1793.     mov     bl, [edi + eax]
  1794.  
  1795.     mov     ecx, [comport]
  1796.     inc     eax
  1797.     push    eax
  1798.     mov     eax, 43
  1799.     int     0x40
  1800.  
  1801.     pop     eax
  1802.     pop     edx
  1803.  
  1804.     cmp     [ edi + eax ], byte 0
  1805.     jne     sw_001
  1806.  
  1807.     cmp     [ esi + edx ], byte 0
  1808.     jne     sw_001
  1809.  
  1810.     xor     eax, eax
  1811.     inc     eax
  1812.  
  1813. sw_exit:
  1814.     ; return success (1) or failure (0) in eax
  1815.     ret
  1816.  
  1817.  
  1818.  
  1819.  
  1820. if DEBUG_OUTPUT = TRUE
  1821.  
  1822. ;****************************************************************************
  1823. ;    Function
  1824. ;       debug_output
  1825. ;
  1826. ;   Description
  1827. ;       prints a description of the PPP protocol's data exchanges to the
  1828. ;       debug board
  1829. ;
  1830. ;       esi holds ptr to msg to display
  1831. ;
  1832. ;       Nothing preserved; I'm assuming a pusha/popa is done before calling
  1833. ;
  1834. ;****************************************************************************
  1835. debug_output:
  1836.     cmp     esi, RX_IP
  1837.     jne     do_001
  1838.  
  1839.     call    debug_print_string
  1840.  
  1841.     call    debug_print_rx_ip
  1842.  
  1843.     mov     esi, IP_DATA1
  1844.     call    debug_print_string
  1845.     mov     esi, CRLF
  1846.     call    debug_print_string
  1847.     mov     esi, IP_DATA2
  1848.     call    debug_print_string
  1849.     ret
  1850.  
  1851. do_001:
  1852.     cmp     esi, TX_IP
  1853.     jne     do_002
  1854.  
  1855.     call    debug_print_string
  1856.  
  1857.     call    debug_print_tx_ip
  1858.  
  1859.     mov     esi, IP_DATA1
  1860.     call    debug_print_string
  1861.     mov     esi, CRLF
  1862.     call    debug_print_string
  1863.     mov     esi, IP_DATA2
  1864.     call    debug_print_string
  1865.     ret
  1866.  
  1867. do_002:
  1868.     ; Print PPP protocol information
  1869. if DEBUG_PPP_OUTPUT = TRUE
  1870.     call    debug_print_string
  1871.     mov     esi, CRLF
  1872.     call    debug_print_string
  1873. end if
  1874.     ret
  1875.  
  1876.  
  1877.  
  1878. txCom2:
  1879.     push    ecx
  1880.  
  1881. wait_txd2t:
  1882.     mov     eax,43
  1883.     mov     ecx,0x80000000 + 0x2f8 + 5
  1884.     int     0x40
  1885.     and     bl, 0x40
  1886.     cmp     bl, 0
  1887.     jz      wait_txd2t                  ; loop until free
  1888.  
  1889.     pop     ebx
  1890.  
  1891.  
  1892.     ; send the character
  1893.  
  1894.     mov     ecx, 0x2f8
  1895.     mov     eax, 43
  1896.     int     0x40
  1897.     ret
  1898.  
  1899.  
  1900. ;****************************************************************************
  1901. ;    Function
  1902. ;       debug_print_string
  1903. ;
  1904. ;   Description
  1905. ;       prints a string to the debug board
  1906. ;
  1907. ;       esi holds ptr to msg to display
  1908. ;
  1909. ;       Nothing preserved; I'm assuming a pusha/popa is done before calling
  1910. ;
  1911. ;****************************************************************************
  1912. debug_print_string:
  1913.     mov     cl, [esi]
  1914.     cmp     cl, 0
  1915.     jnz     dps_001
  1916.     ret
  1917.  
  1918. dps_001:
  1919. if DEBUG_PORT2_OUTPUT = TRUE
  1920.     pusha
  1921.     call    txCom2
  1922.     popa
  1923. end if
  1924.     mov     eax,63
  1925.     mov     ebx, 1
  1926.     push    esi
  1927.     int 0x40
  1928.     pop     esi
  1929.     inc     esi
  1930.     jmp     debug_print_string
  1931.  
  1932.  
  1933. ; This is used for translating hex to ASCII for display or output
  1934. hexchars db '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
  1935.  
  1936. IP_DATA1    db 'TCP  From: xxxxxxxx To: xxxxxxxx SrcP: xxxx DestP: xxxx',0
  1937. IP_DATA2    db 'Seq: xxxxxxxx Ack: xxxxxxxx Flags: xx  dataLen: xxxx',13,10,0
  1938.  
  1939.  
  1940.  
  1941. debug_print_rx_ip:
  1942.     mov     esi, rx_str + 4     ; The ip buffer address start
  1943.  
  1944.     mov     edi, IP_DATA1
  1945.  
  1946.     cmp     [esi+9], byte 1
  1947.     jne     rnICMP
  1948.     mov     eax,'ICMP'
  1949.     jmp     drp
  1950. rnICMP:
  1951.     cmp     [esi+9], byte 6
  1952.     jne     rnTCP
  1953.     mov     eax,'TCP '
  1954.     jmp     drp
  1955. rnTCP:
  1956.     cmp     [esi+9], byte 17
  1957.     jne     rnUDP
  1958.     mov     eax,'UDP '
  1959.     jmp     drp
  1960. rnUDP:
  1961.  
  1962. drp:
  1963.     mov     [edi], eax
  1964.  
  1965.     call    fillData
  1966.  
  1967.     ret
  1968.  
  1969.  
  1970. debug_print_tx_ip:
  1971.     mov     esi, ip_buff     ; The ip buffer address start
  1972.  
  1973.     mov     edi, IP_DATA1
  1974.  
  1975.     cmp     [esi+9], byte 1
  1976.     jne     tnICMP
  1977.     mov     eax,'ICMP'
  1978.     jmp     dtp
  1979. tnICMP:
  1980.     cmp     [esi+9], byte 6
  1981.     jne     tnTCP
  1982.     mov     eax,'TCP '
  1983.     jmp     dtp
  1984. tnTCP:
  1985.     cmp     [esi+9], byte 17
  1986.     jne     tnUDP
  1987.     mov     eax,'UDP '
  1988.     jmp     dtp
  1989. tnUDP:
  1990.  
  1991. dtp:
  1992.     mov     [edi], eax
  1993.  
  1994.     call    fillData
  1995.  
  1996.     ret
  1997.  
  1998.  
  1999. fillData:
  2000.     ; Display from IP
  2001.     mov     cl, [esi+12]
  2002.     mov     edx, 11
  2003.     call    wbyte               ; byte in cl, dest in edi+edx
  2004.     mov     cl, [esi+13]
  2005.     mov     edx, 13
  2006.     call    wbyte               ; byte in cl, dest in edi+edx
  2007.     mov     cl, [esi+14]
  2008.     mov     edx, 15
  2009.     call    wbyte               ; byte in cl, dest in edi+edx
  2010.     mov     cl, [esi+15]
  2011.     mov     edx, 17
  2012.     call    wbyte               ; byte in cl, dest in edi+edx
  2013.  
  2014.     ; Display to IP
  2015.     mov     cl, [esi+16]
  2016.     mov     edx, 24
  2017.     call    wbyte               ; byte in cl, dest in edi+edx
  2018.     mov     cl, [esi+17]
  2019.     mov     edx, 26
  2020.     call    wbyte               ; byte in cl, dest in edi+edx
  2021.     mov     cl, [esi+18]
  2022.     mov     edx, 28
  2023.     call    wbyte               ; byte in cl, dest in edi+edx
  2024.     mov     cl, [esi+19]
  2025.     mov     edx, 30
  2026.     call    wbyte               ; byte in cl, dest in edi+edx
  2027.  
  2028.     ; Only display extra data for TCP
  2029.     cmp     [esi+9], byte 6     ; TCP?
  2030.     je      nTCP
  2031.  
  2032.     ; display source port
  2033.     mov     [edi+32], byte 0
  2034.     mov     edi, IP_DATA2
  2035.     mov     [edi], byte 0
  2036.     ret
  2037.  
  2038. nTCP:
  2039.     mov     [edi+32], byte ' '
  2040.  
  2041.     mov     cl, [esi+20]
  2042.     mov     edx, 39
  2043.     call    wbyte               ; byte in cl, dest in edi+edx
  2044.     mov     cl, [esi+21]
  2045.     mov     edx, 41
  2046.     call    wbyte               ; byte in cl, dest in edi+edx
  2047.  
  2048.     mov     cl, [esi+22]
  2049.     mov     edx, 51
  2050.     call    wbyte               ; byte in cl, dest in edi+edx
  2051.     mov     cl, [esi+23]
  2052.     mov     edx, 53
  2053.     call    wbyte               ; byte in cl, dest in edi+edx
  2054.  
  2055.  
  2056.     mov     edi, IP_DATA2
  2057.     mov     [edi], byte 'S'
  2058.  
  2059.     mov     cl, [esi+24]
  2060.     mov     edx, 5
  2061.     call    wbyte               ; byte in cl, dest in edi+edx
  2062.     mov     cl, [esi+25]
  2063.     mov     edx, 7
  2064.     call    wbyte               ; byte in cl, dest in edi+edx
  2065.     mov     cl, [esi+26]
  2066.     mov     edx, 9
  2067.     call    wbyte               ; byte in cl, dest in edi+edx
  2068.     mov     cl, [esi+27]
  2069.     mov     edx, 11
  2070.     call    wbyte               ; byte in cl, dest in edi+edx
  2071.  
  2072.     mov     cl, [esi+28]
  2073.     mov     edx, 19
  2074.     call    wbyte               ; byte in cl, dest in edi+edx
  2075.     mov     cl, [esi+29]
  2076.     mov     edx, 21
  2077.     call    wbyte               ; byte in cl, dest in edi+edx
  2078.     mov     cl, [esi+30]
  2079.     mov     edx, 23
  2080.     call    wbyte               ; byte in cl, dest in edi+edx
  2081.     mov     cl, [esi+31]
  2082.     mov     edx, 25
  2083.     call    wbyte               ; byte in cl, dest in edi+edx
  2084.  
  2085.     mov     cl, [esi+33]
  2086.     and     cl, 0x3F
  2087.     mov     edx, 35
  2088.     call    wbyte               ; byte in cl, dest in edi+edx
  2089.  
  2090.     ; Display the size of the received packet
  2091.     mov     dh, [esi + 2]
  2092.     mov     dl, [esi + 3]
  2093.     sub     dx, 40
  2094.     mov     cl, dh
  2095.     mov     edx, 48
  2096.     call    wbyte               ; byte in cl, dest in edi+edx
  2097.     mov     dh, [esi + 2]
  2098.     mov     dl, [esi + 3]
  2099.     sub     dx, 40
  2100.     mov     cl, dl
  2101.     mov     edx, 50
  2102.     call    wbyte               ; byte in cl, dest in edi+edx
  2103.  
  2104.  
  2105.     ret
  2106.  
  2107.  
  2108. wbyte:  ; byte in cl, dest in edi+edx, edi unchanged
  2109.     xor     eax, eax
  2110.     mov     al, cl
  2111.     shr     al, 4
  2112.     mov     bl, [eax + hexchars]
  2113.     mov     [edi+edx], bl
  2114.     inc edx
  2115.     mov     al, cl
  2116.     and     al, 0x0f
  2117.     mov     bl, [eax + hexchars]
  2118.     mov     [edi+edx], bl
  2119.     ret
  2120.  
  2121. else
  2122. debug_output:
  2123.     ret
  2124. end if
  2125.  
  2126. ; DATA AREA
  2127.  
  2128.  
  2129. ; debug msgs
  2130. RX_IP               db  'R: ',0
  2131. TX_IP               db  'T: ',0
  2132. CRLF                db  13,10,0
  2133. RX_LCP_REQ          db  'RX_LCP_REQ',0
  2134. RX_LCP_ACK          db  'RX_LCP_ACK',0
  2135. RX_LCP_NAK          db  'RX_LCP_NAK',0
  2136. RX_LCP_REJ          db  'RX_LCP_REJ',0
  2137. RX_LCP_ECHO_REQ     db  'RX_LCP_ECHO_REQ',0
  2138. RX_PAP_ACK          db  'RX_PAP_ACK',0
  2139. RX_IPCP_REQ         db  'RX_IPCP_REQ',0
  2140. RX_IPCP_ACK         db  'RX_IPCP_ACK',0
  2141. RX_IPCP_NAK         db  'RX_IPCP_NAK ( IP Address assigned )',0
  2142. RX_CCP_REQ          db  'RX_CCP_REQ',0
  2143. TX_LCP_REQ          db  'TX_LCP_REQ',0
  2144. TX_PAP_REQ          db  'TX_PAP_REQ',0
  2145. TX_IPCP_REQ         db  'TX_IPCP_REQ',0
  2146.  
  2147.  
  2148. ; Labels for GUI buttons
  2149. button1_text        db  'DIAL'
  2150. button1_text_len    db  4
  2151. button3_text        db  'DISCONNECT'
  2152. button3_text_len    db  10
  2153.  
  2154. comport             dd  0
  2155. comirq              dd  0
  2156.  
  2157. ; Pointer to prompt shown to user
  2158. prompt              dd  0
  2159. prompt_len          db  0
  2160.  
  2161. ; Application Title
  2162. labelt              db  'PPP Dialer'
  2163. labellen:
  2164.  
  2165. txmsg:              db  'Tx bytes :'
  2166. txmsglen:
  2167. rxmsg:              db  'Rx bytes :'
  2168. rxmsglen:
  2169.  
  2170. timerValue          dd  0
  2171. sendwaitTime        dd  0
  2172.  
  2173.  
  2174. ; Prompts displayed to the user
  2175. welcomep            db  'Select an option below, see ppp.txt'
  2176. welcomep_len        db  35
  2177.  
  2178. dialfp              db  'Connect Failed...'
  2179. dialfp_len          db  17
  2180.  
  2181. connectedp          db  'Connected to Host'
  2182. connectedp_len      db  17
  2183.  
  2184. conp                db  'Connecting to Host'
  2185. conp_len            db  18
  2186.  
  2187. pppOnp              db  'PPP Started'
  2188. pppOnp_len          db  11
  2189.  
  2190. IPOnp               db  'IP Link established'
  2191. IPOnp_len           db  19
  2192.  
  2193. discp               db  'Disconnected from Host'
  2194. discp_len           db  22
  2195.  
  2196. hangp               db  'Hanging up Modem......'
  2197. hangp_len           db  22
  2198.  
  2199. PPPconSend          db  0x7e,0xff,0x7d,0x23,0x08,0x08,0x08,0x08,0
  2200. PPPconWait          db  '~~',0
  2201. hangupWait          db  'ATZ',0
  2202. hangupSend          db  '|||+++|||',10,13,'ATH',10,13,'|ATZ',10,13,0
  2203.  
  2204. ; Shrirang 2/5/03
  2205.  
  2206. abortres:           times(50) db 0
  2207. abortcnt                      db 0
  2208.  
  2209. ;--!
  2210.  
  2211. LCPREQStr db 0x0e,0x02,0x06,0x00, 0x0a, 0x00, 0x00, 0x07, 0x02, 0x08, 0x02
  2212. PAPREQStr           db 14, 4, 'free', 4, 'free'
  2213. IPCPREQStr          db 10, 3, 6, 0, 0, 0, 0
  2214.  
  2215. irqtable:           dd  0x3f8 + 0x01000000  ; read port 0x3f8, byte
  2216.       dd  0
  2217.       dd  0
  2218.       dd  0
  2219.       dd  0
  2220.       dd  0
  2221.       dd  0
  2222.       dd  0
  2223.       dd  0
  2224.       dd  0
  2225.       dd  0
  2226.       dd  0
  2227.       dd  0
  2228.       dd  0
  2229.       dd  0
  2230.       dd  0
  2231. checksum1           dd  0
  2232. checksum2           dd  0
  2233. packet              dd  0
  2234. state               dd  0
  2235. extended            dd  0
  2236. number              dd  0
  2237. tx_end              dd  0
  2238. tx_ptr              dd  0
  2239. rx_ptr              dd  0
  2240. addr1               db  0
  2241. addr2               db  0
  2242. addr3               db  0
  2243. addr4               db  0
  2244. rxbytes             dd  0
  2245. txbytes             dd  0
  2246.  
  2247.  
  2248. ; End of application code and data marker
  2249.  
  2250. I_END:
  2251.  
  2252. rx_str:             rb MaxRx + 1
  2253. tx_str:             rb MaxTx + 1
  2254. ip_buff:            rb 1500
  2255.  
  2256.