Subversion Repositories Kolibri OS

Rev

Rev 109 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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