Subversion Repositories Kolibri OS

Rev

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

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