-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetcommand.asm
4839 lines (4555 loc) · 140 KB
/
setcommand.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 mssset
; File MSSSET.ASM
include symboldefs.h
; 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.
;
; Edit history
; 12 Jan 1995 version 3.14
; Last edit
; 12 Jan 1995
public setcom, prmptr, dodef, setcpt, docom, stkadr, rdbuf, reset
public setrx, rxtable, srvdsa, srvena, mcctab, takclos, ask
public askq, assign, initibm, mccptr, setinpbuf, setrollb, npages
public xfchtab, xftyptab, com1port, com2port, com3port, com4port
public flotab, popcmd, domacptr, warntab, portirq, portfifo, dodecom
public xfertab1, xfertab2, xfertab3, rollwidth, setwidth, abftab
public localmac, getok, takeerror, macroerror, getc, dial, docnv
public takopen_sub, takopen_file, takopen_macro, _forinc, poplevel
public hide_assign, hide_define, declare, marray, forcmd, undefine
ifndef no_tcp
public tcpaddress,tcpsubnet,tcpdomain,tcpgateway,tcpprimens
public tcpsecondns,tcphost,tcpbcast,tcpport,tcppdint,tcpttbuf
public tcpbtpserver,tcpnewline,tcpdebug,tcpmode,tcpmss
endif ; no_tcp
braceop equ 7bh ; opening curly brace
bracecl equ 7dh ; closing curly brace
maketab MACRO ; Assembler Macro to make rxtable [jrd]
cnt = 0
rept 256
db cnt ; initialize table to 0 .. 255
cnt = cnt + 1
endm
db 0 ; table off (0) or on (1) indicator
ENDM
data segment
extrn comand:byte, flags:byte, trans:byte, takadr:word, taklev:byte
extrn portval:word, dtrans:byte, spause:word, machnam:byte
extrn filtst:byte, maxtry:byte, script:byte, denyflg:word
extrn sloghnd:word, ploghnd:word, tloghnd:word, cardet:byte
extrn decbuf:byte, kstatus:word, errlev:byte, srvtmo:byte
extrn luser:byte, lpass:byte, destab:byte, blktab:byte
extrn seoftab:byte, dmpname:byte, lsesnam:byte, lpktnam:byte
extrn ltranam:byte, incstb:byte, inactb:byte, rxoffmsg:byte
extrn rxonmsg:byte, scpbuflen:word, setchtab:byte
extrn prnname:byte, prnhand:word, outpace:word, apctrap:byte
extrn protlist:byte, rcvpathflg:byte, sndpathflg:byte
extrn fossilflag:byte, ifelse:byte, oldifelse:byte
extrn domath_ptr:word, domath_cnt:word, domath_msg:word
extrn streaming:byte
rxtable equ THIS BYTE ; build 256 byte Translation Input table
maketab ; table rxtable is used by Connect mode
kerm db 'MS-Kermit>',0 ; default ASCIIZ prompt
promptbuf db 80 dup (0),0 ; buffer for new ASCIIZ prompt
rdbuf db cmdblen dup (?) ; work space; room for macro def
; and for Status display line
settemp db 100 dup (0) ; temp for hidemac/unhide
stflg db 0 ; Says if setting SEND or RECEIVE parameter
defkind db 0 ; 0 for ASSIGN, 1 for DEFINE
ermes1 db cr,lf,'?Too many macro names$'
ermes2 db cr,lf,bell,'?No room for Take file buffer or Macro definition'
db cr,lf,bell,'$'
ermes4 db cr,lf,'?Too many active Take files and Macros',cr,lf, bell,'$'
ermes5 db cr,lf,'?Not implemented$'
ermes6 db cr,lf,'?More parameters are needed$'
ermes7 db cr,lf,'?Cannot use RTS/CTS on non-UART ports$'
ermes8 db cr,lf,'?Cannot use HARDWARE parity on non-UART ports$'
errcap db cr,lf,'?Unable to open that file$'
erropn db cr,lf,'?Log file is already open$'
badrx db cr,lf,'?Expected ON, OFF, or \nnn$'
escerr db cr,lf,'?Not a control code$'
takcerr db cr,lf,'?Note: command is valid only in Take files and Macros$'
dmpdefnam db 'Kermit.scn',0 ; asciiz default screen dump filename
prndefnam db 'PRN',0 ; asciiz default printer name
xfchbad db cr,lf,'Warning: forcing FILE CHARACTER-SET to CP866$'
xfchbad2 db cr,lf,'Warning: forcing FILE CHARACTER-SET to Shift-JIS$'
xfchbad3 db cr,lf,'Warning: forcing FILE CHARACTER-SET to CP862$'
setchmsg db cr,lf,'Warning: forcing TRANSFER CHARACTER-SET to CYRILLIC$'
setchmsg2 db cr,lf,'Warning: forcing TRANSFER CHARACTER-SET to'
db ' Japanese-EUC$'
setchmsg3 db cr,lf,'Warning: forcing TRANSFER CHARACTER-SET to HEBREW-ISO$'
badcntlmsg db cr,lf,'?Number is not in range of 0..31, 128..159$'
getdef db 'Please respond Yes or No ',0 ; ASCII, used as prompt
crlf db cr,lf,'$'
space db ' ',0
srvtab db 2 ; SET SERVER table
mkeyw 'Login',1
mkeyw 'Timeout',2
ifndef no_network
settab db 64 ; Set table
else
settab db 64 - 3 ; Set table
endif ; no_network
mkeyw 'Alarm',setalrm
mkeyw 'Attributes',setatt
mkeyw 'Baud',baudst
mkeyw 'Bell',bellst
mkeyw 'Block-check-type',blkset
mkeyw 'Carrier',setcar
mkeyw 'COM1',com1port
mkeyw 'COM2',com2port
mkeyw 'COM3',com3port
mkeyw 'COM4',com4port
mkeyw 'Control-character',cntlset
mkeyw 'Count',takectr
mkeyw 'Debug',debst
mkeyw 'Default-disk',cwdir
mkeyw 'Delay',setdely
mkeyw 'Destination',desset
mkeyw 'Display',disply
mkeyw 'Dump',setdmp
mkeyw 'Duplex',setdup
mkeyw 'End-of-Line',eolset
mkeyw 'EOF',seteof
mkeyw 'Errorlevel',seterl
mkeyw 'Escape-character',escset
mkeyw 'Exit',setexitwarn
mkeyw 'File',setfile
mkeyw 'Flow-control',floset
mkeyw 'Fossil',fosset
mkeyw 'Handshake',hndset
mkeyw 'Incomplete',abfset
mkeyw 'Input',inpset
mkeyw 'Key',setkey
mkeyw 'Line',coms
mkeyw 'Local-echo',lcal
mkeyw 'Macro',setmacerr
mkeyw 'Mode-line',modl
mkeyw 'Modem',setmodem
ifndef no_network
mkeyw 'NetBios-name',setnbios
endif ; no_network
mkeyw 'Output',setoutput
mkeyw 'Parity',setpar
mkeyw 'Port',coms
mkeyw 'Printer',setprn
mkeyw 'Prompt',promset
mkeyw 'Receive',recset
mkeyw 'Remote',remset
mkeyw 'Repeat',repset
mkeyw 'Retry',retryset
mkeyw 'Rollback',setrollb
mkeyw 'Send',sendset
mkeyw 'Server',setsrv
mkeyw 'Speed',baudst
mkeyw 'Stop-bits',stopbit
mkeyw 'Streaming',strmmode
mkeyw 'Take',takset
ifndef no_tcp
mkeyw 'TCP/IP',tcpipset
mkeyw 'Telnet',tcpipset
endif ; no_tcp
mkeyw 'Terminal',vts
mkeyw 'Timer',timset
mkeyw 'Transfer',sxfer
mkeyw 'xfer',sxfer ; hidden synonym
mkeyw 'Translation',setrx
mkeyw 'Transmit',setxmit
mkeyw 'Unknown-character-set',unkchset
mkeyw 'Warning',filwar
mkeyw 'Windows',winset
setfitab db 6 ; Set File command table
mkeyw 'Character-Set',1
mkeyw 'Collision',0
mkeyw 'Display',3
mkeyw 'Incomplete',4
mkeyw 'Type',2
mkeyw 'Warning',0
setrep db 2 ; SET REPEAT
mkeyw 'Counts',0
mkeyw 'Prefix',1
xfertab db 5 ; SET TRANSFER table
mkeyw 'Character-set',0
mkeyw 'CRC',4
mkeyw 'Locking-shift',1
mkeyw 'Mode',3
mkeyw 'Translation',2
xfertab1 db 3 ; SET TRANSFER LOCKING-SHIFT
mkeyw 'Off',lock_disable
mkeyw 'On',lock_enable
mkeyw 'Forced',lock_force
xfertab2 db 2 ; SET TRANSFER TRANSLATION
mkeyw 'Readable',0
mkeyw 'Invertible',1
xfertab3 db 2 ; SET TRANSFER MODE
mkeyw 'Automatic',1
mkeyw 'Manual',0
xfchtab db 6 ; SET TRANSFER CHARACTER-SET
mkeyw 'Transparent',xfr_xparent ; no translation
mkeyw 'Latin1 ISO 8859-1',xfr_latin1 ; ISO 8859-1, Latin-1
mkeyw 'Latin2 ISO 8859-2',xfr_latin2 ; ISO 8859-2, Latin-2
mkeyw 'Hebrew ISO 8859-8',xfr_hebiso ; ISO 8859-8 Hebrew-ISO
mkeyw 'Cyrillic ISO 8859-5',xfr_cyrillic; ISO 8859-5/Cyrillic, CP866
mkeyw 'Japanese-EUC',xfr_japanese ; Japanese-EUC
xftyptab db 2 ; SET FILE TYPE table
mkeyw 'Binary',1 ; Binary = as-is
mkeyw 'Text',0 ; Text = can change char sets
warntab db 8 ; File Warning table
mkeyw 'Append',filecol_append ; append
mkeyw 'Overwrite',filecol_overwrite ; overwrite
mkeyw 'Rename',filecol_rename ; rename
mkeyw 'Discard',filecol_discard ; discard
mkeyw 'Update',filecol_update ; update (if incoming is newer)
mkeyw 'No-supersede',filecol_discard ; discard
mkeyw 'on (rename)',filecol_rename ; old form
mkeyw 'off (overwrite)',filecol_overwrite ; old form
unkctab db 2 ; unknown character-set disposition
mkeyw 'Keep',0
mkeyw 'Cancel',1
atttab db 7 ; SET ATTRIBUTES table
mkeyw 'Off',00ffh ; all off
mkeyw 'On',10ffh ; all on (high byte is on/off)
mkeyw 'Character-set',attchr ; Character set
mkeyw 'Date-Time',attdate ; Date and Time
mkeyw 'Length',attlen ; Length
mkeyw 'Type',atttype ; Type
mkeyw 'System-id',attsys ; System
comtab db 2 ; table of COM ports
mkeyw 'COM3',4 ; offset of COM3 address
mkeyw 'COM4',6 ; offset of COM4 address
cntltab db 2 ; SET CONTROL table
mkeyw 'Prefixed',0 ; 0 = send with prefix
mkeyw 'Unprefixed',1 ; 1 = send as-is
stsrtb db 10 ; Number of options
mkeyw 'Packet-length',srpack
mkeyw 'Padchar',srpad
mkeyw 'Padding',srnpd
mkeyw 'Pause',srpaus
mkeyw 'Start-of-packet',srsoh
mkeyw 'Quote',srquo
mkeyw 'End-of-packet',sreol
mkeyw 'Timeout',srtim
mkeyw 'Double-char',srdbl
mkeyw 'Pathnames',srpath
ontab db 2
mkeyw 'off',0
mkeyw 'on',1
outputtab db 1 ; Set OUTPUT
mkeyw 'PACING',setopace
distab db 5 ; Set Display mode
mkeyw '7-bit',7 ; controls bit d8bit in flags.remflg
mkeyw '8-bit',8 ; sets d8bit
mkeyw 'Quiet',dquiet ; values defined in header file
mkeyw 'Regular',dregular
mkeyw 'Serial',dserial
distab2 db 3 ; for SET FILE DISPLAY
mkeyw 'Quiet',dquiet ; values defined in header file
mkeyw 'Regular',dregular
mkeyw 'Serial',dserial
fossiltab db 1 ; Fossil
mkeyw 'disable-on-close',1
; If abort when receiving files, can keep what we have or discard
abftab db 2
mkeyw 'Discard',1
mkeyw 'Keep',0
flotab db 5
mkeyw 'none',0
mkeyw 'xon/xoff',1+2 ; both directions
mkeyw 'incoming-xon/xoff',2
mkeyw 'outgoing-xon/xoff',1
mkeyw 'RTS/CTS',4
FIFOtab db 2
mkeyw 'FIFO-disabled',0
mkeyw 'FIFO-enabled',1
hndtab db 8
mkeyw 'none',0
mkeyw 'bell',bell
mkeyw 'cr',cr
mkeyw 'esc',escape
mkeyw 'lf',lf
mkeyw 'xoff',xoff
mkeyw 'xon',xon
mkeyw 'code',0ffh ; allow general numerial code
duptab db 2 ; SET DUPLEX table
mkeyw 'full',0
mkeyw 'half',1
partab db 6
mkeyw 'none',PARNON
mkeyw 'even',PAREVN
mkeyw 'odd',PARODD
mkeyw 'mark',PARMRK
mkeyw 'space',PARSPC
mkeyw 'HARDWARE',PARHARDWARE
parhwtab db 4 ; for 9-bit bytes
mkeyw 'even',PAREVNH
mkeyw 'odd',PARODDH
mkeyw 'mark',PARMRKH
mkeyw 'space',PARSPCH
exittab db 1 ; EXIT table
mkeyw 'warning',0
gettab db 3 ; GETOK dispatch table
mkeyw 'Yes',kssuc ; success = yes
mkeyw 'OK',kssuc ; ditto
mkeyw 'No',ksgen ; general failure
inptab db 5 ; Scripts. Set Input
mkeyw 'Case',inpcas ;[jrs]
mkeyw 'Default-timeout',inptmo ;[jrs]
mkeyw 'Echo',inpeco ;[jrs]
mkeyw 'Filter-echo',infilt
mkeyw 'Timeout-action',inpact ;[jrs]
resettab db 1
mkeyw 'Clock',80h
macrotab db 1 ; SET MACRO table
;; mkeyw 'Echo',0
mkeyw 'Error',1
pathtab db 3 ; SET SEND/RECEIVE PATHNAMES
mkeyw 'off',0
mkeyw 'relative',1
mkeyw 'absolute',2
taketab db 3 ; SET TAKE table
mkeyw 'Debug',2
mkeyw 'Echo',0
mkeyw 'Error',1
xmitab db 4 ; SET TRANSMIT table
mkeyw 'Fill-empty-line',0
mkeyw 'Line-Feeds-sent',1
mkeyw 'Pause',3
mkeyw 'Prompt',2
debtab db 4 ; Set Debug command
mkeyw 'Off',0
mkeyw 'On',logpkt+logses
mkeyw 'Packets',logpkt
mkeyw 'Session',logses
logtab db 3 ; LOG command
mkeyw 'Packets',logpkt
mkeyw 'Session',logses
mkeyw 'Transactions',logtrn
srvdetab db 18 ; Enable/Disable list for server
mkeyw 'All',0ffffh
mkeyw 'BYE',byeflg
mkeyw 'CD',cwdflg
mkeyw 'CWD',cwdflg
mkeyw 'Define',defflg
mkeyw 'Delete',delflg
mkeyw 'Dir',dirflg
mkeyw 'Finish',finflg
mkeyw 'Get',getsflg
mkeyw 'Host',hostflg
mkeyw 'Kermit',kerflg
mkeyw 'Login',pasflg
mkeyw 'Print',prtflg
mkeyw 'Retrieve',retflg
mkeyw 'Query',qryflg
mkeyw 'Send',sndflg
mkeyw 'Space',0;;;spcflg ; obsolete, non-functional
mkeyw 'Type',typflg
trnstab db 2 ; Set Translation table
mkeyw 'Input',1
mkeyw 'Keyboard',2
ifndef no_tcp
tcptable db 14 ; Telnet or TCP/IP command
mkeyw 'address',1 ; local Internet address
mkeyw 'domain',2 ; local domain string
mkeyw 'broadcast',8 ; broadcast of all 0's or all 1's
mkeyw 'gateway',4 ; gateway address
mkeyw 'primary-nameserver',5 ; name servers
mkeyw 'secondary-nameserver',6
mkeyw 'subnetmask',3 ; our subnet mask
mkeyw 'host',7 ; host's IP name or IP number
mkeyw 'Packet-Driver-interrupt',9
mkeyw 'term-type',10 ; Options term type
mkeyw 'NewLine-mode',11 ; CR-NUL vs CRLF
mkeyw 'mode',13 ; NVT-ASCII or Binary
mkeyw 'mss',14 ; Max Segment Size
mkeyw 'debug-Options',12 ; debug Telnet Options
tcpmodetab db 2 ; TCP/IP Mode
mkeyw 'NVT-ASCII',0
mkeyw 'Binary',1
tcpdbtab db 4 ; TCP Debug modes
mkeyw 'off',0
mkeyw 'status',1
mkeyw 'timing',2
mkeyw 'on', 3
newlinetab db 3 ; TCP/IP Newline mode
mkeyw 'off',0
mkeyw 'on',1
mkeyw 'raw',2
domainbad db cr,lf,'?Bad domain name, use is such as my.domain.name$'
addressbad db cr,lf,'?string is too long$'
hostbad db cr,lf,'?Bad host, use IP name or IP number$'
tcpaddress db 'dhcp',(16-($-tcpaddress)) dup (0),0
tcpsubnet db '255.255.255.0',(16-($-tcpsubnet)) dup (0),0
tcpdomain db 'unknown',(32-($-tcpdomain)) dup (0),0
tcpgateway db 'unknown',(32-($-tcpgateway)) dup (0),0
tcpprimens db 'unknown',(16-($-tcpprimens)) dup (0),0
tcpsecondns db 'unknown',(16-($-tcpsecondns)) dup (0),0
tcphost db (60 -($-tcphost)) dup (0),0
tcpbcast db '255.255.255.255',(16-($-tcpbcast)) dup (0),0
tcpbtpserver db 17 dup (0) ; bootp server (response)
tcpport dw 23 ; TCP port
tcppdint dw 0 ; Packet Driver interrupt
tcpttbuf db 32 dup (0),0 ; term-type-override buffer
tcpnewline db 1 ; NewLine-Mode (default is on)
tcpdebug db 0 ; Options debugging (0 is off)
tcpmode db 0 ; NVT-ASCII is 0, Binary is 1
tcpmss dw 1460 ; MSS
endif ; no_tcp
; MACRO DATA STRUCTURES mcctab
mcclen equ macmax*10 ; length of mcctab
mcctab db 0 ; macro name table entries
db mcclen dup (0) ; room for macro structures
; END OF MACRO DATA STRUCTURES
ibmmac db 'IBM ' ; startup IBM macro definition + space
db 'set timer on,set parity mark,set local-echo on,'
db 'set handshake xon,set flow none,',0 ; asciiz
dialmac db '__DIAL ' ; "__DIAL "
db 'asg \%9 \v(carrier),set carr off,'
db 'output ATD\%1\%2\%3\%4\%5\%6\%7\%8\13,wait 90 CD,'
db 'asg \%8 \v(status),set carr \%9,end \%8,',0 ; asciiz
even
prmptr dw kerm ; pointer to prompt
tempptr dw 0 ; pointer into work buffer
domacptr dw 0 ; pointer to DO MAC string
min dw 0
max dw 0
numerr dw 0
numhlp dw 0
temp dw 0
temp1 dw 0 ; Temporary storage
temp2 dw 0 ; Temporary storage
askecho db 0 ; ask's echo control flag
deftemp dw 0
stkadr dw 0 ; non-zero if replacement keyboard xlator present
mccptr dw mcctab ; ptr to first free byte in mcctab
macptr dw 0 ; temp to hold segment of string
npages dw 10 ; # of pages of scrolling on each side
rollwidth dw 0 ; columns to roll back 80..207
portirq db 4 dup (0) ; user specified IRQ's for COM1..4
portfifo db 4 dup (1) ; user specified FIFO for COM1..4
takeerror db 0 ; Take Error (0 = off)
macroerror db 0 ; Macro Error (0 = off)
marray dw 27 dup (0) ; pointers to macro array mem areas
arraybad db cr,lf,'? Array size is too large, 32000 max$'
hidetmp db 0 ; 0..9 binary for hide prefix
forstr1 db '_forinc ',0 ; append 'variable step'
forstr2 db ' if not > ',0 ; append 'variable end'
forstartptr dw 0
forendptr dw 0
forstepptr dw 0
forcmdsptr dw 0
forbadname db cr,lf,'?Not a variable name$'
data ends
data1 segment
askhlp1 db 'Variable name then prompt string$'
askhlp2 db 'Prompt string$'
askhlp3 db 'Enter a line of text$'
getokhlp db 'Optional prompt string$'
filhlp db ' Output filename for the log$'
forhlp db cr,lf,'FOR variable initial final increment'
db ' {command,command,...}$'
dishlp db cr,lf,' Quiet (no screen writing), Regular (normal),'
db ' Serial (non-formatted screen)'
db cr,lf,' and/or 7-BIT (default) or 8-BIT wide characters.$'
exitwhlp db cr,lf,' ON or OFF. Warn if sessions are active when exiting'
db ' Kermit$'
remhlp db cr,lf,' OFF to show file transfer display,'
db ' ON for quiet screen$'
macmsg db ' Specify macro name followed by body of macro, on same line$'
prmmsg db cr,lf
db ' Enter new prompt string or press Enter to regain default prompt.'
db cr,lf,' Use \fchar(123) notation for special chars;'
db ' Escape is \fchar(27).$'
rspathhlp db cr,lf,' OFF removes pathnames during file transfer,'
db cr,lf,' RELATIVE includes path from current location'
db cr,lf,' ABSOLUTE includes path from root of drive$'
srxhlp1 db cr,lf,' Enter code for received byte code for'
db ' local byte ',cr,lf,' use ascii characters themselves or'
db cr,lf,' numerical equivalents of \nnn decimal'
db ' or \Onnn octal or \Xnnn hexadecimal',cr,lf
db ' or keywords ON or OFF (translation is initially off)'
db cr,lf,'$'
takchlp db cr,lf,'Value 0 to 65535 for COUNT in script IF COUNT command$'
nummsg1 db cr,lf,'?Use a number between $'
nummsg2 db ' and $'
srvthlp db 'seconds, 0-255, waiting for a transaction$'
unkchhlp db cr,lf,' Disposition of files arriving with unknown'
db ' character sets:',cr,lf,' Keep (default), Cancel$'
winhelp db cr,lf,'Number of sliding window slots 1 (no windowing) to 32$'
eophlp db ' Decimal number between 0 and 31$'
ctlhlp db ' Decimal number between 0 and 31, 128 and 159$'
cntlhlp db cr,lf,' PREFIXED <0..31, 128..159> protectively quotes this'
db ' control code',cr,lf
db ' UNPREFIXED <0..31, 128..159> sends control code as-is'
db cr,lf,' Use ALL to change all codes at once.$'
sohhlp db ' Decimal number between 0 and 31.',cr,lf,' Special case:'
db ' up to 126, but reduces strength of the protocol.$'
dmphlp db ' Filename to hold screen dumps$'
prnhlp db ' Filename for printer output (default is PRN)$'
prnerr db cr,lf,' Cannot open that name. Using default of PRN$'
erlhlp db ' Decimal number between 0 and 255$'
pakerr db cr,lf,'?Choose a decimal number '
db 'from 20 to 94 (normal) or to 9024 (long)$'
pakhlp db cr,lf,'Decimal number between 20 and 94 (normal) or '
db '9024 (long)$'
padhlp db cr,lf,' Decimal number between 0 and 31 or 127$'
pauhlp db ' Decimal number between 0 and 65383 milliseconds$'
quohlp db ' Decimal number between 33 and 126$'
retryhlp db ' Decimal number between 1 and 63$'
rollhlp db ' Decimal number between 0 and 8000$'
dblhlp db ' Decimal number between 0 and 255$'
stophlp db ' Serial port stop bits, 1 (default) or 2$'
luserh db cr,lf,'Username Password from remote Kermit (0-16 chars each)$'
lpassh db cr,lf,'Password from remote Kermit (0-16 chars,'
db ' spaces allowed)$'
prefhlp db cr,lf,' single char (def is ~) or number between 33-62 or'
db ' 96-126$'
timhlp db ' Decimal number between 0 and 94$'
delyhlp db ' Delay seconds before sending file (0-63)$'
eschlp db cr,lf,'Press literal control keys (ex: Control ]) or'
db ' enter in \nnn numerical form$'
hnd1hlp db cr,lf,'XON (\17), XOFF (\19), CR (\13), LF (\10), BELL (\7),'
DB ' ESC (\27), NONE (\0)'
db cr,lf,' or "CODE" followed by decimal number$'
intoms db 'number of seconds to wait before timeout',cr,lf,'$'
loghlp db cr,lf
db ' PACKETS - during file transfers (to default file PACKET.LOG)'
db cr,lf
db ' SESSION - during Connect mode (to default file SESSION.LOG)'
db cr,lf
db ' TRANSACTIONS - files transfers (to default file TRANSACT.LOG)'
db cr,lf,' followed by an optional filename for the log and'
db ' optional',cr,lf,' '
loghlp2 db ' APPEND (default) or NEW$'
carhlp db cr,lf,' ON or OFF. Sense modem Carrier Detect and end'
db ' connection if it drops.$'
comhlp db cr,lf,' Set port address, IRQ, and control UART FIFO.'
db cr,lf,' Address of the COM1 - COM4 port (ex: COM3 \x02f8 or'
db ' COM4 \x02e8)$'
irqhlp db cr,lf,' IRQ of port (ex: \3)$'
fifohlp db cr,lf,' FIFO-disable or FIFO-enable or press Enter key.'
db cr,lf,' FIFO-disable means bypass UART buffer$'
debhlp db cr,lf,' PACKETS - during file transfers' ; Debugging
db cr,lf,' SESSION - during Connect mode'
db cr,lf,' ON - both packets and session'
db cr,lf,' OFF - turns off all debugging$'
dialhlp db ' Phone number to dial$'
dohlp db cr,lf,'definitions of variables (\%n), or press ENTER key$'
fossilhlp db cr,lf,' OFF to leave Fossil active (default), ON to disable'
db ' when done with port$'
sdshlp db cr,lf,'DISABLE or ENABLE access to selected Server commands:'
db cr,lf
db ' BYE (includes LOGOUT), CD/CWD, DEFINE, DEL, DIR, FINISH,'
db ' GET, HOST,',cr,lf
db ' KERMIT, LOGIN, PRINT, QUERY, RETRIEVE, SEND, TYPE,'
db ' and ALL.$'
xfchhlp db cr,lf,' Which character set to put on the wire during file'
db ' transfers:',cr,lf
db ' TRANSPARENT (regular PC codes)',cr,lf
db ' LATIN1 (ISO 8859-1)',cr,lf
db ' LATIN2 (ISO 8859-2)',cr,lf
db ' HEBREW (ISO 8859-8)',cr,lf
db ' CYRILLIC (ISO 8859-5)',cr,lf
db ' JAPANESE-EUC$'
xferhlp1 db cr,lf,' OFF: disable feature, ON: enable (default), FORCE:'
db ' forced on$'
xfchhlp2 db cr,lf,' READABLE: translate some/many characters to/from'
db ' locally readable form (def).'
db cr,lf,' INVERTIBLE: use codes which can be copied back to the'
db ' host in its form.$'
xferhlp3 db cr,lf,'Automatic (Binary mode between like systems),'
db ' manual (default)$'
xfilhlp db 'NONE, SPACE, or filler character$'
xpmthlp db 'Host echo char acting as prompt, \1-\255$'
xpauhlp db 'Millisec to pause between lines, 1 - 65000$'
opacehlp db 'Millisec to pause between OUTPUT bytes, 0 - 65000$'
pophlp db 'Status value to be returned msg, nothing if no new value$'
sethlp db cr,lf
db ' Alarm sec from now or HH:MM:SS '
db ' Mode-line on/off'
db cr,lf
db ' Attributes packets on/off '
db ' NetBios-name (our local name)'
db cr,lf
db ' Bell on/off at end of xfers '
db ' Output pacing (ms between bytes) '
db cr,lf
db ' Block-check-type checksum/CRC '
db ' Parity even/odd/mark/space/none'
db cr,lf
db ' Carrier sense modem Carrier Detect'
db ' Port (or Line) 1/2/COM1/COM2/etc'
db cr,lf
db ' COM1 - COM4 port-address irq '
db ' Printer filespec for Connect mode'
db cr,lf
db ' Control prefixed/unprefixed code '
db ' Prompt string (new Kermit prompt)'
db cr,lf
db ' Count number a loop counter '
db ' Receive parameter many things'
db cr,lf
db ' Debug on/off display packets '
db ' Repeat Counts (on/off) '
db cr,lf
db ' Default-disk '
db ' Retry limit for packet send/receive'
db cr,lf
db ' Delay secs before Sending file '
db ' Rollback, terminal screens'
db cr,lf
db ' Destination Disk/Screen/Printer '
db ' Send parameter many things'
db cr,lf
db ' Display quiet/reg/serial show cnts?'
db ' Server parameter'
db cr,lf
db ' Dump filespec screen to disk '
db ' Speed or Baud many speeds'
db cr,lf
db ' Duplex half or full '
db ' Streaming on/off'
db cr,lf
db ' EOF Ctrl-Z/NoCtrl-Z ^Z ends file? '
db ' Stop-bits always 1'
db cr,lf
db ' End-of-line char cr or whatever '
db ' Take Echo or Error on/off'
db cr,lf
db ' Errorlevel number for DOS Batch '
db ' TCP/IP or Telnet parameters'
db cr,lf
db ' Escape-char ^] or whatever '
db ' Terminal type and parameters'
db cr,lf
db ' Exit warning (if session active) '
db ' Timer on/off time packet waiting'
db cr,lf
db ' File (Character-set, Type, Warning)'
db ' Translation in Connect mode rcv''d char'
db cr,lf
db ' Flow-control none xon/xoff rts/cts'
db ' Transfer Character-set (on wire) '
db cr,lf
db ' Handshake xon/xoff/cr/lf/bell/esc..'
db ' Transmit parameters, for scripts'
db cr,lf
db ' Incomplete file keep/discard '
db ' Unknown-character-set (keep/cancel)'
db cr,lf
db ' Input timeout, etc (for scripts) '
db ' Warning on/off if file renamed'
db cr,lf
db ' Key key-ident definition '
db ' Windows number of sliding window slots'
db cr,lf
db ' Local-echo on/off'
db '$'
ifndef no_tcp
hosthlp db cr,lf,'Internet name or number (ddd.ddd.ddd.ddd) of '
db 'the remote machine$'
domainhlp db cr,lf,'Name of your domain$'
subnethlp db cr,lf,'Subnetmask, decimal ddd.ddd.ddd.ddd$'
addrhelp db cr,lf,'Internet address, decimal ddd.ddd.ddd.ddd, of this'
db ' machine or'
db cr,lf,' BOOTP, DHCP, RARP, or Telebit-PPP$'
iphelp db cr,lf,'Internet address, decimal ddd.ddd.ddd.ddd$'
tcppdinthlp db cr,lf,'Interrupt on PC for Packet Driver, \x40 to \x7f'
db ' or use 0 for automatic search,'
db cr,lf,' or ODI to use Novell''s ODI interface$'
tcpttyhlp db cr,lf,' Telnet Options terminal identification override '
db 'string.'
db cr,lf,' This does NOT modify the real terminal type.'
db ' Press ENTER to remove this',cr,lf
db ' override and report the real terminal type.$'
tcpnlhlp db cr,lf,' ON sends CR LF for each CR, OFF sends CR NUL,'
db ' RAW sends just CR$'
tcpmsshlp db cr,lf,' Maximum Segment Size, 16 to 1460 bytes$'
endif ; no_tcp
arrayhlp db ' \&<char>[size] size of 0 undefines the array$'
data1 ends
code1 segment
extrn makebuf:far, domath:far, strlen:far, strcpy:far
extrn prtasz:far, decout:far, strcat:far, toupr:far
extrn isfile:far, malloc:far, dec2di:far, takrd:far
assume cs:code1
code1 ends
code segment
extrn comnd:near, baudst:near, prompt:near, coms:near, cwdir:near
extrn lnout:near, breakcmd:near
extrn vts:near, setalrm:near, serrst:near
extrn prnopen:near, pntflsh:near
ifndef no_network
extrn setnbios:near ; in MSXIBM, needs stub for other machines
endif ; no_network
assume cs:code, ds:data, es:nothing
; DO defined macro command
; DO macname variable variable also defines variables \%1, \%2, ...\%9
DOCOM PROC NEAR
mov dx,offset mcctab ; table of macro defs
xor bx,bx ; help is table
mov ah,cmkey ; get key word (macro name)
call comnd ; get pointer to keyword structure
jnc docom1 ; nc = success, bx = 16 bit data
ret ; failure
DOCOM1: mov domacptr,bx ; segment of definition string
mov comand.cmquiet,0 ; permit command echoing
mov bx,offset decbuf+2 ; point to borrowed work buffer
docom1a:mov dx,offset dohlp ; help
mov comand.cmblen,decbuflen ; length of analysis buffer
mov comand.cmdonum,1 ; \number conversion allowed
mov ah,cmword
call comnd
jnc docom1b
ret
docom1b:mov si,bx ; terminating null
sub si,ax ; minus length
mov [si-2],ax ; store length in preceeding word
add bx,2 ; leave a full word empty
mov word ptr [bx-2],0
or ax,ax ; any text?
jnz docom1a ; nz = got text, get more
mov ah,cmline ; read and discard rest of line
mov bx,offset rdbuf ; discard here
xor dx,dx ; no help
call comnd
jnc docom2 ; nc = success
ret
docom2: inc taklev ; prepare for being in Take below
call hidemac ; hide previous \%0..\%9 macros
dec taklev
call getname ; get name of this macro to rdbuf
mov cx,word ptr rdbuf ; length of "\%0 plus found name"
call dodecom ; define macro \%0 as macro name
jc docomx ; c = failure
push es
mov ax,domacptr ; macro definition string segment
mov es,ax ; string is in es:si
xor si,si ; point to count word
call docnv ; convert macro string in-place
pop es ; to lift top {} and do bare "," -> CR
jc docomx ; c = failure
mov max,1 ; temp for counting 1 + number args
mov word ptr rdbuf+4,' 1' ; number of first variable
docom3: mov word ptr rdbuf,0 ; clear length field, install \%x name
mov word ptr rdbuf+2,'%\' ; start with '\%1 '
mov word ptr rdbuf+6,0 ; clear text field
mov tempptr,offset rdbuf+6 ; pointer to location of found word
xor ch,ch ; make cx = 1 - 9
mov cl,rdbuf+4 ; cx = word # of interest, for getwrd
sub cl,'0' ; remove ascii bias
mov si,offset decbuf+2 ; source = work buffer (borrowed)
call getwrd ; get CX-th word from work buf (1-9)
cmp deftemp,0 ; length of word, was it found?
je docom4 ; e = no, end variable definition part
add deftemp,4 ; count '\%n ' in command line length
inc max ; one more argument
mov cx,deftemp ; command length for dodecom
call dodecom ; add keyword+def using DEF MAC below
jc docomx ; c = failure
inc rdbuf+4 ; inc number of variable in '\%n '
cmp rdbuf+4,'9'
jbe docom3 ; do '1' through '9', if available
docom4: call takopen_macro ; create the DO the macro itself
jc docomx ; c = failure
mov bx,takadr ; point to current structure
push es
mov es,domacptr ; segment of macro definition string
mov [bx].takbuf,es ; remember in Take structure
mov cx,es:word ptr[0] ; length of definition string
mov si,cx
cmp byte ptr es:[si+2-1],CR ; terminates in CR?
je docom5 ; e = yes
mov byte ptr es:[si+2],CR ; force CR termination
; keeps open macro until after last command has executed, for \%digit
inc cx ; add CR to macro length
mov es:[0],cx ; update image too
docom5: pop es
mov [bx].takcnt,cx ; # of unread chars in buffer
mov cx,max ; 1 + number of arguments
mov [bx].takargc,cx
mov al,taklev ; Take level now
mov [bx].takinvoke,al ; remember take level of this DO
clc ; success
ret
docomx: inc taklev ; simulate Take closing
mov hidetmp,0 ; unhide only \% args
call unhidemac ; recover hidden variables
dec taklev
stc ; say failure
ret
DOCOM ENDP
; Extract CX-th word (cx = 1-9) from buffer (SI). Enter with si = source
; string and tempptr pointing at destination. Returns deftemp (count) of
; transferred characters.
; All registers preserved.
getwrd proc near
push si
push di
push es
push cx ; save word counter (1-9)
getwr1: mov ax,[si-2] ; get length of word
or ax,ax
jz getwr2 ; z = zero length, no word, quit
dec cx ; one less word
or cx,cx
jz getwr2 ; z = at desired word
add si,ax ; step to next word (<cnt><text>)
add si,2 ; point to text
jmp short getwr1
getwr2: mov deftemp,ax ; returned length of word
mov cx,ax ; length of word
mov di,tempptr ; where to store word/string
push ds
pop es ; set es to data segment
cld
rep movsb ; copy bytes to destination
xor al,al
stosb ; force null terminator
pop cx
pop es
pop di
pop si
ret
getwrd endp
; Get macro name, given the action pointer in domacptr.
; Return rdbuf as word:length that follows, then "\%0 macro-name"
getname proc near
push bx
push cx
push dx
push si
push di
mov dx,domacptr ; action word to be matched
mov bx,offset mcctab+1 ; table of macro names, skip count
mov word ptr rdbuf,4 ; name length and space
mov word ptr rdbuf+2,'%\' ; define '\%0 '
mov word ptr rdbuf+4,' 0'
mov cl,mcctab ; number of entries
xor ch,ch
jcxz getnam3 ; z = empty table
getnam1:push cx
mov cx,[bx] ; length of name
mov si,bx ; point at structure member
add si,2 ; plus count
add si,cx ; plus length of name
mov ax,[si] ; get action word
cmp ax,dx ; correct action word?
jne getnam2 ; ne = no
push es
push ds
pop es
add word ptr rdbuf,cx ; length of macro \%0 + name
mov di,offset rdbuf+6 ; where to store text
mov si,bx
add si,2 ; source of text
cld
rep movsb ; copy name to rdbuf+6
mov byte ptr [di],0 ; null terminator
pop es
pop cx
jmp short getnam3 ; exit
getnam2:mov ax,[bx] ; get length of name
add ax,4 ; plus count and word pointer
add bx,ax ; point to next entry
pop cx
loop getnam1 ; look at next entry
getnam3:pop di
pop si
pop dx
pop cx
pop bx
ret
getname endp
; Local macro macro macro...
; Hides existing macros of those names, if any
localmac proc near
cmp taklev,0 ; in a take file/macro?
je localmx ; e = no, quit
mov bx,offset rdbuf+2
xor dx,dx ; help
mov comand.cmper,1 ; don't expand macro
mov ah,cmword ; get name of macro
call comnd
jnc localm1
localmx:mov ah,cmeol ; get eol
call comnd
ret
localm1:mov word ptr rdbuf,ax ; save name length
or ax,ax ; empty (end of command)?
jz localmx ; z = yes, quit
mov bx,offset mcctab+1 ; table of macro names, skip count
xor ch,ch
mov cl,mcctab ; number of entries
jcxz localmx ; z = empty table
localm2:mov ax,word ptr rdbuf ; get user macro name length
cmp word ptr [bx],ax ; name length, same?
jne localm4 ; ne = no, get next table entry
push cx ; compare names
push si
push di
mov cx,ax ; length of macro (either)
mov si,offset rdbuf+2 ; user word
mov di,bx ; table word length
add di,2 ; table word
localm3:mov al,[si]
mov ah,[di]
inc si
inc di
call toupr ; upper case both
cmp al,ah ; same?
loope localm3 ; e = yes
je short localm5 ; e = fully matched
pop di
pop si
pop cx
localm4:mov ax,[bx] ; get length of name
add ax,4 ; plus count and word pointer
add bx,ax ; point to next entry
loop localm2 ; look at next table entry
jmp localmac ; get next macro name
localm5:pop di
pop si
pop cx
mov hidetmp,1 ; hide locals
call hidewrk ; hide macro pointed to by bx
jmp localmac ; get next macro name
localmac endp
; DEFINE and ASSIGN macro commands
; Data structures comments. Macro name is stored in table mcctab as if we