TPSRC5 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600
  1. SUB CX,SI ;calc length
  2. kdpad MOV AL,#$20 ;pad with spaces
  3. CALL conput ;write space
  4. LOOP kdpad ;:another one
  5. JMP.b kdnext ;'next dir entry
  6. kdnextln CALL xwriteln ;WriteLn
  7. kdnext MOV AH,#$4F ;get next entry
  8. PUSH DX ;save tab
  9. CALL dos ;get it
  10. POP DX ;restore tab
  11. JNB kddis ;:ok, write it
  12. OR.B DL,DL ;(redundant !)
  13. JMP.b kdend ;'end it
  14. kderr CALL xwriteln ;WriteLn
  15. CALL vidattr2
  16. CALL prints
  17. B "No files",$00
  18. CALL knrmvid
  19. MOV DL,#$01 ;do CR
  20. kdend OR.B DL,DL ;test tab flag
  21. JZ kdend2 ;:no CR
  22. CALL xwriteln ;WriteLn
  23. kdend2 CALL xwriteln ;WriteLn
  24. MOV.B DL,scrpn ;get drive number
  25. SUB.B DL,#$40 ;convert
  26. MOV AH,#$36 ;get disk free space
  27. CALL dos
  28. CMP AX,#$FFFF ;invalid drive ?
  29. JZ kdret ;:yes
  30. MUL CX ;calc bytes/block
  31. OR DX,DX ;many ?
  32. JNZ kdret ;:yes
  33. MUL BX ;* number free blocks
  34. MOV CL,#$0A ;DIV 1024
  35. SHR AX,CL
  36. MOV CL,#$06
  37. SHL DX,CL
  38. ADD AX,DX
  39. CALL knum1 ;write number
  40. CALL prints
  41. B "k bytes free",$00
  42. kdret RET ;"
  43. klogged CALL prints ;L:Logged drive
  44. B "New drive",$00
  45. CALL kreadln ;Read line
  46. MOV.B AL,[BX] ;get char from buffer
  47. CMP AL,#$1A ;EOF ?
  48. JNZ kldef ;:no
  49. MOV AH,#$19 ;get default drive
  50. CALL dos
  51. JMP.b kldef2 ;'ok
  52. kldef CALL upcase ;convert it
  53. SUB AL,#$41 ;< A ?
  54. JB klret ;:wrong
  55. CMP AL,#$0F ;> O ?
  56. JA klret ;:wrong
  57. kldef2 PUSH AX ;save it
  58. MOV AH,#$0D ;reset disk system
  59. CALL dos
  60. POP DX ;restore drive
  61. MOV AH,#$0E ;set default drive
  62. CALL dos
  63. klret RET ;"
  64. kactdir CALL prints ;A:Active directory
  65. B "New directory",$00
  66. CALL kreadln ;read string
  67. JZ karet ;nothing: ret
  68. MOV SI,BX ;source
  69. MOV DX,#pnbuf ;dest: std pathname
  70. MOV DI,DX
  71. MOV CX,#$0040 ;64 bytes
  72. PUSH DS ;DS -> ES
  73. POP ES
  74. CLD ;copy it
  75. REPZ
  76. MOVS.B
  77. MOV DI,DX ;restore ptr to beg
  78. MOV AL,#$1A ;search ^Z
  79. MOV CX,#$0040
  80. REPNZ
  81. SCAS.B
  82. JNZ kaerr ;not found: invalid
  83. MOV.B [DI]-$01,#$00 ;mark end with 0
  84. MOV AH,#$3B ;change directory
  85. CALL dos
  86. OR.B AL,AL ;error ?
  87. JZ karet ;:no
  88. kaerr MOV AL,#$07 ;Bell
  89. CALL conput ;write it
  90. karet RET ;"
  91. kspace CALL prints ;Display space information
  92. B "Code: ",$00
  93. MOV BX,#$2D8B ;(code size-runtime length)/16
  94. MOV CL,#$04
  95. SHR BX,CL
  96. MOV AX,codesize ;(already in paras)
  97. SUB AX,BX
  98. AND AX,#$0FFF
  99. CALL ksize ;write number
  100. CALL prints
  101. B ", ",$00
  102. MOV AX,#$1000 ;(64K-code size)/16
  103. SUB AX,codesize
  104. AND AX,#$0FFF
  105. CALL kpara ;write para
  106. CALL prints
  107. B " free",$0D,$0A,"Data: ",$00
  108. MOV BX,#$024F ;(Data size-std vars)/16
  109. MOV CL,#$04
  110. SHR BX,CL
  111. MOV AX,datasize ;(already paras)
  112. SUB AX,BX
  113. AND AX,#$0FFF
  114. CALL ksize ;write number
  115. CALL prints
  116. B ", ",$00
  117. MOV AX,#$1000 ;(64K-data size)/16
  118. SUB AX,datasize
  119. AND AX,#$0FFF
  120. CALL kpara ;write para
  121. CALL prints
  122. B " free",$0D,$0A,$00
  123. CMP.B codedest,#$01 ;code destination ?
  124. JZ kspmem ;:memory
  125. CMP.B codedest,#$02
  126. JZ kspcom ;:COM-File
  127. RET ;'
  128. kspmem CALL prints
  129. B "Stack/Heap: ",$00
  130. MOV AX,minstksz ;display min stack size
  131. CALL ksize ;write number
  132. JMP xwriteln ;'WriteLn
  133. kspcom CALL prints
  134. B "Stack/Heap: ",$00
  135. MOV AX,minhpsz ;min heap/stack size
  136. CALL ksize ;write number
  137. CALL prints
  138. B " (minimum)",$0D,$0A," ",$00
  139. MOV AX,maxhpsz ;max heap/stack size
  140. CALL ksize ;write number
  141. CALL prints
  142. B " (maximum)",$0D,$0A,$00
  143. RET ;"
  144. ksize PUSH AX ;write number hex and dec
  145. CALL kpara ;write para
  146. CALL prints
  147. B " (",$00
  148. POP AX ;restore number
  149. XOR DX,DX ;clear hi
  150. MOV CX,#$0004
  151. ksize2 SHL AX,1 ;* 16
  152. RCL DX,1
  153. LOOP ksize2 ;:another shift
  154. MOV BX,AX ;number
  155. MOV CX,#$0006 ;field length
  156. CALL knum ;write DX:BX
  157. CALL prints
  158. B " bytes)",$00
  159. RET ;"
  160. kpara CALL whexword ;Write para: hex number
  161. kparastr CALL prints
  162. B " paragraphs",$00
  163. RET ;"
  164. CALL kpara ;WriteLn para
  165. JMP xwriteln ;"
  166. krdhex XOR AX,AX ;Read hex
  167. krxlp PUSH AX ;save number
  168. MOV.B AL,[BX] ;get char
  169. CALL upcase ;UpCase
  170. MOV.B CH,AL ;-> CH
  171. POP AX ;restore number
  172. SUB.B CH,#$30 ;ASCII-translation
  173. JB krxend ;:< 0 - end
  174. CMP.B CH,#$0A ;> 9 ?
  175. JB krxok ;no: ok
  176. SUB.B CH,#$07 ;A..F
  177. CMP.B CH,#$0A ;< A ?
  178. JB krxend ;yes: end
  179. CMP.B CH,#$10 ;> F ?
  180. JNB krxend ;yes: end
  181. krxok MOV CL,#$04 ;number * 16
  182. SHL AX,CL
  183. OR.B AL,CH ;add digit
  184. INC BX ;next char
  185. JMP krxlp ;'continue
  186. krxend RET ;"
  187. kfind CALL prints ;F:Find Error
  188. B "Enter PC",$00
  189. CALL kreadln ;ReadLn
  190. JNZ kfind2 ;:ok
  191. RET ;'nothing entered
  192. kfind2 CALL krdhex ;read hex
  193. MOV errpos2,AX ;store error position
  194. CALL knocode ;set flag: not compiled
  195. kdofind CALL kgetfile ;get file, if necessary
  196. MOV.B cpmode,#$01 ;set flag: searching
  197. CALL prints
  198. B $0D,$0A,"Searching",$00
  199. JMP.b kcnofile ;"do it...
  200. kcomp CALL kgetfile ;C:Compile - get file
  201. CALL kdestfil ;set dest file
  202. CALL prints
  203. B $0D,$0A,"Compiling",$00
  204. CMP.B cpmode,#$00 ;to memory ?
  205. JZ kcnofile ;:yes
  206. CALL prints
  207. B " --> ",$00
  208. MOV SI,#scrpn ;display dest path name
  209. CALL printpn
  210. kcnofile CALL xwriteln ;WriteLn
  211. CALL turbo ;Call compiler
  212. CMP.B cpmode,#$02 ;COM/CHN produced ?
  213. JB kcnoerr ;:no
  214. CMP.B cperr,#$00 ;error ?
  215. JZ kcnoerr ;:no
  216. CALL kdestfil ;set dest file
  217. MOV AH,#$41 ;delete it
  218. MOV DX,#destpn
  219. CALL dos
  220. kcnoerr CMP.B cperr,#$CA ;Compilation aborted ?
  221. JNZ kcnoabrt ;:no
  222. CALL xwriteln ;WriteLn
  223. CALL xwriteln ;WriteLn
  224. CALL vidattr2
  225. CALL prints
  226. B "Compilation aborted",$00
  227. JMP kmainlp ;'return to main menu
  228. kcnoabrt CALL prints
  229. B " lines",$0D,$0A,$0A,$00
  230. CMP.B cperr,#$00 ;error ?
  231. JNZ kctest ;:yes
  232. CMP.B cpmode,#$01 ;find error pos ?
  233. JZ kcnotfnd ;:yes
  234. CALL kspace ;display space info
  235. RET ;'
  236. kcnotfnd CALL vidattr3 ;error pos not found
  237. CALL prints
  238. B "Run-time error position not found",$00
  239. CALL knrmvid
  240. JMP.b kwlnret ;'return to main
  241. kctest CMP.B cperr,#$C9 ;I/O-error ?
  242. JNZ kcfound ;:no
  243. CALL ksfull ;write message
  244. kwlnret CALL xwriteln ;WriteLn
  245. JMP kmainlp ;'return to main menu
  246. kcfound CMP.B cperr,#$C8 ;Error pos found ?
  247. JNZ kcerror ;:no
  248. CALL prints
  249. B "Run-time error position found",$00
  250. JMP kcwend ;'jump to this position
  251. kcerror CALL vidattr3 ;Error message
  252. CALL prints
  253. B "Error ",$00
  254. XOR AX,AX ;get error number
  255. MOV AL,cperr
  256. CALL knum1 ;write it
  257. TEST.B msgflg,#$FF ;error msgs included ?
  258. JZ kcwend ;:no
  259. MOV BX,#txstrt ;pointer to messages
  260. kcmsr MOV.B AL,[BX] ;get char
  261. CMP AL,#$1A ;^Z ?
  262. JZ kcwend ;yes: not found
  263. CMP AL,#$20 ;control char ?
  264. JB kcmsr2 ;:yes
  265. SUB AL,#$30 ;get digit
  266. MOV.B AH,AL ;* 10
  267. ADD.B AL,AL
  268. ADD.B AL,AL
  269. ADD.B AL,AH
  270. ADD.B AL,AL
  271. INC BX
  272. ADD.B AL,[BX] ;get second digit
  273. SUB AL,#$30 ;convert
  274. INC BX ;next char
  275. CMP.B AL,cperr ;= error number ?
  276. JZ kcwmsg ;:yes
  277. kcmsr2 MOV.B AL,[BX] ;get char
  278. INC BX ;next one
  279. CMP AL,#$0D ;end of line ?
  280. JNZ kcmsr2 ;no: search it
  281. INC BX ;next char: skip LF
  282. JMP kcmsr ;'continue searching
  283. kcwmsg CALL prints ;Display error message
  284. B ": ",$00
  285. kcwlp MOV.B AL,[BX] ;get char
  286. CMP AL,#$0D ;CR ?
  287. JZ kcwend ;yes: done
  288. CMP AL,#$20 ;control char ?
  289. JNB kcwchar ;:no - write it
  290. CMP AL,#$1A ;^Z ?
  291. JZ kcwend ;yes: done
  292. MOV SI,#txstrt ;pointer to messages
  293. kcsubsr MOV.B AL,[SI] ;get char
  294. INC SI ;go to next
  295. CMP AL,#$20 ;control char ?
  296. JNB kcwsub ;no: search end of line
  297. CMP.B AL,[BX] ;is it the right one ?
  298. JNZ kcwsub ;:no, next line
  299. kcsubsr2 MOV.B AL,[SI] ;get char - write sub-message
  300. CMP AL,#$0D ;CR ?
  301. JZ kcwnext ;:end
  302. CALL conput ;write it
  303. INC SI ;next one
  304. JMP kcsubsr2 ;'continue
  305. kcwsub MOV.B AL,[SI] ;search end of line
  306. INC SI ;next char
  307. CMP AL,#$0D ;CR ?
  308. JNZ kcwsub ;:no
  309. INC SI ;skip LF
  310. JMP kcsubsr ;'continue searching
  311. kcwchar CALL conput ;display char
  312. kcwnext INC BX ;go to next
  313. JMP kcwlp ;'continue
  314. kcwend MOV.B mainflg,#$00 ;work file used
  315. CMP.B inclflg,#$00 ;error in include file ?
  316. JZ kcnoincl ;:no
  317. MOV AL,#$2E
  318. CALL conput ;write char
  319. CALL knrmvid
  320. CALL ksvnoask
  321. MOV SI,#inclpn ;copy include file name
  322. MOV DI,#workpn ;into work file name
  323. CALL fncopy ;do it
  324. CALL kwload ;load that file
  325. CALL xwriteln ;WriteLn
  326. CALL vidattr3
  327. CALL prints
  328. B "Error found in above include file",$00
  329. JMP.b kcwait ;'go into editor
  330. kcnoincl CMP.B mainpn,#$00 ;main file exists ?
  331. JZ kcwait ;:no
  332. MOV SI,#mainpn ;copy main into
  333. MOV DI,#workpn ;work file name
  334. CALL fncopy ;do it
  335. kcwait CALL waitesc ;wait for ESC
  336. MOV BX,txerrpos ;get error pos in text
  337. DEC BX
  338. JMP editor2 ;"jump into editor
  339. kmem MOV.B codedest,#$01 ;M:memory
  340. RET ;"set flag
  341. kcom MOV.B codedest,#$02 ;C:COM file
  342. RET ;"set flag
  343. kchn MOV.B codedest,#$03 ;H:CHN file
  344. RET ;"set flag
  345. kcs CALL prints ;O:CS size
  346. B "Minimum Code Segment size",$00
  347. CALL kreadln ;read it
  348. MOV AX,#$0000 ;default
  349. JZ kcsdef ;:nothing entered
  350. CALL krdhex ;read hex
  351. MOV BX,#$2D8B ;add runtime size
  352. MOV CL,#$04 ;convert to paras
  353. SHR BX,CL
  354. ADD AX,BX
  355. kcsdef MOV mincssz,AX ;store min CS
  356. RET ;"
  357. kds CALL prints ;D:DS size
  358. B "Minimum Data Segment size",$00
  359. CALL kreadln ;read it
  360. MOV AX,#$0000 ;default
  361. JZ kdsdef ;nothing entered: set it
  362. CALL krdhex ;read hex
  363. MOV BX,#$024F ;add std vars size
  364. MOV CL,#$04
  365. SHR BX,CL ;convert to paras
  366. ADD AX,BX
  367. kdsdef MOV mindssz,AX ;store min DS
  368. RET ;"
  369. kss CALL prints ;S:SS size
  370. B "Minimum Stack Segment size",$00
  371. CALL kreadln ;read it
  372. MOV AX,#$0400 ;default: 16K
  373. JZ kssdef ;nothing entered: set it
  374. CALL krdhex ;read hex
  375. kssdef MOV minhpsz,AX ;store min SS
  376. RET ;"
  377. kmss CALL prints ;A:Max. SS size
  378. B "Maximum Stack Segment size",$00
  379. CALL kreadln ;read it
  380. MOV AX,#$A000 ;default: 640K
  381. JZ kmssdef ;nothing entered: set it
  382. CALL krdhex ;read hex
  383. kmssdef MOV maxhpsz,AX ;store max SS
  384. RET ;"
  385. kparm CALL prints ;P:Parameter line
  386. B "Parameters",$00
  387. MOV SI,#parmlin ;ptr to buffer
  388. CALL kreaddef ;Read line with default
  389. MOV DI,#parmlin ;copy it
  390. MOV CX,#$003B ;count
  391. kparml MOV.B AL,[BX] ;get char
  392. CMP AL,#$1A ;^Z ?
  393. JZ kparme ;yes: end
  394. MOV.B [DI],AL ;store in buffer
  395. INC BX ;next char
  396. INC DI
  397. LOOP kparml ;:another char
  398. kparme MOV.B [DI],#$00 ;mark end of param line
  399. RET ;"
  400. kgetfile CMP.B workpn,#$00 ;load file, if necessary
  401. JNZ kget1 ;:work file defined
  402. CALL kgetfn ;get work file name
  403. kget1 CMP.B mainpn,#$00 ;main file ?
  404. kget2 MOV SI,#workpn
  405. JNZ kget3 ;:work file exists
  406. CALL kgetfn ;copy work -> main file name
  407. MOV AL,#$00 ;use work file
  408. JMP.b kget4 ;'
  409. kget3 CALL kcmpfn ;work = main ?
  410. JZ kget2 ;:yes
  411. CALL ksvnoask ;save without question
  412. MOV vfilbig,#flbigclr ;set error vectors
  413. MOV vnewfil,#flescclr
  414. MOV SI,#mainpn ;main file
  415. CALL kwload2 ;load it
  416. MOV AL,#$FF ;set flag: main file
  417. kget4 MOV mainflg,AL ;store flag
  418. MOV.B errio,#$00 ;clear error flag
  419. RET ;"
  420. kdestfil MOV SI,#mainpn ;Set dest file name
  421. CMP.B [SI],#$00 ;main file name ok ?
  422. JNZ kdsmain ;not null - ok
  423. MOV SI,#workpn ;use work file name
  424. kdsmain CALL fnsisc ;copy to scratch file name
  425. MOV SI,#extcom ;set extension .COM
  426. MOV AL,codedest
  427. MOV.B cpmode,#$00 ;set flag: memory
  428. DEC.B AL ;memory ?
  429. JZ kdsmem ;:yes
  430. MOV.B cpmode,#$02 ;flag: file
  431. DEC.B AL ;COM ?
  432. JZ kdsmem ;:yes
  433. MOV.B cpmode,#$03 ;flag: CHN
  434. MOV SI,#extchn ;set extension .CHN
  435. kdsmem CALL kext ;modify file name
  436. MOV DI,#destpn ;-> dest file name
  437. CALL fnscdi ;copy it
  438. RET ;"
  439. krun CMP.B txcomp,#$00 ;R:Run
  440. JNZ krok ;:already compiled
  441. CALL kcomp ;compile it
  442. krok CMP.B codedest,#$01 ;memory: ok
  443. JZ krmem ;yes: do it
  444. CMP.B codedest,#$02 ;COM-file ?
  445. JNZ krchn
  446. CALL xwriteln ;WriteLn
  447. CALL vidattr2
  448. CALL prints
  449. B "Please Quit TURBO to run .COM file",$00
  450. krchn JMP kmainlp ;'return to menu
  451. krmem MOV SI,#parmlin ;copy command line
  452. MOV DI,#paramlin ;to start of CS
  453. MOV ES,destseg ;seg of compiled program
  454. XOR BX,BX ;clear offset
  455. krparml MOV.B AL,[SI] ;get char
  456. CMP AL,#$00 ;end ?
  457. JZ krparme ;:yes
  458. INC SI ;next char
  459. INC BX
  460. ES:
  461. MOV.B [BX_DI],AL ;store that char
  462. JMP krparml ;'continue
  463. krparme ES:
  464. MOV.B [BX_DI]$01,#$0D ;store CR at the end
  465. ES:
  466. MOV.B [DI],BL ;store length
  467. CALL prints
  468. B $0D,$0A,"Running",$0D,$0A,$00
  469. PUSH destseg ;CS of program
  470. MOV AX,#$0100 ;start of program
  471. PUSH AX
  472. RETF ;'start program
  473. turboret ES: ;return point from program
  474. MOV AL,errio ;error ?
  475. MOV errio,AL
  476. ES:
  477. MOV AX,errpos2 ;get error position
  478. MOV errpos2,AX
  479. MOV AX,#$FFFF ;flag
  480. JMP kmeminit ;"reinit
  481. kclrtxt MOV BX,txbeg ;Clear text
  482. MOV txend,BX ;text beg -> text end
  483. MOV.B txchg,#$00 ;text not changed
  484. MOV.B mainflg,#$00 ;work file
  485. knocode MOV.B txcomp,#$00 ;text not compiled
  486. RET ;"
  487. kquit CALL ksvchng ;Q:Quit - save changes
  488. CALL xcrtexit ;CrtExit
  489. MOV AH,#$4C ;end of process
  490. JMP dos ;"return to MS-DOS
  491. kgetfn CMP.B workpn,#$00 ;Get current file name
  492. JNZ kgf2 ;:work file
  493. CMP.B mainpn,#$00 ;main file ?
  494. JNZ kgfmain ;:yes
  495. CALL kwork ;set work file name
  496. JMP.b kgf2 ;'
  497. kgfmain MOV SI,#mainpn ;main -> work file name
  498. MOV DI,#workpn
  499. CALL fncopy
  500. MOV.B mainflg,#$FF ;flag: main file
  501. CALL kgetfn ;get filename
  502. kgf2 CMP.B mainflg,#$00 ;main file ?
  503. JZ kgfret ;:no
  504. CALL ksvnoask ;save without question
  505. CALL kwload ;load that file
  506. kgfret RET ;"
  507. kcmpfn MOV SI,#workpn ;main = work file ?
  508. MOV DI,#mainpn
  509. kcmpl MOV.B AL,[SI] ;get char
  510. CMP.B AL,[DI] ;compare it
  511. JNZ kcmpnoeq ;:not equal
  512. OR.B AL,AL ;end ?
  513. JZ kcmpret ;:yes
  514. INC SI ;next char
  515. INC DI
  516. JMP kcmpl ;'continue
  517. kcmpnoeq MOV AL,#$01 ;set flag: false
  518. kcmpret RET ;"
  519. kreaderr MOV AX,#txstrt ;Read error message file
  520. MOV txbeg,AX ;set text beg
  521. MOV vnewfil,#flesc ;set error vectors
  522. MOV vfilbig,#flbig
  523. MOV SI,#errpath ;ptr to pathname
  524. MOV DI,#scrpn ;scratch pathname
  525. PUSH DI ;save ptr
  526. PUSH DS ;DS -> ES
  527. POP ES
  528. PUSH CS ;CS -> DS
  529. POP DS
  530. CALL fncopy1 ;copy filename
  531. PUSH ES ;ES -> DS
  532. POP DS
  533. POP SI ;restore ptr
  534. CALL kwload2 ;load file
  535. MOV BX,txend ;store its end position
  536. MOV.B [BX],#$1A ;store ^Z at the end
  537. INC BX ;next char
  538. MOV txbeg,BX ;-> new text beg
  539. RET ;"
  540. kwstrsi PUSH BX ;write string [SI]
  541. MOV BX,#prpnret ;no change
  542. JMP.b prpn2 ;'
  543. printpn PUSH BX ;write pathname: save BX
  544. MOV BX,#upcase ;vector: UpCase
  545. prpn2 CLD
  546. LODS.B ;get char
  547. OR.B AL,AL ;end ?
  548. JZ prpne ;:no
  549. CALL BX ;modify char
  550. CALL conput ;write it
  551. JMP prpn2 ;'continue
  552. prpne POP BX ;restore
  553. prpnret RET ;"
  554. knum1 XOR CX,CX ;write number - unformatted
  555. CALL knum2 ;do it
  556. RET ;"
  557. knumax MOV CX,#$0005 ;write number - 5 digits
  558. XOR DX,DX ;clear hi word
  559. JMP.b knum2 ;'
  560. knum2 XOR DX,DX ;write number DX:BX
  561. knum PUSH SI ;save regs
  562. PUSH DI
  563. PUSH ES
  564. PUSH DS ;DS -> ES
  565. POP ES
  566. PUSH CS ;CS -> DS
  567. POP DS
  568. MOV DI,#knumbuf ;dest buffer
  569. MOV BX,AX ;number to write
  570. PUSH CX ;save field size
  571. CLD
  572. XOR CX,CX ;format flag (leading zeroes)
  573. MOV SI,#kndectab ;ptr decimal table
  574. MOV AH,#$07 ;7 digits
  575. kndig XOR.B AL,AL ;clear digit
  576. kndiglp INC.B AL ;count up
  577. SUB BX,[SI] ;do successive subtraction
  578. SBB DX,[SI]$02
  579. JNB kndiglp ;:continue
  580. ADD BX,[SI] ;restore number
  581. ADC DX,[SI]$02
  582. ADD SI,#$04 ;next table entry
  583. DEC.B AL ;restore digit
  584. JNZ knnot0 ;:not zero
  585. OR CX,CX ;test flag
  586. JZ knnoput
  587. knnot0 ADD AL,#$30 ;convert to ASCII
  588. STOS.B ;store in dest buffer
  589. INC CX ;set flag
  590. knnoput DEC.B AH ;another digit ?
  591. JNZ kndig ;:yes
  592. OR CX,CX ;digits done ?
  593. JNZ knnot00 ;:yes
  594. MOV AL,#$30 ;put a 0
  595. STOS.B
  596. INC CX ;digit count
  597. knnot00 XOR AX,AX ;write a zero at the end
  598. STOS.B
  599. POP AX ;restore field size
  600. PUSH ES ;ES -> DS
  601. POP DS
  602. SUB AX,CX ;fill up with spaces ?
  603. JBE knnopad ;:no
  604. INC CX ;space count
  605. DEC DI
  606. MOV SI,DI ;make space in buffer
  607. ADD DI,AX
  608. STD
  609. REPZ ;move it up
  610. MOVS.B
  611. MOV CX,AX ;now fill with spaces
  612. MOV AL,#$20
  613. REPZ
  614. STOS.B
  615. knnopad MOV SI,#knumbuf ;buffer ptr
  616. CALL kwstrsi ;write string
  617. POP ES ;restore regs
  618. POP DI
  619. POP SI
  620. RET ;"
  621. kndectab W $4240,$000F ;1000000 decimal table
  622. W $86A0,$0001 ; 100000
  623. W $2710,$0000 ; 10000
  624. W $03E8,$0000 ; 1000
  625. W $0064,$0000 ; 100
  626. W $000A,$0000 ; 10
  627. W $0001,$0000 ;" 1
  628. kparse MOV CX,#$000F ;parse filename: no wildcards allowed
  629. kparse2 MOV DI,#scrpn ;dest: scratch file name
  630. MOV AX,[BX] ;get 2 chars: drive spec
  631. CALL upcase ;UpCase
  632. CMP AL,#$20 ;control char ?
  633. JB kpdefdrv ;:yes
  634. CMP.B AH,#$3A ;: ?
  635. JNZ kpdefdrv ;:no
  636. INC BX ;next char
  637. INC BX
  638. JMP.b kpdrv ;'set drive
  639. kpdefdrv MOV AH,#$19 ;get default drive
  640. CALL dos
  641. ADD AL,#$41 ;-> ASCII
  642. MOV AH,#$3A
  643. kpdrv MOV [DI],AX ;store drive spec
  644. INC DI
  645. INC DI
  646. OR.B CH,CH ;test path ?
  647. JNZ kpendpn2 ;:no
  648. CMP.B [BX],#$5C ;\ ?
  649. JZ kpendpn2 ;:yes
  650. MOV.B [DI],#$5C ;store \
  651. INC DI
  652. MOV AH,#$47 ;get current path
  653. MOV.B DL,AL ;drive number
  654. SUB.B DL,#$40
  655. MOV SI,DI ;destination
  656. CALL dos ;do it
  657. JB kpendpn2 ;:error
  658. CMP.B [DI],#$00 ;search end of path
  659. JZ kpendpn2 ;:found
  660. kpendsr MOV.B AL,[DI] ;get char
  661. OR.B AL,AL ;end ?
  662. JZ kpendpn ;:found
  663. INC DI ;next char
  664. CMP DI,#scrpnend ;end of buffer ?
  665. JB kpendsr ;:not yet
  666. JMP.b kpend ;'end it
  667. kpendpn MOV.B [DI],#$5C ;store \
  668. INC DI ;next char
  669. CMP DI,#scrpnend ;end of buffer ?
  670. ;:yes
  671. JZ kpend
  672. kpendpn2 XOR.B CH,CH ;clear flag
  673. PUSH CS ;CS -> ES
  674. POP ES
  675. CLD
  676. kpchklp MOV.B AL,[BX] ;get char
  677. CMP AL,#$20 ;control / space ?
  678. JBE kpend ;:yes
  679. PUSH CX ;save cnt, dest ptr
  680. PUSH DI
  681. MOV DI,#kpinval ;test: illegal char ?
  682. REPNZ ;CL is count for this search
  683. SCAS.B ;search char in table
  684. POP DI ;restore
  685. POP CX
  686. JZ kpend ;found: end it
  687. INC BX ;next char
  688. MOV.B [DI],AL ;store it
  689. INC DI ;next char in dest
  690. CMP DI,#scrpnend ;end of buffer ?
  691. JB kpchklp ;:no
  692. kpend MOV.B [DI],#$00 ;mark end
  693. RET ;"
  694. kpinval B $22,"+,/;<=>[]{|}*?" ;"table of illegal chars
  695. kpasext MOV SI,#extpas ;pointer: .PAS
  696. kextdef PUSH SI ;save extension ptr
  697. CALL kparse ;parse filename
  698. POP SI ;restore ext ptr
  699. MOV DL,#$01 ;only set if no ext
  700. JMP.b kx1 ;'do it
  701. kext2 MOV DL,#$02
  702. JMP.b kx1 ;'
  703. kext XOR.B DL,DL ;set file extension
  704. kx1 MOV DI,#insline2 ;ptr scratch file name
  705. XOR CX,CX ;clr dot pos
  706. kxsrdot MOV.B AL,[DI] ;get char
  707. OR.B AL,AL ;end ?
  708. JZ kxend ;:yes
  709. INC DI ;next one
  710. CMP.B DL,#$02 ;search dot ?
  711. JZ kxsrdot ;:no
  712. CMP AL,#$2E
  713. JNZ kxnodot ;:no
  714. MOV CX,DI ;store pos of dot
  715. kxnodot CMP AL,#$5C ;\ ?
  716. JNZ kxsrdot ;:no
  717. XOR CX,CX ;clear dot pos
  718. JMP kxsrdot ;'continue
  719. kxend OR CX,CX ;test dot pos
  720. JZ kxnodotf ;:not set
  721. OR.B DL,DL ;set extension ?
  722. JNZ kxret ;:no
  723. MOV DI,CX ;dot position
  724. DEC DI ;go back
  725. kxnodotf CS: ;set extension
  726. MOV.B CL,[SI] ;length of extension
  727. XOR.B CH,CH ;-> count
  728. JCXZ kxexte ;:nothing to do
  729. kxextl CMP DI,#scrpnend ;buffer end ?
  730. JZ kxexte ;:yes
  731. INC SI ;next pos
  732. CS:
  733. MOV.B AL,[SI] ;get ext char
  734. MOV.B [DI],AL ;store it
  735. INC DI ;next one
  736. LOOP kxextl ;:another char
  737. kxexte MOV.B [DI],#$00 ;mark end
  738. kxret RET ;"
  739. fnscdi MOV SI,#scrpn ;copy scratch -> [DI]
  740. JMP.b fncopy ;'
  741. fnsisc MOV DI,#scrpn ;copy [SI] -> scratch
  742. fncopy PUSH DS ;DS -> ES
  743. POP ES
  744. fncopy1 MOV CX,#$0020 ;copy 64 bytes
  745. CLD
  746. REPZ
  747. MOVS ;do it
  748. RET ;"
  749. kwscrpn MOV SI,#scrpn ;write scratch file name
  750. JMP printpn ;"
  751. kwworkpn MOV SI,#workpn ;write work file name
  752. JMP printpn ;"
  753. kdworkfn MOV SI,#workpn ;Display work file name
  754. PUSH DS ;DS -> ES
  755. POP ES
  756. CLD
  757. LODS.B ;get char
  758. CALL upcase ;UpCase
  759. CALL conput ;write it (drive)
  760. LODS.B ;get char
  761. CALL conput ;write it (:)
  762. MOV DI,SI ;search end of filename
  763. XOR.B AL,AL
  764. MOV CX,#$FFFF ;any length
  765. CLD
  766. REPNZ
  767. SCAS.B ;search it
  768. STD ;backward search !
  769. MOV AL,#$5C ;now search \
  770. MOV CX,#$FFFF ;any length
  771. DEC DI
  772. REPNZ
  773. SCAS.B ;do it
  774. MOV SI,DI ;position of file name
  775. INC SI ;without dir path
  776. INC SI
  777. JMP printpn ;"write it
  778. printatt PUSH BP ;Print string with highlighting
  779. MOV BP,SP ;string: inline, 0=end
  780. XCHG BX,[BP]$02 ;get return addr
  781. PUSH AX ;save
  782. PUSHF
  783. pralp CS: ;get char
  784. MOV.B AL,[BX]
  785. INC BX ;go to next
  786. OR.B AL,AL ;end ?
  787. JZ praend ;:yes
  788. CMP AL,#$80 ;highlighted ?
  789. JNB prahi ;:yes
  790. CALL klowvid ;LowVideo
  791. JMP.b pralo ;'write it
  792. prahi CALL knrmvid ;NormVideo
  793. AND AL,#$7F ;mask out bit 7
  794. JZ pralp ;zero: end
  795. pralo CALL conput ;write it
  796. JMP pralp ;'next char
  797. praend POPF ;restore
  798. POP AX
  799. XCHG BX,[BP]$02 ;restore ret
  800. POP BP
  801. RET ;"
  802. knrmvid CMP.B curatt,#$00 ;NormVideo
  803. JZ knrmret ;already set: ret
  804. MOV.B curatt,#$00 ;set flag
  805. JMP xnormvid ;'do it
  806. knrmret RET ;"
  807. klowvid CMP.B curatt,#$01 ;LowVideo
  808. JZ knrmret ;:already set
  809. MOV.B curatt,#$01 ;set it
  810. JMP xlowvid ;"
  811. vidattr3 CMP.B curatt,#$03 ;Attribute #3
  812. JZ knrmret ;:already set
  813. MOV.B curatt,#$03 ;set it
  814. PUSH AX ;save
  815. MOV AL,att3 ;set that attribute
  816. MOV attcur,AL
  817. POP AX ;restore
  818. RET ;"
  819. vidattr2 CMP.B curatt,#$02 ;Attribute #2
  820. JZ knrmret ;:already set
  821. MOV.B curatt,#$02 ;set it
  822. PUSH AX ;save
  823. MOV AL,att2 ;set that attribute
  824. MOV attcur,AL
  825. POP AX ;restore
  826. RET ;"
  827. movebk MOV SI,BX ;Block transfer [BX]->[DX]
  828. MOV DI,DX ;forward = delete
  829. PUSH DS ;DS -> ES
  830. POP ES
  831. CLD
  832. REPZ ;CX=count
  833. MOVS.B ;do it
  834. MOV BX,SI ;point to block end
  835. MOV DX,DI
  836. RET ;"
  837. movebkb MOV SI,BX ;Block transfer [BX]->[DX]
  838. MOV DI,DX ;backward = insert
  839. PUSH DS ;DS -> ES
  840. POP ES ;BX,DX point to block END !
  841. STD
  842. REPZ
  843. MOVS.B ;do it
  844. CLD ;reset dir flag
  845. MOV BX,SI ;point to block beg
  846. MOV DX,DI
  847. RET ;"
  848. inited XOR AX,AX ;Init editor vars
  849. MOV editflg,AL
  850. MOV DI,#srend ;390..3B0:=0
  851. MOV CX,#$0021
  852. PUSH DS ;DS -> ES
  853. POP ES
  854. CLD ;fill
  855. REPZ
  856. STOS.B
  857. INC AX ;3B1..3B2:=1
  858. MOV DI,#oldlen ;old len, redisplay from
  859. MOV CX,#$0002
  860. REPZ
  861. STOS.B
  862. INC AX ;Words 3BA..3BD:=2
  863. MOV DI,#bkbegl ;block pos in buffer
  864. MOV CX,#$0002
  865. REPZ
  866. STOS
  867. MOV AX,#$FFFF ;3B3..3B8:=FF
  868. MOV DI,#overflg ;set flags:
  869. MOV CX,#$0006 ;insert, indent, display
  870. REPZ ;redisplay
  871. STOS.B
  872. MOV AX,#line ;Words 3BE..3C8:=046C
  873. MOV DI,#edpos ;current pos, pos in line buffer
  874. MOV CX,#$0006 ;pos FIFO = beg of line buffer
  875. REPZ
  876. STOS
  877. MOV AL,#$00 ;3CA..45F:=0
  878. MOV DI,#cmdbuf ;command entry buffer, search,
  879. MOV CX,#$0096 ;replace, option, filename
  880. REPZ
  881. STOS.B
  882. MOV.B cmdbuf,#$03 ;command buf: 3 chars
  883. MOV.B srword,#$1E ;search word: 30 chars
  884. MOV.B srrepl,#$1E ;replce word: 30 chars
  885. MOV.B stopt,#$0A ;option word: 10 chars
  886. MOV.B fnbuf,#$40 ;file name: 64 chars
  887. MOV.B fnbufend,#$1A ;end file name buffer
  888. MOV lineend,#$0A0D ;end line input buffer
  889. MOV AL,#$00 ;no flicker
  890. MOV DX,#$B000 ;mono screen segment
  891. CMP.B scrmod,#$07 ;mode = 7 ?
  892. JZ inited1 ;yes: mono
  893. CS:
  894. MOV AL,scrflick ;get flicker flag
  895. MOV DH,#$B8 ;set segment
  896. inited1 MOV scrbad,AL ;store flicker flag
  897. MOV scrseg,DX ;store segment
  898. RET ;"
  899. clred MOV bkbeg,BX ;Clear editor vars
  900. MOV bkend,BX ;set to beg of text = BX
  901. MOV edpos,BX
  902. MOV posfifo,BX
  903. MOV qppos,BX
  904. MOV disbeg,BX
  905. RET ;"
  906. ekd CALL eflush ;flush changes
  907. CS:
  908. MOV.B DL,txwiny2 ;bottom-1
  909. DEC.B DL
  910. MOV DH,#$00
  911. CALL setcpos ;set cursor pos
  912. CALL knrmvid ;NormVideo
  913. DEC txend ;end of text
  914. MOV BX,txend
  915. MOV.B [BX],#$1A ;store ^Z at the end
  916. JMP kmainlp ;"return to main menu
  917. editor CALL kgetfn ;E:Editor - get file name
  918. MOV BX,#$FFFF ;position flag
  919. editor2 PUSH BX ;save pos
  920. MOV BX,txend ;end of text
  921. MOV [BX],#$0A0D ;store CR,LF there
  922. INC txend
  923. MOV.B statobs,#$00 ;status line obsolete
  924. MOV.B dislin,#$01 ;redisplay all
  925. MOV sepptr,#eseptab ;pos of word separator tab
  926. CALL knrmvid ;NormVideo
  927. CALL xclrscr ;ClrScr
  928. POP BX ;relative text pos
  929. ADD BX,txbeg ;+text beg+1
  930. INC BX
  931. CALL efsetpos ;set new pos
  932. edmain CALL eredispl ;redisplay
  933. MOV.B CL,statera ;clear status line
  934. OR.B CL,CL ;anything to erase ?
  935. JZ ednoera ;:no
  936. MOV BX,#$0000 ;cursor pos: home
  937. CALL esetcur
  938. CALL esetlow ;LowVideo
  939. MOV AL,#$20 ;space
  940. edera CALL ewritch ;write char
  941. DEC.B CL ;another ?
  942. JNZ edera ;:yes
  943. MOV.B statera,CL ;clear erase flag
  944. ednoera CALL estat ;display status line
  945. CALL edproc ;get command
  946. JNB edchg ;:no command - enter char
  947. JZ edmain ;:not found
  948. CMP.B DH,#$7F ;MSB vector = 1 ?
  949. JB ednochg ;:no
  950. MOV.B txchg,#$FF ;set flag: text changed
  951. MOV.B txcomp,#$00 ;code invalid
  952. AND.B DH,#$7F ;mask vector
  953. ednochg MOV BX,#edmain ;store return addr
  954. PUSH BX ;-> main loop
  955. PUSH DX
  956. MOV BX,#pfifosrc ;do position FIFO
  957. MOV DX,#pfifodst
  958. MOV CX,#$0008 ;8 bytes
  959. JMP movebkb ;'move back, jump to command
  960. eprefix CALL eddiscmd ;^P:Control char prefix - display
  961. CALL keyget ;get char
  962. JMP.b edput ;'enter this char
  963. edchg MOV txchg,AL ;flag: text changed
  964. MOV.B txcomp,#$00 ;code invalid
  965. edput MOV BX,lnpos ;pos in line
  966. CMP BX,#lineend0 ;line full ?
  967. JNB edmain ;yes: ignore char
  968. CMP.B overflg,#$00 ;overwrite ?
  969. JZ edover ;:yes
  970. PUSH AX ;save it
  971. CALL einsch ;make space for char
  972. POP AX ;restore it
  973. edover MOV.B [BX],AL ;store char
  974. INC BX ;cursor right
  975. PUSH BX
  976. CALL eredlin ;redisplay line
  977. POP BX
  978. MOV lnpos,BX ;new pos in line buffer
  979. CALL erepos ;reposition in line
  980. JMP edmain ;"main loop
  981. edproc CALL keyget ;Get command: get key
  982. CMP AL,#$7F ;Delete ?
  983. JZ edpdel ;:yes
  984. CMP AL,#$20 ;control char ?
  985. JNB edpret ;no: no command
  986. edpdel MOV BX,#cmdbuf ;pointer to cmd buf
  987. MOV.B [BX],#$01 ;store length
  988. INC BX
  989. MOV.B [BX],AL ;store char
  990. edploop PUSH BX ;save pos in buf
  991. MOV BX,#cmdbuf ;ptr cmd buf
  992. MOV SI,#ecmd1 ;ptr first cmd table
  993. MOV CH,#$FF ;must be equal
  994. CALL edsrcmd ;search in table
  995. POP BX ;restore pos
  996. OR.B AL,AL ;test result
  997. JNZ edpfnd ;:found
  998. PUSH BX ;save again
  999. MOV BX,#cmdbuf ;ptr cmd buf
  1000. MOV SI,#ecmd2 ;ptr second cmd table
  1001. MOV CH,#$1F ;second char without ctrl ok
  1002. CALL edsrcmd ;search in table
  1003. POP BX ;restore pos
  1004. OR.B AL,AL ;test result
  1005. STC
  1006. JZ edpret ;:not found
  1007. edpfnd DEC.B AL
  1008. JZ edpcont ;:need another key
  1009. MOV BX,#ejmptab ;ptr jump table
  1010. ADD BX,CX ;+2*cmd number
  1011. ADD BX,CX
  1012. CS:
  1013. MOV DX,[BX] ;get jump addr
  1014. STC ;ok
  1015. edpret RET ;'
  1016. edpcont CALL eddiscmd ;display command char
  1017. PUSHF ;save stat
  1018. CALL keyget ;get key
  1019. INC.B cmdbuf ;inc lenght cmd buf
  1020. INC BX ;next pos
  1021. MOV.B [BX],AL ;store char
  1022. POPF ;restore stat: function key ?
  1023. JNZ edploop ;:continue
  1024. CALL eddiscmd ;display
  1025. JMP edploop ;"try it again
  1026. eddiscmd CALL ekbdstat ;display command sequence
  1027. JNZ edpret ;late - ret
  1028. PUSH BX ;save pos
  1029. XOR BX,BX ;clear char count
  1030. MOV.B statera,BL ;number of chars to erase
  1031. CALL esetcur ;set position: home
  1032. MOV BX,#cmdbuf ;ptr cmd buf
  1033. MOV.B AL,[BX] ;get cmd length
  1034. eddislp PUSH AX ;save len
  1035. INC BX ;next char
  1036. MOV.B AL,[BX] ;get char
  1037. ADD.B statera,#$02 ;2 chars to erase
  1038. CALL edcntput ;put char
  1039. POP AX ;restore len
  1040. DEC.B AL ;another char ?
  1041. JNZ eddislp ;:yes
  1042. POP BX ;restore
  1043. RET ;"
  1044. edcntput PUSH AX ;Display control code - save char
  1045. CALL esetnrm ;set attribute
  1046. POP AX ;restore char
  1047. CMP AL,#$20 ;control ?
  1048. JB edcntl ;:yes
  1049. JMP ewritch ;'write char
  1050. edcntl PUSH AX ;save char
  1051. PUSH AX
  1052. MOV AL,#$5E ;write ^
  1053. CALL ewritch
  1054. POP AX ;restore char
  1055. ADD AL,#$40 ;-> normal char
  1056. CALL ewritch ;write it
  1057. POP AX ;restore char
  1058. RET ;"
  1059. edsrcmd MOV CL,#$FF ;Search command in table
  1060. PUSH CX ;save cmd comparison mask
  1061. PUSH BX ;command buf ptr
  1062. edsclp POP BX ;restore
  1063. POP CX
  1064. CS:
  1065. MOV.B AL,[SI] ;get char from table
  1066. INC SI ;next pos
  1067. OR.B AL,AL ;end of table ?
  1068. JZ edscret ;:yes
  1069. INC.B CL ;command number
  1070. PUSH CX ;save
  1071. PUSH BX
  1072. MOV.B CL,[BX] ;get command len
  1073. INC BX ;go to first char
  1074. SUB.B AL,CL ;>= table len ?
  1075. JNB edsc1 ;:yes
  1076. ADD.B CL,AL ;skip this entry
  1077. JMP.b edscnxt1 ;'try next one
  1078. edsc1 LAHF ;save flags
  1079. PUSH AX ;save table entry length
  1080. edsccmp CS:
  1081. MOV.B AL,[SI] ;char from table
  1082. SUB.B AL,[BX] ;compare them
  1083. AND.B AL,CH ;mask difference
  1084. JNZ edscnext ;:not equal - next one
  1085. INC SI ;next char
  1086. INC BX
  1087. DEC.B CL ;= length of cmd ?
  1088. JNZ edsccmp ;no: compare
  1089. POP AX ;restore flag, table entry length
  1090. SAHF
  1091. POP BX ;restore
  1092. POP CX
  1093. MOV CH,#$00 ;mode: none
  1094. MOV AL,#$FF ;found
  1095. JZ edscret ;:found
  1096. MOV AL,#$01 ;need another char
  1097. edscret RET ;'
  1098. edscnext POP AX ;restore length
  1099. ADD.B AL,CL ;skip entry
  1100. MOV.B CL,AL
  1101. edscnxt1 MOV CH,#$00 ;clr hi
  1102. ADD SI,CX ;add to ptr
  1103. JMP edsclp ;"try next one
  1104. estat CALL ekbdstat ;Display status line: Get KBD stat
  1105. JNZ edscret ;late: ret
  1106. CALL klowvid ;LowVideo
  1107. CMP.B statobs,#$FF ;obsolete ?
  1108. JZ estnrm ;no:just display pos
  1109. MOV.B statobs,#$FF ;clear flag
  1110. MOV BX,#$0000 ;screen position
  1111. MOV oldpos,BX ;remember cursor pos
  1112. MOV.B edcol,BL ;column
  1113. CALL esetcur ;set cursor pos
  1114. CALL eclrlin ;clear line
  1115. CS:
  1116. CMP.B txwinx2,#$38 ;screen width sufficient ?
  1117. JB estshrt ;:no
  1118. MOV BX,#$2A00 ;set cursor pos
  1119. CALL esetcur
  1120. CALL kdworkfn ;display filename
  1121. estshrt MOV BX,#$0600 ;cursor pos
  1122. CALL ewritpos ;put string
  1123. B "Line ",$00
  1124. MOV BX,#$1000 ;cursor pos
  1125. CALL ewritpos ;put string
  1126. B "Col ",$00
  1127. MOV BX,#$1800 ;cursor pos
  1128. CMP.B overflg,#$00 ;Overwrite ?
  1129. JZ estover ;:yes
  1130. CALL ewritpos ;put string
  1131. B "Insert ",$00
  1132. JMP.b estins ;'
  1133. NOP
  1134. estover CALL ewritpos ;put string
  1135. B "Overwrite ",$00
  1136. estins CMP.B indntflg,#$00 ;Indent ?
  1137. JZ estnrm ;:no
  1138. CALL ewrits ;put string
  1139. B "Indent",$00
  1140. estnrm MOV AL,horscr ;calc column
  1141. ADD.B AL,phcol
  1142. INC.B AL
  1143. CMP.B AL,edcol ;= old col ?
  1144. JZ estnocol
  1145. MOV edcol,AL ;set that column
  1146. MOV BX,#$1400 ;cursor pos
  1147. CALL esetcur ;set it
  1148. CALL klowvid ;LowVideo
  1149. MOV.B BL,AL ;number -> BX
  1150. MOV BH,#$00 ;clr hi
  1151. MOV AL,#$03 ;3 chars
  1152. CALL ednum ;display number
  1153. estnocol MOV BX,edpos ;current pos = old pos ?
  1154. CMP BX,oldpos
  1155. JNZ estrow ;no: display line number
  1156. JMP eposcur ;'restore cursor pos
  1157. estrow CALL eposcur ;restore cursor pos
  1158. CALL ekbdstat ;Get KBD stat
  1159. JNZ estend
  1160. MOV DI,txbeg ;beg of text
  1161. MOV CX,edpos
  1162. MOV DX,#$0001 ;line number
  1163. SUB CX,DI ;calc count
  1164. JZ estrow2 ;:done
  1165. estcnt CLD ;forward search
  1166. PUSH DS ;DS -> ES
  1167. POP ES
  1168. estlf MOV AL,#$0A ;search LF
  1169. REPNZ
  1170. SCAS.B
  1171. JNZ estrow2 ;:not found, done
  1172. INC DX ;count it
  1173. OR.B DL,DL ;256 lines counted ?
  1174. JNZ estlf ;:no, continue
  1175. CALL ekbdstat ;Get KBD stat
  1176. JZ estcnt ;:nothing entered
  1177. JMP.b estend
  1178. estrow2 MOV BX,#$0B00 ;cursor pos
  1179. PUSH DX ;save line number
  1180. CALL esetcur ;set cursor pos
  1181. CALL klowvid ;LowVideo
  1182. POP BX ;restore number
  1183. MOV AL,#$05 ;5 digits
  1184. CALL ednum ;write it
  1185. MOV BX,edpos ;current pos -> old pos
  1186. MOV oldpos,BX
  1187. estend JMP eposcur ;"restore cursor pos
  1188. ednum PUSH AX ;Write number: save field length
  1189. MOV CH,#$00 ;clear flag
  1190. CALL edcvt ;convert number
  1191. POP AX ;restore length
  1192. ADD.B AL,CH ;counter
  1193. JZ ednret ;:done
  1194. ;counter
  1195. MOV.B CH,AL
  1196. MOV AL,#$20 ;pad with spaces
  1197. ednpad CALL ewritch ;put it
  1198. DEC.B CH ;another ?
  1199. JNZ ednpad ;:yes
  1200. ednret RET ;"
  1201. edcvt CMP BX,#$00 ;number -> decimal
  1202. MOV AL,#$30
  1203. JZ edcvno0 ;0: store a 0
  1204. MOV DX,#$2710 ;digit 10000
  1205. CALL edcvdig
  1206. MOV DX,#$03E8 ;digit 1000
  1207. CALL edcvdig
  1208. MOV DX,#$0064 ;digit 100
  1209. CALL edcvdig
  1210. MOV DX,#$000A ;digit 10
  1211. CALL edcvdig
  1212. MOV DX,#$0001 ;digit 1
  1213. edcvdig XOR.B AL,AL ;clear digit
  1214. edcvdlp SUB BX,DX ;do successive subtraction
  1215. JB edcvput ;:done
  1216. INC.B AL ;count digit
  1217. JMP edcvdlp ;'
  1218. edcvput ADD BX,DX ;restore number
  1219. ADD AL,#$30 ;convert to ASCII
  1220. CMP AL,#$30 ;0 ?
  1221. JNZ edcvno0 ;:no
  1222. OR.B CH,CH ;is it a leading zero ?
  1223. JZ ednret
  1224. edcvno0 DEC.B CH ;set flag
  1225. JMP ewritch ;"write char
  1226. edreadst CALL prints ;Input from status line
  1227. B ": ",$00
  1228. MOV BX,DX ;destination ptr
  1229. MOV SI,DX
  1230. INC BX ;point to string
  1231. MOV.B DH,[BX] ;get old length
  1232. MOV.B [BX],#$00 ;clr old length
  1233. INC BX ;go to string
  1234. erloop MOV.B disflg,#$00 ;flag: editing stat line
  1235. PUSH DX ;save regs
  1236. PUSH BX
  1237. PUSH SI
  1238. CALL edproc ;process key
  1239. POP SI
  1240. POP BX
  1241. POP DX
  1242. MOV.B disflg,#$FF ;restore flag
  1243. JNB erput ;no command: put char
  1244. JNZ ercr ;:valid command
  1245. MOV AL,cmdbuf1 ;get command
  1246. CALL etstint ;test for interrupt
  1247. JMP erloop ;'loop back
  1248. ercr MOV.B AL,CL ;command code
  1249. CMP AL,#$00 ;CR ?
  1250. JNZ errt ;:no
  1251. MOV.B [BX],#$1A ;store ^Z at the end
  1252. RET ;'return
  1253. errt CMP AL,#$03 ;Character right ?
  1254. JNZ errecall ;:no
  1255. MOV.B AL,[SI]$01 ;get length
  1256. CMP.B AL,DH ;= pos ?
  1257. JNB erloop
  1258. INC.B [SI]$01 ;go right
  1259. JMP.b errest ;'get char from old value
  1260. errecall CMP AL,#$05 ;word right ?
  1261. JNZ erclr ;:no
  1262. errec1 MOV.B AL,[SI]$01 ;length = old len ?
  1263. CMP.B AL,DH
  1264. JZ erloop ;yes: loop
  1265. MOV.B AL,[BX] ;get char
  1266. CALL edcntput ;write it
  1267. INC BX ;next one
  1268. INC.B [SI]$01 ;inc len
  1269. JMP errec1 ;'until end
  1270. erclr CMP AL,#$04 ;Word left ?
  1271. JNZ erprefix ;:no
  1272. erclrl CALL erdelc ;delete char
  1273. JNZ erclrl ;:ok, continue
  1274. JMP erloop ;'end reached, loop
  1275. erprefix CMP AL,#$2D ;Control char prefix ?
  1276. JNZ erdel ;:no
  1277. CALL keyget ;get a key
  1278. JMP.b erput ;'put it
  1279. erdel CMP AL,#$1B ;Test delete codes
  1280. JZ erdel1 ;:delete left
  1281. CMP AL,#$1C
  1282. JZ erdel1 ;:del left
  1283. CMP AL,#$01
  1284. JZ erdel1 ;:char left
  1285. CMP AL,#$02
  1286. JNZ erinv ;:no delete
  1287. erdel1 CALL erdelc ;delete char
  1288. JMP erloop ;'loop back
  1289. erinv CMP.B cmdbuf1,#$12 ;word right ?
  1290. JZ errec1 ;:yes
  1291. JMP erloop ;'loop back
  1292. erput MOV.B DL,AL ;save char
  1293. MOV.B AL,[SI]$01 ;current len
  1294. CMP.B AL,[SI] ;< max len ?
  1295. JB erput2 ;:ok
  1296. JMP erloop ;'loop back
  1297. erput2 INC.B [SI]$01 ;inc length
  1298. MOV.B [BX],DL ;store char
  1299. errest MOV.B AL,[BX] ;get char
  1300. INC BX ;go to next
  1301. CALL edcntput ;display it
  1302. MOV.B AL,[SI]$01 ;get current len
  1303. CMP.B AL,DH ;= old len ?
  1304. JNB ergend ;:no
  1305. JMP erloop ;'loop back
  1306. ergend MOV.B DH,[SI]$01 ;get pos
  1307. JMP erloop ;'loop back
  1308. erdelc MOV.B AL,[SI]$01 ;Delete char: get len
  1309. OR.B AL,AL ;0 ?
  1310. JZ erdelret ;yes: nothing to delete
  1311. DEC.B [SI]$01 ;dec length
  1312. DEC BX ;go back one char
  1313. CMP.B [BX],#$20 ;was it a control char ?
  1314. JNB erdelcc ;:no
  1315. CALL erdelcc ;delete two chars
  1316. erdelcc CALL prints ;delete one char
  1317. B $08," ",$08,$00
  1318. MOV AL,#$FF ;set flag
  1319. OR.B AL,AL
  1320. erdelret RET ;"
  1321. efind MOV.B srmode,#$00 ;^QF:Find - set mode flag
  1322. CALL eqffind ;get find word
  1323. CALL eqfopt ;get option string
  1324. JMP.b efnd1 ;"do it
  1325. eqffind CALL eclrstat ;Get find word: clear stat line
  1326. CALL ewrits ;write string
  1327. B "Find",$00
  1328. MOV DX,#srword ;dest: find word
  1329. JMP edreadst ;"read string
  1330. eqfrepl CALL eclrs2 ;Get repl word: clear stat line
  1331. CALL ewrits ;write string
  1332. B "Replace with",$00
  1333. MOV DX,#srrepl ;dest var
  1334. JMP edreadst ;"read string
  1335. eqfopt CALL eclrs2 ;Get Options: clear stat line
  1336. CALL ewrits ;write string
  1337. B "Options",$00
  1338. MOV DX,#stopt ;dest var
  1339. CALL edreadst ;read string
  1340. CS:
  1341. MOV.B BH,txwinx2 ;end of screen
  1342. DEC.B BH
  1343. MOV BL,#$00 ;beg of line
  1344. JMP esetcur ;"set cursor pos
  1345. ereplace MOV.B srmode,#$FF ;^QA:Search & Replace
  1346. CALL eqffind ;get find word
  1347. CALL eqfrepl ;get replacement word
  1348. CALL eqfopt ;get option string
  1349. JMP.b efnd1 ;"do it
  1350. erepeat CALL eddiscmd ;^L:Repeat last find
  1351. efnd1 CALL eflush ;write back current line
  1352. CALL esrcend ;end of line buffer
  1353. INC BX ;+1
  1354. MOV DX,lnpos ;or current pos in line
  1355. CALL emin
  1356. MOV DX,#line ;- beg of buffer
  1357. SUB BX,DX
  1358. MOV DX,edpos ;+ current pos
  1359. ADD BX,DX
  1360. MOV srpos,BX ;-> search pos
  1361. MOV srcnt,#$0000 ;line count
  1362. MOV CX,txend ;text end-1
  1363. DEC CX
  1364. MOV srend,CX ;-> search end
  1365. MOV CX,txbeg ;text beg -> search beg
  1366. MOV srbeg,CX
  1367. MOV BX,#sropt1 ;ptr option string
  1368. MOV.B CH,[BX] ;get length
  1369. MOV.B sropt,#$00 ;clear option flag
  1370. OR.B CH,CH ;empty ?
  1371. JNZ efndcnt ;:no
  1372. JMP.b efndopte ;'no options set
  1373. NOP ;Process option line
  1374. efndcnt INC BX ;next char
  1375. MOV.B AL,[BX] ;get char
  1376. CMP AL,#$30 ;valid digit ?
  1377. JB efndopt ;:no
  1378. CMP AL,#$3A ;> 9 ?
  1379. JNB efndopt ;:no digit
  1380. SUB AL,#$30 ;-> number. Get line count
  1381. CBW
  1382. PUSH AX ;save digit
  1383. MOV AL,#$0A ;current count * 10
  1384. IMUL srcnt
  1385. POP DX ;+ digit
  1386. ADD AX,DX
  1387. MOV srcnt,AX ;-> line count
  1388. JMP.b efndo2 ;'continue
  1389. efndopt CALL upcase ;UpCase
  1390. CMP AL,#$57 ;W ?
  1391. JNZ efndu ;:no
  1392. OR.B sropt,#$01 ;flag: whole words
  1393. efndu CMP AL,#$55 ;U ?
  1394. JNZ efndn ;:no
  1395. OR.B sropt,#$04 ;flag: ignore upper/lower
  1396. efndn CMP AL,#$4E ;N ?
  1397. JNZ efndg ;:no
  1398. OR.B sropt,#$02 ;flag: replace without asking
  1399. efndg CMP AL,#$47 ;G ?
  1400. JNZ efndb ;:no
  1401. OR.B sropt,#$08 ;flag: global
  1402. efndb CMP AL,#$42 ;B ?
  1403. JNZ efndl ;:no
  1404. OR.B sropt,#$10 ;flag: backwards
  1405. efndl CMP AL,#$4C ;L ?
  1406. JNZ efndo2 ;:no
  1407. OR.B sropt,#$20 ;flag: search block
  1408. AND.B sropt,#$F7 ;clear global
  1409. MOV CX,bkend ;search block, only
  1410. MOV srend,CX ;block end -> search end
  1411. MOV CX,bkbeg ;block beg -> search beg
  1412. MOV srbeg,CX
  1413. efndo2 DEC.B CH ;another option char ?
  1414. JNZ efndcnt ;:yes
  1415. efndopte CMP srcnt,#$01 ;at least one line to do
  1416. JA efndcnok ;:ok
  1417. MOV srcnt,#$0001
  1418. efndcnok MOV BX,srbeg ;begin limit
  1419. MOV AL,sropt ;option
  1420. TEST AL,#$10 ;backwards ?
  1421. JZ efndfwd ;:no
  1422. MOV BX,srend ;end limit
  1423. efndfwd TEST AL,#$28 ;block & global ?
  1424. JNZ efndrep ;:no
  1425. MOV BX,srpos ;current pos
  1426. efndrep MOV srpos,BX ;store search pos
  1427. TEST.B sropt,#$10 ;backwards ?
  1428. JNZ efndbkw ;:yes
  1429. CMP BX,srend ;= search limit ?
  1430. JB efndsrc ;:no, continue
  1431. JMP efndexit ;'done
  1432. efndbkw DEC BX ;go back
  1433. CMP BX,srbeg ;= search limit ?
  1434. JNB efndsrc ;:no
  1435. JMP efndexit ;'end it
  1436. efndsrc MOV DX,#srword2 ;ptr searched word
  1437. MOV AL,srword1 ;get length
  1438. MOV.B CH,AL
  1439. TEST.B sropt,#$10 ;backwards ?
  1440. JZ efndfw2 ;:no
  1441. DEC.B AL ;go to its end
  1442. ADD.B AL,DL
  1443. MOV.B DL,AL
  1444. JNB efndfw2
  1445. INC.B DH
  1446. efndfw2 TEST.B sropt,#$01 ;whole words ?
  1447. JZ efndall1 ;:no
  1448. PUSH DX ;save
  1449. PUSH BX
  1450. CALL edbeg ;at the beginning ?
  1451. MOV.B AL,[BX] ;get char
  1452. POP BX ;restore
  1453. POP DX
  1454. JB efndall1 ;:at beg
  1455. CALL edfnchar ;is it alphanum ?
  1456. JB efndpos ;:yes - continue searching
  1457. efndall1 OR.B CH,CH ;length = 0 ?
  1458. JZ efndnil ;:found
  1459. efndcmp CALL edcmp ;compare chars
  1460. JNZ efndpos ;:not the same
  1461. DEC.B CH ;another char ?
  1462. JNZ efndnch ;:yes
  1463. efndnil TEST.B sropt,#$01 ;whole words ?
  1464. JZ efndall2 ;:no
  1465. PUSH BX ;save
  1466. CALL edend ;end ?
  1467. MOV.B AL,[BX] ;get char
  1468. POP BX ;restore
  1469. JB efndall2 ;:at the end
  1470. CALL edfnchar ;alphanum ?
  1471. JB efndpos ;yes: not valid
  1472. efndall2 TEST.B sropt,#$10 ;backwards ?
  1473. JNZ efndbw2 ;:yes
  1474. INC BX ;end of text ?
  1475. CMP BX,txend
  1476. efndbw2 CMP.B srmode,#$00 ;search mode ?
  1477. JZ efndfnd ;:find
  1478. CALL edoreplc ;replace it
  1479. efndfnd TEST.B sropt,#$28 ;block global ?
  1480. JZ efndnxt ;:yes
  1481. JMP efndrep ;'continue
  1482. efndnxt DEC srcnt ;another line to process ?
  1483. JZ efndend ;:no
  1484. JMP efndrep ;'continue
  1485. efndend JMP.b efsetpos ;'set new pos
  1486. NOP
  1487. efndnch PUSH DX ;save pos
  1488. CALL edend ;at the end ?
  1489. POP DX ;restore
  1490. JB efndexit ;:yes
  1491. TEST.B sropt,#$10 ;backwards ?
  1492. JZ efndfw3 ;:no
  1493. DEC DX ;go back
  1494. JMP efndcmp ;'
  1495. efndfw3 INC DX ;next char
  1496. JMP efndcmp ;'continue
  1497. efndpos MOV BX,srpos ;get current search pos
  1498. CALL edend ;at the end ?
  1499. JB efndexit ;:yes
  1500. JMP efndrep ;'continue
  1501. efndexit CALL edrange ;end search: limit new pos
  1502. CALL efsetpos ;set pos
  1503. TEST.B sropt,#$28 ;global block ?
  1504. JNZ espret ;:no
  1505. CALL eclrstat ;clear status line
  1506. CALL ewriterr ;write string
  1507. B "Search string not found",$00
  1508. JMP waitesc ;"wait for ESC
  1509. efsetpos CALL esetpos ;set position
  1510. JMP erstlin ;"restore line
  1511. esetpos MOV DX,txend ;Set pos
  1512. DEC DX ;text end - 1
  1513. CMP BX,DX ;= current ?
  1514. JB esp2 ;:below
  1515. XCHG BX,DX ;limit it
  1516. esp2 PUSH BX ;save
  1517. PUSH BX
  1518. CALL esrcbeg ;search beg of that line
  1519. MOV edpos,BX ;-> current pos
  1520. XCHG BX,DX ;-> DX
  1521. POP BX ;restore
  1522. SUB BX,DX ;calc pos in line
  1523. MOV DX,#line ;+ buffer offset
  1524. ADD BX,DX
  1525. MOV lnpos,BX ;-> pos in line buffer
  1526. CALL erepos ;reposition in current line
  1527. CALL eseldisp ;do selective rewrite
  1528. POP BX ;restore pos
  1529. espret RET ;"
  1530. edrange MOV DX,txbeg ;bring BX into range:
  1531. CALL emin ;>= text beg,
  1532. MOV BX,txend
  1533. DEC BX
  1534. JMP emin ;"< text end
  1535. edfnchar CMP AL,#$30 ;char in alphanum ?
  1536. JB edfnch2 ;<0: no
  1537. CMP AL,#$3A
  1538. JB edfnchrt ;0..9: yes
  1539. CMP AL,#$41
  1540. JB edfnch2 ;<A: no
  1541. CMP AL,#$5B
  1542. JB edfnchrt ;A..Z: yes
  1543. CMP AL,#$61
  1544. JB edfnch2 ;<a: no
  1545. CMP AL,#$7B
  1546. JB edfnchrt ;a..z: yes
  1547. edfnch2 OR.B AL,AL ;test flag
  1548. RET ;"
  1549. edbeg TEST.B sropt,#$10 ;At the beginning ?
  1550. JZ edend2 ;:forward
  1551. edbeg2 INC BX
  1552. CMP BX,srend ;= search limit end ?
  1553. CMC
  1554. edfnchrt RET ;'
  1555. edend TEST.B sropt,#$10 ;end reached ?
  1556. JZ edbeg2 ;:forward
  1557. edend2 DEC BX
  1558. CMP BX,srbeg ;= search limit beg ?
  1559. RET ;"
  1560. edcmp XCHG DX,BX ;Compare chars
  1561. MOV.B AL,[BX] ;get char in search string
  1562. XCHG DX,BX
  1563. CMP AL,#$01 ;wild card ?
  1564. JZ edfnchrt ;yes: ok
  1565. CMP.B AL,[BX] ;compare it
  1566. JZ edfnchrt ;yes: ok
  1567. TEST.B sropt,#$04 ;ignore upper/lower ?
  1568. JZ edcmp2 ;:no, just compare
  1569. CALL edfnchar ;is it a valid char ?
  1570. JNB edcmp2 ;:no
  1571. XOR.B AL,[BX] ;mask different bits
  1572. AND AL,#$DF
  1573. RET ;'
  1574. edcmp2 CMP.B AL,[BX] ;compare it
  1575. RET ;"
  1576. edoreplc PUSH BX ;Do replace
  1577. CALL ekbdstat ;get KBD stat
  1578. JZ erpdis ;nothing: display it
  1579. TEST.B sropt,#$02 ;replace without asking ?
  1580. JNZ erpdoit ;:yes
  1581. erpdis CALL efsetpos ;set new position
  1582. CALL eredispl ;redisplay
  1583. TEST.B sropt,#$02 ;replace without asking ?
  1584. JNZ erpdoit ;:yes
  1585. CALL eclrs2 ;clear status line
  1586. CALL printatt ;write string
  1587. B "Replace (",$D9,"/",$CE,"): ",$00
  1588. erpblnk MOV.B BL,phrow ;Blink cursor: alternate
  1589. MOV.B BH,phcol ;status line / cursor pos
  1590. CALL esetcur ;set cursor pos
  1591. MOV CX,#$0004 ;do 4 times
  1592. erpbw1 CALL ekbdstat ;get KBD stat
  1593. JNZ erpbw2 ;:key pressed
  1594. MOV BX,#$0064 ;wait 100 ms
  1595. PUSH CX ;save count
  1596. CALL delaybx ;Delay
  1597. POP CX ;restore
  1598. LOOP erpbw1 ;:another
  1599. MOV BX,#$0F00 ;pos:status line
  1600. CALL esetcur ;set cursor pos