-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.asm
3607 lines (3442 loc) · 108 KB
/
main.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
NAME mssker
; File MSSKER.ASM
include symboldefs.h
; Edit history
; 20 Mar 1998 version 3.16
; Last edit
; 23 Apr 1999
;****************************** Version 3.16 *****************************
; KERMIT, Celtic for "free"
;
; The name "Kermit" is a registered trade mark of Henson Associates, Inc.,
; used by permission.
;
; MS-DOS Kermit Program Version 3.16 alpha, Feb 98
; MS-DOS Kermit Program Version 3.15 15 Sept 97
; MS-DOS Kermit Program Version 3.14, 18 Jan 95
; MS-DOS Kermit Program Version 3.13, 8 July 93
; MS-DOS Kermit Program Version 3.12, Feb 1992
; MS-DOS Kermit Program Version 3.11, 6 Sept 1991
; MS-DOS Kermit Program Version 3.10, 2 March 1991
; MS-DOS Kermit Program Version 3.02, development for 3.10, 1990-91
; MS-DOS Kermit Program Version 3.01, 20 March 1990
; MS-DOS Kermit Program Version 3.00, 16 Jan 1990
; Kermit-MS Program Version 2.32, 11 Dec 1988
; Kermit-MS Program Version 2.31, 1 July 1988
; Kermit-MS Program Version 2.30, 1 Jan 1988
; Kermit-MS Program Version 2.29, 26 May 1986, plus later revisions.
; Kermit-MS Program Version 2.27, December 6,1984
; Kermit-MS Program Version 2.26, July 27, 1984
; PC-Kermit Program Version 1.20, November 4, 1983
; PC-Kermit Program Version 1.0, 1982
;
; Based on the Columbia University KERMIT Protocol.
;
; Copyright (C) 1982, 1999, Trustees of Columbia University in the
; City of New York. The MS-DOS Kermit software may not be, in whole
; or in part, licensed or sold for profit as a software product itself,
; nor may it be included in or distributed with commercial products
; or otherwise distributed by commercial concerns to their clients
; or customers without written permission of the Office of Kermit
; Development and Distribution, Columbia University. This copyright
; notice must not be removed, altered, or obscured.
;
; Original Authors (versions 1.0 through 2.28):
; Daphne Tzoar, Jeff Damens
; Columbia University Center for Computing Activities
; 612 West 115th Street
; New York, NY 10025
;
; Present author (version 2.29, 2.30, 2.31, 2.32, 3.00, 3.01, 3.02,
; 3.10, 3.11, 3.12, 3.13, 3.14):
; Joe R. Doupnik
; Dept of EE, and CASS
; Utah State University
; Logan, UT 84322, USA
; E-Mail: JRD@CC.USU.EDU (Internet), JRD@USU (BITNET)
;
; Special thanks to Christine Gianone, Frank da Cruz, Bill Catchings,
; Bernie Eiben, Vace Kundakci, Terry Kennedy, Jack Bryans, and many many
; others for their help and contributions.
public dosnum, curdsk, fpush, isfile, sbrk, crun, errlev
public takrd, takadr, taklev, filtst, maxtry, dskspace, thsep, tdfmt
public lclsusp, lclrest, lclexit, cwdir, kstatus, verident, cdsr
public spath, patched, getenv, psp, dosctty, patchid, retcmd
public tcptos, emsrbhandle, emsgshandle, apctrap, cboff, cbrestore
public startup, cmdfile, inidir, tmpbuf, malloc, dostemp
public breakcmd, xms, xmsrhandle, xmsghandle, xmsep
env equ 2CH ; environment address in psp
cline equ 80H ; offset in psp of command line
braceop equ 7bh ; opening curly brace
bracecl equ 7dh ; closing curly brace
_STACK SEGMENT ; our stack
dw 1500+1024 dup (0) ; for TCP code
dw 200 dup(0) ; for main Kermit code
msfinal label word ; top of stack
_STACK ENDS
data segment
extrn buff:byte, comand:byte, flags:byte, trans:byte, prmptr:word
extrn machnam:byte, decbuf:byte, rstate:byte, sstate:byte
extrn mcctab:byte, rdbuf:byte, takeerror:byte, macroerror:byte
extrn dos_bottom:byte, domath_ptr:word, domath_cnt:word
extrn domath_msg:word, oldifelse:byte, retbuf:byte
verident label byte
verdef
patchena db '$patch level'
patchid db ' 0 $'
copyright db cr,lf
db 'Copyright (C) Trustees of Columbia University 1982, 2000.'
db cr,lf,'$'
copyright2 db cr,lf,lf
db ' Copyright (C) 1982, 2000, Trustees of Columbia University in the'
db cr,lf
db ' City of New York. The MS-DOS Kermit software may not be, in whole'
db cr,lf
db ' or in part, licensed or sold for profit as a software product itself,'
db cr,lf
db ' nor may it be included in or distributed with commercial products'
db cr,lf
db ' or otherwise distributed by commercial concerns to their clients'
db cr,lf
db ' or customers without written permission of the Office of Kermit'
db cr,lf
db ' Development and Distribution, Columbia University. This copyright'
db cr,lf
db ' notice must not be removed, altered, or obscured.'
db cr,lf,'$'
hlpmsg db cr,lf,'Type ? or HELP for help',cr,lf,'$'
crlf db cr,lf,'$'
patpmt db 0
ermes1 db cr,lf,'?More parameters are needed$'
ermes2 db cr,lf,'?Unable to initialize memory$'
ermes3 db cr,lf,'?Command canceled$'
ermes4 db '?Unable to change directory',0 ; asciiz
ermes5 db cr,lf,'?Unable to complete initialization process$'
ermes6 db cr,lf,'Ignoring patch file.'
db ' Version number mismatch.',cr,lf,'$'
ermes7 db cr,lf,'Patch file was not found',cr,lf,'$'
ermes8 db cr,lf,'Fatal error in patch file! Please remove PATCH '
db 'command.',cr,lf,'$'
erms30 db cr,lf,'?Passed maximum nesting level for TAKE command$'
erms31 db cr,lf,'?Cannot find Take-file: $'
erms34 db cr,lf,'This program requires DOS 2.0 or above$'
erms37 db cr,lf,'?Unable to execute command interpreter $'
erms38 db cr,lf,' Not an 8250 UART at this COM port$'
erms39 db cr,lf,' UART tests ok$'
badnam db cr,lf,'?No such file(s)$'
ifdef no_graphics
nographics db ' No graphics$'
endif ; no_graphics
ifdef no_network
nonet db ' No network$'
else
ifdef no_tcp
notcp db ' No tcp/ip$'
endif ; no_tcp
endif ; no_network
ifdef no_terminal
noterm db ' No terminal$'
endif ; no_terminal
msgif db cr,lf,' IF extensions are ',0
msggraph db cr,lf,' Graphics is ',0
msgtcpip db cr,lf,' TCP/IP is ',0
msgnetwork db cr,lf,' Network is ',0
msgterm db cr,lf,' Terminal emulation is ',0
msgnot db 'not ',0
msgavail db 'available$',0
xms xmsreq <> ; XMS request block
takepause db ' Take debug, press a key to continue, Control-C to quit$'
data ends
data1 segment
filmsg db ' Filename$'
dskmsg db ' disk drive letter or Return$'
pthmsg db ' Name of new working directory and/or disk$'
runmsg db ' program name and command line$'
pathlp db ' optional path for file mskermit.pch$'
stophlp db ' Status value to be returned msg, nothing if no new value$'
setenvhlp db ' name=string phrase to be put into DOS master environment$'
tophlp db cr,lf
db ' Ask, Askq (read keybd to variable) '
db ' Pause [secs], MPause/Msleep [millisec]'
db cr,lf
db ' APC text send App Prog Cmd to host'
db ' Pop, End (exit current macro/Take file)'
db cr,lf
db ' Bye (logout remote server) '
db ' Push (go to DOS, keep Kermit)'
db cr,lf
db ' C or Connect (become a terminal) '
db ' Quit (leave Kermit)'
db cr,lf
db ' Check (graphics, tcp/ip, networks) '
db ' R or Receive (opt local filename)'
db cr,lf
db ' Clear (Input, comms recv buffer) '
db ' Read (line from a file to variable)'
db cr,lf
db ' Close (logging and script file) '
db ' Reget (get rest of a partial file)'
db cr,lf
db ' CLS (clear screen at command level)'
db ' Reinput (script Input, reread buffer)'
db cr,lf
db ' CWD or CD (change dir &/or disk) '
db ' Remote (prefix for commands)'
db cr,lf
db ' Decrement/Increment variable number'
db ' Replay (file through term emulator)'
db cr,lf
db ' Define/Assign (a command macro) '
db ' Reset (clock)'
db cr,lf
db ' Delete (a file) '
db ' Retrieve (get files, delete source) '
db cr,lf
db ' Dial (phone number) '
db ' Return text (from macro to \v(return))'
db cr,lf
db ' Directory (filepsec) '
db ' Run (a program)'
db cr,lf
db ' Disable (selected server commands)'
db ' S, Send, Resend, Psend local new-name'
db cr,lf
db ' Echo text (show line on screen) '
db ' Server [timeout] (become a server)'
db cr,lf
db ' Else (follows IF statment) '
db ' Set (most things)'
db cr,lf
db ' Enable (selected server commands)'
db ' Setenv name=string to DOS environment'
db cr,lf
db ' EXIT (leave Kermit) '
db ' Show (most things)'
db cr,lf
db ' Finish (to remote server) '
db ' Sleep time (wait, no comms echos)'
db cr,lf
db ' For var start stop step {commands} '
db ' Space (free on current disk)'
db cr,lf
db ' Get (remote file opt new name)'
db ' Stop (exit all Take files & macros)'
db cr,lf
db ' Getc (read 1 byte from kbd to var)'
db ' Switch index {:label, cmds,...}'
db cr,lf
db ' GetOK (get Yes, OK, No response)'
db ' Take (commands from a file)'
db cr,lf
db ' Goto (label, Take file or Macro)'
db ' Telnet host port NEW or RESUME'
db cr,lf
db ' Hangup (drop DTR, hang up phone) '
db ' Test COM1 ... COM4 (check for UART)'
db cr,lf
db ' If [not] <condition> <command> '
db ' Transmit filespec [prompt] (raw upload)'
db cr,lf
db ' I or Input [timeout] text (scripts)'
db ' Type (a file)'
db cr,lf
db ' INTRO introduction to Kermit '
db ' Version (show version and copyright)'
db cr,lf
db ' Log (Packet, Session, Transaction) '
db ' Wait [timeout] on modem \cd \cts \dsr'
db cr,lf
db ' Mail (file to host Mailer) '
db ' While <condition> {commands}'
db cr,lf
db ' Minput (Input with many patterns)'
db ' Write/Writeln FILE or log file text'
db cr,lf
db ' Move (send files, delete source)'
db ' Undefine (macro or array element)'
db cr,lf
db ' Open Read/Write/Append file '
db ' Xecho string (without leading cr/lf)'
db cr,lf
db ' Output text (to comms channel)'
db ' Xif <condition> {cmds} ELSE {cmds}'
db '$'
qckhlp db cr,lf
db 'MS-DOS Kermit 3.16, 31 Oct 2000, Copyright (C) 1982, 2000,'
db cr,lf
db 'Trustees of Columbia University in the City of New York.'
db cr,lf,lf
db 'Important commands (type the command, then press the'
db ' Enter key):'
db cr,lf,lf
db ' INTRO - For an introduction to MS-DOS Kermit.'
db cr,lf
db ' VERSION - For version and copyright information.'
db cr,lf
db ' EXIT - To leave MS-DOS Kermit.'
db cr,lf,lf
db 'Press the question-mark (?) key for context-sensitive'
db ' help'
db cr,lf
db ' at any point within a command.'
db cr,lf,lf
db 'DOCUMENTATION:'
db cr,lf
db ' "Using MS-DOS Kermit" by Christine M. Gianone,'
db cr,lf
db ' Digital Press / Butterworth-Heinemann, 1992, ISBN'
db ' 1-55558-082-3.'
db cr,lf
db ' Please purchase this manual - it shows you how to use'
db ' the software,'
db cr,lf
db ' it answers your questions, and its sales support the'
db ' Kermit effort.'
db cr,lf
db ' To order, call +1 212 854-3703 or +1 800 366-2665.'
db cr,lf,lf
db 'And see these files on your Kermit diskette for additional'
db ' information:'
db cr,lf
db ' KERMIT.UPD - New features and updates.'
db cr,lf
db ' KERMIT.BWR - Hints and tips, troubleshooting information,'
db ' etc.'
db cr,lf
db ' KERMIT.HLP - Concise descriptions of each command.'
db cr,lf,'$'
ifndef no_terminal
intrhlp db cr,lf
db ' Introduction to MS-DOS Kermit',cr,lf
db 'o An MS-Kermit command is a line of words separated by spaces and'
db ' ending with',cr,lf,' a carriage return <the Enter key>.'
db ' Example: SET SPEED 2400<Enter>',cr,lf
db 'o Most words can be abbreviated and can be completed by pressing'
db ' the Esc key.',cr,lf
db ' Example: SET SPE 24<Enter> or even SET SPE<Esc> 24<Esc>'
db '<Enter>',cr,lf
db 'o Help (detailed, specific): press the "?" key where a word would'
db ' appear.',cr,lf
db 'o Edit lines using the Backspace key to delete characters,'
db ' Control-W to delete',cr,lf
db ' words, and Control-U to delete the line. Control-C cancels the'
db ' command.',cr,lf
db 'o Frequently used MS-Kermit commands:',cr,lf
db ' EXIT Leave the Kermit program. QUIT does the same'
db ' thing.',cr,lf
db ' SET PORT, PARITY, SPEED, TERMINAL and many other'
db ' parameters.',cr,lf
db ' SHOW Display groups of important parameters.'
db ' SHOW ? for categories.',cr,lf,lf
db ' CONNECT Establish a terminal connection to a remote'
db ' system or a modem.',cr,lf
db ' Control-'
; labels where Connect mode escape printable goes (twice)
intrhlp1 db ' C (Control-'
intrhlp2 db ' '
db ' followed by "C") Return to MS-Kermit> prompt.',cr,lf,lf
db ' SEND filename Send the file(s) to Kermit on the other'
db ' computer.',cr,lf
db ' RECEIVE Receive file(s), SEND them from Kermit on the'
db ' other computer.',cr,lf
db ' GET filename Ask the remote Kermit server to send the file(s)'
db ' to us.',cr,lf
db ' FINISH Shut down remote Kermit but stay logged into'
db ' remote system.',cr,lf
db ' BYE FINISH and logout of remote system and exit'
db ' local Kermit.',cr,lf
db 'o Common startup sequence: SET SPEED 9600, CONNECT, login, start'
db ' remote Kermit,',cr,lf
db ' put it into Server mode, escape back with Control-C, transfer'
db ' files with',cr,lf
db ' SEND x.txt, GET b.txt, BYE.'
db cr,lf,lf
db ' MS-DOS Kermit commands, a functional summary:'
db cr,lf
db cr,lf,' Local file management: '
db 'Kermit program management:'
db cr,lf,' DIR (list files) '
db ' EXIT (from Kermit, return to DOS)'
db cr,lf,' CD (change directory) '
db ' QUIT (same as EXIT)'
db cr,lf,' DELETE (delete files) '
db ' TAKE (execute Kermit commands from file)'
db cr,lf,' RUN (a DOS command) '
db ' CLS (clear screen)'
db cr,lf,' TYPE (display a file) '
db ' PUSH (enter DOS, EXIT returns to Kermit)'
db cr,lf,' SPACE (show disk space) '
db ' Ctrl-C (interrupt a command)'
db cr,lf
db cr,lf,' Communication settings: '
db 'Terminal emulation:'
db cr,lf,' SET PORT, SET SPEED '
db ' CONNECT (begin terminal emulation)'
db cr,lf,' SET PARITY '
db ' HANGUP (close connection)'
db cr,lf,' SET FLOW-CONTROL '
db ' Alt-X (return to MS-Kermit> prompt)'
db cr,lf,' SET LOCAL-ECHO '
db ' SET KEY (key mapping)'
db cr,lf,' SET ? to see others '
db ' SET TERMINAL TYPE, BYTESIZE, other parameters'
db cr,lf,' SHOW COMMUNICATIONS, MODEM '
db ' SHOW TERMINAL, SHOW KEY'
db cr,lf
db cr,lf,' File transfer settings: '
db cr,lf,' SET FILE CHARACTER-SET name '
db ' SET TRANSFER CHARACTER-SET'
db cr,lf,' SET FILE TYPE TEXT, BINARY '
db ' SET SEND or RECEIVE parameters'
db cr,lf,' SET FILE ? to see others '
db ' SET WINDOWS (sliding windows)'
db cr,lf,' SHOW FILE '
db ' SHOW PROTOCOL, SHOW STATISTICS'
db cr,lf,lf
db cr,lf,' Kermit file transfer: '
db 'ASCII file transfer:'
db cr,lf,' SEND files (to RECEIVE) '
db ' LOG SESSION, CLOSE SESSION (download)'
db cr,lf,' RECEIVE (from SEND) '
db ' TRANSMIT (upload)'
db cr,lf,' MAIL files (to RECEIVE) '
db ' SET TRANSMIT parameters'
db cr,lf
db cr,lf,' Using a Kermit server: '
db 'Being a kermit server:'
db cr,lf,' GET files (from server) '
db ' SET SERVER TIMEOUT or LOGIN'
db cr,lf,' SEND or MAIL (to server) '
db ' ENABLE or DISABLE features'
db cr,lf,' REMOTE command (to server) '
db ' SERVER'
db cr,lf,' FINISH, LOGOUT, BYE '
db ' SHOW SERVER'
db cr,lf
db cr,lf,' Script programming commands: '
db cr,lf,' INPUT, REINPUT secs text '
db ' :label, GOTO label'
db cr,lf,' OUTPUT text '
db ' IF [ NOT ] condition command'
db cr,lf,' DECREMENT or INCREMENT variable number'
db cr,lf,' ASK or ASKQ variable prompt '
db ' OPEN READ (or WRITE or APPEND) file'
db cr,lf,' DEFINE variable or macro '
db ' READ variable-name'
db cr,lf,' ASSIGN variable or macro '
db ' WRITE file-designator text'
db cr,lf,' [ DO ] macro arguments '
db ' CLOSE READ or WRITE file or logfile'
db cr,lf,' ECHO text '
db ' END or POP from macro or file'
db cr,lf,' PAUSE time '
db ' STOP all macros and command files'
db cr,lf,' SLEEP time no comms sampling'
db ' WRITE file-designator text'
db cr,lf,' WAIT time modem-signals '
db ' SHOW VARIABLES, SHOW SCRIPTS, SHOW MACROS'
db cr,lf
db ' Use "?" within comands for help on what fits that word.$'
endif ;; ifndef no_terminal
kpath db 64 dup (0) ; Kermit's paths to Kermit files
data1 ends
data segment
comtab db 106 - 1 ; COMND tables
mkeyw 'APC',scapc
mkeyw 'Asg',assign ; synonym
mkeyw 'Ask',ask
mkeyw 'Askq',askq
mkeyw '_assign',hide_assign ; hidden, expand destination name
mkeyw 'Assign',assign
mkeyw 'Break',breakcmd
mkeyw 'Bye',bye
mkeyw 'C',telnet
mkeyw 'CD',cwdir
mkeyw 'Clear',scclr
mkeyw 'Close',clscpt
mkeyw 'Check',check
mkeyw 'Comment',comnt
mkeyw 'Connect',telnet
mkeyw 'Continue',continue
mkeyw 'CLS',cls
mkeyw 'CWD',cwdir
mkeyw 'Declare',declare
mkeyw '_define',hide_define ; hidden, expand destination name
mkeyw 'Define',dodef
mkeyw 'Dec',decvar ; decrement vs declare resolver
mkeyw 'Decrement',decvar
mkeyw 'Delete',delete
mkeyw 'Dial',dial
mkeyw 'Directory',direct
mkeyw 'Disable',srvdsa
mkeyw 'Do',docom
mkeyw 'Echo',scecho
mkeyw 'Else',elsecmd
mkeyw 'Enable',srvena
mkeyw 'End',popcmd
mkeyw 'Exit',exit
mkeyw 'Finish',finish
mkeyw '_forinc',_forinc ; hidden, FOR statement incrementer
mkeyw 'For',forcmd
mkeyw 'Forward',sforward ; hidden "Forward" goto
mkeyw 'Get',get
mkeyw 'G',get ; hidden synomym for Get
mkeyw 'Ge',get ; ditto
mkeyw 'Getc',getc
mkeyw 'Getok',getok
mkeyw 'goto',sgoto
mkeyw 'H',help
mkeyw 'Hangup',dtrlow
mkeyw 'Help',help
mkeyw 'If',ifcmd
mkeyw 'I',scinp
mkeyw 'Increment',incvar
mkeyw 'Input',scinp
mkeyw 'INTRO',intro
mkeyw 'Local',localmac
mkeyw 'Log',setcpt
mkeyw 'Mail',mail
mkeyw 'Minput',scminput
mkeyw 'Move',move
mkeyw 'Mpause',scmpause
mkeyw 'Msleep',scmpause
mkeyw 'Open',vfopen
mkeyw 'O',scout ; hidden synomym for OUTPUT
mkeyw 'Output',scout
mkeyw 'Pause',scpau
mkeyw 'Pop',popcmd
mkeyw 'Psend',psend
mkeyw 'Push',dopush
mkeyw 'Quit',exit
mkeyw 'R',read
mkeyw 'Read',vfread
mkeyw 'Receive',read
mkeyw 'Reget',reget
mkeyw 'Reinput',screinp
mkeyw 'Remote',remote
mkeyw 'Replay',replay
mkeyw 'Resend',resend
mkeyw 'Reset',reset
mkeyw 'Retrieve',retrieve
mkeyw 'Return',retcmd
mkeyw 'Run',run
mkeyw 'S',send
mkeyw 'Send',send
mkeyw 'Server',server
mkeyw 'Set',setcom
mkeyw 'Setenv',setenv
mkeyw 'Show',showcmd
mkeyw 'Sleep',scsleep
mkeyw 'Space',chkdsk
mkeyw 'Statistics',shosta
mkeyw 'Stay',stay
mkeyw 'Stop',takeqit
mkeyw 'Switch',switch
mkeyw 'Take',take
mkeyw 'Test',testcom
mkeyw 'Transmit',scxmit
mkeyw 'xmit',scxmit ; hidden synonym
mkeyw 'Type',typec
mkeyw 'Undefine',undefine
mkeyw 'Version',prvers
mkeyw 'Wait',scwait
mkeyw 'While',whilecmd
mkeyw 'Write',write
mkeyw 'Writeln',writeln
mkeyw 'Xecho',xecho
mkeyw 'XIF',xifcmd
mkeyw ':',comnt ; script labels, do not react
mkeyw 'Patch',patch
mkeyw 'Nopush',pushproc ; must be hidden
ifdef no_network
shotab db 19 - 2 ; SHOW keyword
else
ifndef no_tcp
shotab db 19 ; SHOW keyword
else
shotab db 19 - 1 ; SHOW keyword
endif ; no_tcp
endif ; no_network
mkeyw 'array',sharray
mkeyw 'Communications',shcom
mkeyw 'Control-prefixing',cntlsho
mkeyw 'File',shfile
mkeyw 'Key',shokey
mkeyw 'Logging',shlog
mkeyw 'Macros',shomac
mkeyw 'Memory',shmem
mkeyw 'Modem',shomodem
ifndef no_network
mkeyw 'Network',shownet
endif ; no_network
mkeyw 'Protocol',shpro
mkeyw 'Scripts',shscpt
mkeyw 'Server',shserv
ifndef no_tcp
mkeyw 'Sessions',sesdisp ; TCP/IP
endif ; no_tcp
mkeyw 'Statistics',shosta
mkeyw 'Status',status
mkeyw 'Terminal',shterm
mkeyw 'Translation',shorx
mkeyw 'Variables',shovar
; Kermit initing from Environment
nulprmpt db 0,0,0 ; null prompt
initab db 8 ; Environment phrase dispatch table
mkeyw 'INPUT-buffer-length',setinpbuf ; Script INPUT buffer length
mkeyw 'Rollback',setrollb ; number of Terminal rollback screens
mkeyw 'Width',setwidth ; columns in rollback buffer, def=80
mkeyw 'COM1',com1port
mkeyw 'COM2',com2port
mkeyw 'COM3',com3port
mkeyw 'COM4',com4port
mkeyw 'Path',mkkpath
featab db 5 ; Compiled-in feature list for CHECK cmd
mkeyw 'if',5
mkeyw 'graphics',1
mkeyw 'networks',3
mkeyw 'tcp',2
mkeyw 'terminals',4
chktab db 4 ; table of comm ports for TEST
mkeyw 'COM1',1
mkeyw 'COM2',2
mkeyw 'COM3',3
mkeyw 'COM4',4
patched db 1 ; 1 = enable patching; 0 = disable or done
even
lclsusp dw 0 ; address of routine to call when going to DOS
lclrest dw 0 ; address of routine to call when returning
lclexit dw 0 ; address of routine to call when exiting
tcptos dw 0 ; top of stack for TCP code
ssave dd 0 ; Original SS:SP when doing Command.com
in3ad dw 0,0 ; Original break interrupt addresses
ceadr dd 0 ; DOS Critical Error interrupt address
orgcbrk db 0 ; original Control-Break Check state
psp dw 0 ; segment of Program Segment Prefix
exearg dw 0 ; segment addr of environment (filled in below)
dd 0 ; ptr to cmd line (filled in below)
dw 5ch,0,6ch,0 ; our def fcb's; segment filled in later
emsrbhandle dw -1 ; EMS rollback handle, -1 means invalid
emsgshandle dw -1 ; EMS graphics handle, -1 means invalid
xmsrhandle dw 0 ; XMS rollback buffer handle, 0 = invalid
xmsghandle dw 0 ; XMS graphics memory buffer handle
xmsep dd 0 ; XMS manager entry point, 0 = invalid
dosnum dw 0 ; dos version number, major=low, minor=high
dosctty db 0 ; !=0 if DOS attempts using our comms line
curdsk db 0 ; Current disk
origd db 0 ; Original disk
orgdir db 64 dup (0) ; original directory on original disk
startup db 64 dup (0) ; our startup directory
cmdfile db 64 dup (0) ; path and file of last TAKE
inidir db 64 dup (0) ; mskermit.ini directory (ends on \)
taklev db 0 ; Take levels
takadr dw takstr-(size takinfo) ; Pointer into structure
takstr db (size takinfo) * maxtak dup(0)
cmdlinetake db 0 ; non-zero if have DOS command line cmds
filtst filest <> ; file structure for procedure isfile
maxtry db defmxtry ; Retry limit for data packet send/rcv
ininm2 db 'MSKERMIT.INI',0 ; init file name
ifdef nls_portuguese
ptchnam db 'MSRP315.PCH',0 ; Portuguese
else
ifdef no_terminal
ifdef no_network
ptchnam db 'MSRL315.PCH',0 ; MSK Lite
else
ptchnam db 'MSRN315.PCH',0 ; MSK medium-lite
endif
else
ifdef no_network
ptchnam db 'MSRM315.PCH',0 ; MSK medium
else
ptchnam db 'MSR315.PCH',0 ; main patch file name (Version dependent)
endif
endif
endif
ptchnam2 db 'MSKERMIT.PCH',0 ; alternate patch file name
delcmd db ' del ',0 ; delete command
dircmd db ' dir ',0 ; directory command
typcmd db ' type ',0 ; type command
kerenv db 'KERMIT=',0,0 ; Kermit= environment variable, + 2 nulls
pthnam db 'PATH=' ; Path environment variable
pthlen equ $-pthnam ; length of that string
pthadr dw 0 ; offset of PATH= string
dostempname db 'TEMP=' ; DOS TEMP= enviroment string
dostempnlen equ $ - dostempname ; string length
dostemp db ' > ',60 dup (0) ; " > " contents of TEMP= "\$kermit$.tmp"
tmpname db '$kermit$.tmp',0 ; path must start on dostemp+3
slashc db ' /c ' ; slashc Must directly preceed tmpbuf
tmpbuf db 128 dup (0) ; temp space for file names and comments
cmspnam db 'COMSPEC=' ; Environment variable
cmsplen equ $-cmspnam
cmspbuf db '\command.com',30 dup (0) ; default name plus additional space
shellnam db 'SHELL=' ; Environment variable
shellen equ $-shellnam
shellbuf db 40 dup (0) ; buffer for name
eexit db cr,'exit',cr
leexit equ $-eexit
onexit db 8,0,'ON_EXIT',CR ; <length>on_exit macro name
onexlen equ $-onexit-2-1 ; length of name
mfmsg db '?Not enough memory to run Kermit$'
mf7msg db '?Attempted to allocate a corrupted memory area$'
spcmsg db ' bytes available on drive '
spcmsg1 db ' :',cr,lf,0
spcmsg2 db cr,lf,' Drive '
spcmsg3 db ' : is not ready',0
moremsg db '... more, press a key to continue ...$'
errlev db 0 ; DOS errorlevel to be returned
kstatus dw 0 ; command execution status (0 = success)
thsep db 0 ; thousands separator
tdfmt db 0 ; date/time format code
totpar dw 0
apctrap db 0 ; disable command if done via APC
pttemp db 0 ; Patch temp variable
temp dw 0
tempptr dw 0
seekptr dw 0,0 ; pointer for lseek in takeread
nopush_flag db 0 ; nz = stops push/run, keep hidden
segstr db 'ABCDEFG' ; segment "names" for patcher
lsegstr equ $-segstr
even
segtab dw code ; segment values for patcher
dw code1
dw code2
dw data
dw data1
dw _TEXT
dw dgroup
data ends
code1 segment
extrn fparse:far, iseof:far, strlen:far, strcpy:far, prtscr:far
extrn strcat:far, prtasz:far, domath:far, decout:far, poplevel:far
assume cs:code1
code1 ends
code segment
extrn reget:near, mail:near, shovar:near, scapc:near
extrn bye:near, telnet:near, finish:near, comnd:near, prompt:near
extrn read:near, remote:near, send:near, status:near, get:near
extrn serrst:near, setcom:near, dtrlow:near, cmblnk:near, getc:near
extrn clscpi:near, clscpt:near, scpini:near, setrollb:near
extrn dodef:near, setcpt:near, docom:near, shomodem:near
extrn server:near, lclini:near, shokey:near, shomac:near, shosta:near
extrn shserv:near, initibm:near, forcmd:near, _forinc:near
extrn shorx:near, lnout:near, lnouts:near, scminput:near
extrn scout:near,scinp:near,scpau:near,scecho:near,scclr:near
extrn scxmit:near, scwait:near, srvdsa:near, srvena:near
extrn shcom:near, shlog:near, shpro:near, shterm:near, shscpt:near
extrn shfile:near, takclos:far, ask:near, askq:near
extrn assign:near, sgoto:near, screinp:near, ifcmd:near, write:near
extrn setinpbuf:near, shmem:near, replay:near, xifcmd:near
extrn com1port:near, com2port:near, com3port:near
extrn com4port:near, popcmd:near, mprompt:near, locate:near
extrn vfopen:near, vfread:near, decvar:near, incvar:near
extrn setwidth:near, scmpause:near, whilecmd:near, reset:near
extrn getok:near, cntlsho:near, shownet:near, ctlu:near
extrn resend:near, psend:near, tstport:near, scsleep:near
extrn takopen_file:far, takopen_macro:far, sforward:near
extrn hide_assign:near, hide_define:near, dial:near, declare:near
extrn sharray:near, localmac:near, switch:near, move:near
extrn retrieve:near, undefine:near, xecho:near, writeln:near
ifndef no_tcp
extrn sesdisp:near
endif ; no_tcp
assume cs:code, ds:data, ss:_stack, es:nothing
START PROC FAR
mov ax,data ; initialize DS
mov ds,ax
mov psp,es ; remember psp address
mov ah,dosver ; get DOS version number (word)
int dos
xchg ah,al ; major version to ah
mov dosnum,ax ; remember dos version
cmp ax,200h ; earlier than DOS 2.0?
jge start1 ; ge = no
mov ah,prstr
mov dx,offset erms34 ; complain
int dos
push psp ; set up exit for DOS 1
xor ax,ax ; and the IP
push ax ; make return addr of psp:0 for DOS 1
ret ; and return far to exit now
start1: call memini ; initialize our memory usage
mov ah,setdma ; set disk transfer address
mov dx,offset buff
int dos
call far ptr setint ; ^C, DOS critical error interrupts
mov ah,gcurdsk ; get current disk
int dos
inc al ; make 1 == A (not zero)
mov curdsk,al
mov origd,al ; remember original disk we started on
mov si,offset orgdir ; place for directory path w/o drive code
add al,'A'-1 ; make al alphabetic disk drive again
mov [si],al ; put it into original path descriptor
inc si
mov byte ptr [si],':' ; add drive specifier too
inc si
mov byte ptr [si],'\' ; add root indicator as well
inc si
mov ah,gcd ; get current directory (path really)
xor dl,dl ; use current drive
int dos
call getpath ; get the path from the environment
call gettsep ; get thousands separator, t/date code
mov ah,gswitch
xor al,al ; pick up switch character
int dos
mov slashc+1,dl
and maxtry,3fh ; limit # packet retries
mov bx,4 ; PRN handle for DOS
mov ah,ioctl
mov al,0 ; get info to
int dos
or dl,20h ; turn on binary mode
xor dh,dh
mov ah,ioctl
mov al,1 ; set info
int dos
call getcsp ; get comspec from environment
call getssp ; get shellspec from environment
call getdostemp ; get DOS TEMP= string
mov dx,offset dostemp
call strlen ; length so far
cmp cx,3 ; just ' > '?
je start1c ; e = yes, no TEMP= in environment
mov bx,dx ; string so far
add bx,cx ; last byte + 1
cmp byte ptr [bx-1],'\' ; ends on slash?
je start1c ; e = yes
mov word ptr [bx],'\'+0 ; append slash and null terminator
start1c:mov di,dx ; destination of dostemp
mov si,offset tmpname ; redirection filename
call strcat ; append
call getargv ; get directory where we started
call getparm ; read "KERMIT=" Environment line
jc start1b ; c = fatal error
xor cl,cl ; counter, starts at 0
start1a:mov bx,offset kerenv+6 ; append "<digit>=" to "KERMIT"
mov [bx],cl ; binary digit
inc cl
add byte ptr [bx],'0' ; to ascii
mov byte ptr [bx+1],'=' ; append equals sign
call getparm ; read "KERMITn=" Environment line
jc start1b ; c = fatal error
cmp cl,9 ; done all digits?
jbe start1a ; be = no
call scpini ; initialize script routines
jc start1b ; c = fatal error
call lclini ; do local initialization
cmp flags.extflg,0 ; exit now?
je start2 ; e = no
start1b:mov ah,prstr ; announce our premature exit
mov dx,offset ermes5 ; can't complete initialization
int dos
jmp krmend5 ; quit immediately
start2: mov word ptr comand.cmrprs,offset krmend ; offset of reparse addr
mov ax,cs ; our current code segment
mov word ptr comand.cmrprs+2,ax ; segment of reparse address
mov comand.cmostp,sp ; save for reparse too
call gcmdlin ; read command line
cmp taklev,0 ; in a Take file?
jne start3 ; ne = yes, skip help msg
mov ah,prstr
mov dx,offset machnam ; display machine name
int dos
mov dx,offset verident ; display version header
int dos
mov dx,offset copyright ; display copyright notice
int dos
ifdef no_graphics
mov dx,offset nographics
int dos
endif
ifdef no_network
mov dx,offset nonet
int dos
else
ifdef no_tcp
mov dx,offset notcp
int dos
endif
endif
ifdef no_terminal
mov dx,offset noterm
int dos
endif
;; Here mskermit originally used:
;; ifdef no_graphics + no_tcp + no_network
;; That doesn't work with jwasm, so unroll it presuming '+' means Boolean OR.
ifdef no_graphics
elseifdef no_tcp
elseifdef no_network
mov dx,offset crlf
int dos
endelse
endelse
endif
mov dx,offset hlpmsg
int dos
start3: mov patchena,' ' ; let patch level show
call serrst ; reset serial port (if active)
call initibm ; define IBM macro
call rdinit ; read kermit init file
push es
mov di,ds
mov es,di
mov di,offset inidir ; remember path to mskermit.ini
mov si,offset cmdfile ; last Take file path+name
call strcpy ; copy whole string
mov dx,di
call strlen ; length of complete path+filename
add di,cx ; last byte +1
mov al,'\' ; look for this separator
std
repne scasb
cld
mov byte ptr [di+2],0 ; terminate after separator
pop es
; This is the main KERMIT loop. It prompts for and gets the users commands
kermit: mov ax,ds
mov es,ax ; convenient safety measure
mov dx,prmptr ; get prompt string address
call mprompt ; set master reparse address to here
cmp flags.cxzflg,'C' ; did someone want out?
jne kermt4 ; ne = no
kermt2: cmp taklev,0 ; are we in a Take file?
je kermt4 ; e = no, ignore the signal
call takclos ; close take file, release buffer
jmp short kermt2 ; close any other take files
kermt4: mov flags.cxzflg,0 ; reset each time
and flags.remflg,not dserver ; turn off server mode bit
cmp dosctty,0 ; is DOS using our comms line?
je kermt1 ; e = no
and flags.remflg,not(dquiet+dregular+dserial)
or flags.remflg,dquiet ; set display to quiet mode
call serrst ; close port so CTTY can run
kermt1: mov dx,offset comtab
mov bx,offset tophlp
cmp flags.extflg,0 ; exit flag set?
jne krmend ; ne = yes, jump to KRMEND
mov comand.cmcr,1 ; allow bare CR's
mov ah,cmkey
mov comand.impdo,1 ; allow implied "DO macro"
call comnd
jc kermt3 ; c = failure
mov comand.impdo,0 ; only on initial keyword, not here
mov comand.cmcr,0 ; no more bare CR's
push bx
mov bx,takadr
mov al,taklev
mov [bx].takinvoke,al ; remember Take level of this cmd
pop bx
call bx ; call the routine returned in BX
jc kermt3 ; c = failure
cmp flags.extflg,0 ; exit flag set?
jne krmend ; ne = yes, jump to KRMEND
jmp short kermt5 ; do idle loop cleanup
kermt3: cmp flags.cxzflg,'C' ; got here via Control-C?
jne kermt7 ; ne = no
cmp flags.extflg,0 ; exit flag set?
jne kermt5 ; ne = yes, skip msg, do cleanup
mov dx,offset ermes3 ; say command not executed
mov ah,prstr ; print the error message in dx
int dos
kermt5: cmp flags.cxzflg,'C' ; user Control-C abort?
jne kermt7 ; ne = no, do normal operations
cmp taklev,0 ; in a Take file?
je kermt7 ; e = no
call takclos ; close take file, release buffer
jmp short kermt5 ; close any other take files
kermt7: cmp flags.extflg,0 ; exit flag set?
jne krmend ; ne = yes, exit
mov bx,takadr
mov al,[bx].takinvoke ; take level at start of command parse
cmp al,taklev ; same?
jne kermt10 ; ne = no, already closed
mov al,[bx].taktyp ; kind, file or macro