asmlib.a 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548
  1. (* Copyright (C) 1987 Jensen & Partners International *)
  2. (*Global equates *)
  3. (*
  4. The "ROM" string denotes those sections requiring modification when
  5. creating ROMmable code.
  6. *)
  7. (*ROM
  8. A number of these routines make use of the Int 8 timer tick - they are
  9. marked with an "(*INT8*)" string. If the target machine does not provide
  10. a user timer tick via Int 8, then 1) don't use any of the facilities that
  11. need it; or 2) implement an Int 8.
  12. *)
  13. True=1
  14. False=0
  15. Timer=40H (* 8253-5 Programmable Interval Timer *)
  16. PPIport=60H (* 8255A-5 Programmable Peripheral Interface *)
  17. KBCtrl=61H
  18. module AsmLib
  19. segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  20. public AsmLib$HashString : ssize= 12; segm=10; offs=8; modulus=6;
  21. push bp; mov bp,sp
  22. push ds; push es; push si; push di;
  23. sub dx,dx
  24. sub ax,ax
  25. mov cx,[bp][ssize]
  26. jcxz $Exit
  27. mov ds,[bp][segm]
  28. mov si,[bp][offs]
  29. sub bx,bx
  30. mov di,[bp][ssize]
  31. $loop:
  32. lodsb
  33. or al,al
  34. jz $EndLoop
  35. xor dl,al
  36. rol dx,1
  37. rol dx,1
  38. rol dx,1
  39. add dx,di
  40. sub dx,cx
  41. loop $loop
  42. $EndLoop:
  43. mov ax,dx
  44. sub dx,dx
  45. div word [bp][modulus]
  46. $Exit:
  47. mov ax,dx
  48. pop di; pop si; pop es; pop ds
  49. pop bp; ret far 8
  50. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  51. public AsmLib$Move : s_seg=14; s_ofs=12; d_seg=10; d_ofs=8; len=6
  52. push bp; mov bp,sp
  53. push ds; push es; push si; push di
  54. mov si,[bp][s_ofs]
  55. mov di,[bp][d_ofs]
  56. mov ax,[bp][s_seg]
  57. mov bx,[bp][d_seg]
  58. mov cx,si
  59. mov dx,di
  60. shr cx,1
  61. shr cx,1
  62. shr cx,1
  63. shr cx,1
  64. shr dx,1
  65. shr dx,1
  66. shr dx,1
  67. shr dx,1
  68. add ax,cx
  69. add bx,dx
  70. mov cx,[bp][len]
  71. and si,000FH;
  72. and di,000FH;
  73. cld
  74. mov ds,ax
  75. mov es,bx
  76. cmp ax,bx
  77. ja $Forwards (* (at least a paragraph apart) *)
  78. jb $Backwards
  79. cmp si,di
  80. ja $Forwards
  81. je $Exit
  82. cmp si,di
  83. jae $Forwards
  84. $Backwards:
  85. add si,cx
  86. add di,cx
  87. dec si
  88. dec di
  89. std
  90. $Forwards:
  91. rep
  92. movsb
  93. cld
  94. $Exit:
  95. pop di; pop si; pop es; pop ds
  96. pop bp; ret far 10
  97. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  98. public AsmLib$WordMove : s_seg=14; s_ofs=12; d_seg=10; d_ofs=8; len=6;
  99. push bp; mov bp,sp
  100. push ds; push es; push si; push di
  101. mov si,[bp][s_ofs]
  102. mov di,[bp][d_ofs]
  103. mov ax,[bp][s_seg]
  104. mov bx,[bp][d_seg]
  105. mov cx,si
  106. mov dx,di
  107. shr cx,1
  108. shr cx,1
  109. shr cx,1
  110. shr cx,1
  111. shr dx,1
  112. shr dx,1
  113. shr dx,1
  114. shr dx,1
  115. add ax,cx
  116. add bx,dx
  117. mov cx,[bp][len]
  118. and si,000FH
  119. and di,000FH
  120. cld
  121. mov ds,ax
  122. mov es,bx
  123. cmp ax,bx
  124. ja $Forwards (* (at least a paragraph apart) *)
  125. jb $Backwards
  126. cmp si,di
  127. ja $Forwards
  128. je $Exit
  129. cmp si,di
  130. jae $Forwards
  131. $Backwards:
  132. mov ax,cx
  133. dec ax
  134. shl ax,1
  135. add si,ax
  136. add di,ax
  137. std
  138. $Forwards:
  139. rep
  140. movsw
  141. cld
  142. $Exit:
  143. pop di; pop si; pop es; pop ds;
  144. pop bp; ret far 10
  145. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  146. public AsmLib$Fill : d_seg=12; d_ofs=10; len=8; val=6
  147. push bp; mov bp,sp
  148. push es; push di
  149. mov cx,[bp][len]
  150. les di,[bp][d_ofs]
  151. mov ax,[bp][val]
  152. mov ah,al
  153. shr cx,1
  154. rep
  155. stosw
  156. jnc $Exit
  157. stosb
  158. $Exit:
  159. pop di; pop es
  160. pop bp; ret far 8
  161. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  162. public AsmLib$WordFill : d_seg=12; d_ofs=10; len=8; val=6
  163. push bp; mov bp,sp
  164. push es; push di
  165. mov cx,[bp][len]
  166. les di,[bp][d_ofs]
  167. mov ax,[bp][val]
  168. rep
  169. stosw
  170. pop di; pop es
  171. pop bp; ret far 8
  172. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  173. public @NormPtr :
  174. mov cx,ax
  175. and ax,000FH
  176. shr cx,1
  177. shr cx,1
  178. shr cx,1
  179. shr cx,1
  180. add dx,cx
  181. ret near 0
  182. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  183. extrn @NormPtr
  184. public AsmLib$AddAddr : a_H=10; a_L=8; c_val=6
  185. push bp; mov bp,sp
  186. mov ax,[bp][a_L]
  187. mov dx,[bp][a_H]
  188. add ax,[bp][c_val]
  189. jnc $NoOverflow
  190. add dx,1000H
  191. $NoOverflow:
  192. call near @NormPtr
  193. pop bp; ret far 6
  194. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  195. extrn @NormPtr
  196. public AsmLib$SubAddr : a_H=10; a_L=8; c_val=6
  197. push bp; mov bp,sp
  198. mov ax,[bp][a_L]
  199. mov dx,[bp][a_H]
  200. sub ax,[bp][c_val]
  201. jnc $NoOverflow
  202. sub dx,1000H
  203. $NoOverflow:
  204. call near @NormPtr
  205. pop bp; ret far 6
  206. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  207. extrn @NormPtr
  208. public AsmLib$IncAddr : a_ptrH=10; a_ptrL=8; incr=6
  209. push bp; mov bp,sp
  210. push ds
  211. lds bx,[bp][a_ptrL]
  212. mov ax,[bx]
  213. mov dx,[bx][2]
  214. add ax,[bp][incr]
  215. jnc $NoOverflow
  216. add dx,1000H
  217. $NoOverflow:
  218. call near @NormPtr
  219. mov [bx],ax
  220. mov [bx][2],dx
  221. pop ds
  222. pop bp; ret far 6
  223. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  224. extrn @NormPtr
  225. public AsmLib$DecAddr : a_ptrH=10; a_ptrL=8; decr=6
  226. push bp; mov bp,sp
  227. push ds
  228. lds bx,[bp][a_ptrL]
  229. mov ax,[bx]
  230. mov dx,[bx][2]
  231. sub ax,[bp][decr]
  232. jnc $NoOverflow
  233. sub dx,1000H
  234. $NoOverflow:
  235. call near @NormPtr
  236. mov [bx],ax
  237. mov [bx][2],dx
  238. pop ds
  239. pop bp; ret far 6
  240. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  241. extrn @UserBreak
  242. public AsmLib$UserBreak :
  243. mov bp,sp
  244. jmp @UserBreak
  245. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  246. extrn @Abort
  247. public AsmLib$FatalError:
  248. (* three parameters len,a_ptrH,a_ptrL *)
  249. pop ax
  250. (*public AsmLib@FatalError:*)
  251. pop ax
  252. pop si
  253. pop ds
  254. pop cx
  255. sub sp,cx
  256. sub sp,2
  257. mov di,sp
  258. push ss
  259. pop es
  260. jcxz $abort
  261. $Loop:
  262. lodsb
  263. or al,al
  264. jz $EndLoop
  265. stosb
  266. loop $Loop
  267. $EndLoop:
  268. mov al,36 (* '$' *)
  269. stosb
  270. push es
  271. pop ds
  272. mov dx,sp
  273. mov ah,9
  274. int 21H
  275. $abort:
  276. jmp @Abort
  277. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  278. extrn @D_DATA
  279. extrn @ErrorCode
  280. public AsmLib$SetReturnCode : retcode=6
  281. push bp ; mov bp, sp; push ds
  282. mov ax,[bp][retcode]
  283. mov ds, cs:[@D_DATA]
  284. mov [@ErrorCode],al
  285. pop ds; pop bp; ret far 2
  286. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  287. extrn @SetBreakInterrupt
  288. public AsmLib$EnableBreakCheck :
  289. call @SetBreakInterrupt
  290. ret far 0
  291. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  292. extrn @ResetBreakInterrupt
  293. public AsmLib$DisableBreakCheck :
  294. push ds
  295. call @ResetBreakInterrupt
  296. sub ax,ax
  297. mov ds,ax
  298. pushf
  299. cli
  300. mov word ds:[23H*4], DummyBreak
  301. mov word ds:[23H*4][2],cs
  302. popf
  303. pop ds
  304. ret far 0
  305. DummyBreak :
  306. iret
  307. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  308. public AsmLib$SetJmp :
  309. push bp
  310. mov bp,sp
  311. les di,[bp][6] (* buffer *)
  312. push ss
  313. pop ds
  314. mov si,sp
  315. movsw
  316. movsw
  317. movsw
  318. mov ax,sp
  319. stosw
  320. sub ax,ax
  321. JmpReturn:
  322. pop bp
  323. ret far 4
  324. public AsmLib$LongJmp :
  325. add sp,4 (* remove return *)
  326. pop ax (* return value *)
  327. pop si (* buffer *)
  328. pop ds
  329. mov sp,[si][6]
  330. push ss
  331. pop es
  332. mov di,sp
  333. movsw
  334. movsw
  335. movsw
  336. jmp JmpReturn
  337. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  338. public AsmLib$ScanR : d_seg=12; d_ofs=10; len=8; val=6
  339. push bp; mov bp,sp
  340. push es; push di
  341. mov cx,[bp][len]
  342. jcxz ExitScan
  343. les di,[bp][d_ofs]
  344. mov ax,[bp][val]
  345. repne
  346. scasb
  347. jne ExitScan
  348. inc cx
  349. ExitScan:
  350. mov ax,[bp][len]
  351. sub ax,cx
  352. pop di; pop es
  353. pop bp; ret far 8
  354. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  355. public AsmLib$ScanL : d_seg=12; d_ofs=10; len=8; val=6
  356. push bp; mov bp,sp
  357. push es; push di;
  358. mov cx,[bp][len]
  359. jcxz ExitScan
  360. les di,[bp][d_ofs]
  361. mov ax,[bp][val]
  362. std
  363. repne
  364. scasb
  365. cld
  366. jne ExitScan
  367. inc cx
  368. ExitScan:
  369. mov ax,[bp][len]
  370. sub ax,cx
  371. pop di; pop es
  372. pop bp; ret far 8
  373. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  374. public AsmLib$ScanNeR : d_seg=12; d_ofs=10; len=8; val=6
  375. push bp; mov bp,sp
  376. push es; push di
  377. mov cx,[bp][len]
  378. jcxz ExitScan
  379. les di,[bp][d_ofs]
  380. mov ax,[bp][val]
  381. repe
  382. scasb
  383. je ExitScan
  384. inc cx
  385. ExitScan:
  386. mov ax,[bp][len]
  387. sub ax,cx
  388. pop di; pop es
  389. pop bp; ret far 8
  390. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  391. public AsmLib$ScanNeL : d_seg=12; d_ofs=10; len=8; val=6
  392. push bp; mov bp,sp
  393. push es; push di
  394. mov cx,[bp][len]
  395. jcxz ExitScan
  396. les di,[bp][d_ofs]
  397. mov ax,[bp][val]
  398. std
  399. repe
  400. scasb
  401. cld
  402. je ExitScan
  403. inc cx
  404. ExitScan:
  405. mov ax,[bp][len]
  406. sub ax,cx
  407. pop di; pop es
  408. pop bp; ret far 8
  409. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  410. public AsmLib$Compare : s_seg=14; s_ofs=12; d_seg=10; d_ofs=8; len=6
  411. push bp; mov bp,sp
  412. push ds; push es; push si; push di
  413. mov cx,[bp][len]
  414. jcxz ExitScan
  415. lds si,[bp][s_ofs]
  416. les di,[bp][d_ofs]
  417. repe
  418. cmpsb
  419. je ExitScan
  420. inc cx
  421. ExitScan:
  422. mov ax,[bp][len]
  423. sub ax,cx
  424. pop di; pop si; pop es; pop ds;
  425. pop bp; ret far 10
  426. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  427. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  428. public AsmLib$Sound : FreqHz=6
  429. (*ROM
  430. Generate sounds via the speaker. The machine may not have a speaker, or it
  431. may be accessed in a different way.
  432. *)
  433. push bp; mov bp,sp
  434. mov bx,[bp][FreqHz]
  435. mov ax,34DDH (* 1.193181 MHz *)
  436. mov dx,0012H
  437. cmp dx,bx
  438. jnb SOU9
  439. div bx
  440. mov bx,ax
  441. in al,PPIport+1
  442. test al,03H
  443. jnz SOU1
  444. or al,03H
  445. out PPIport+1,al
  446. (* 10 11 011 0 *)
  447. mov al,0B6H (* Select timer 2, LSB,MSB, mode 3, bin *)
  448. out Timer+3,al
  449. SOU1:
  450. mov al,bl
  451. out Timer+2,al
  452. mov al,bh
  453. out Timer+2,al
  454. SOU9:
  455. pop bp; ret far 2
  456. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  457. public AsmLib$NoSound :
  458. (*ROM
  459. Stop producing sound via the speaker. See the above comments.
  460. *)
  461. in al,PPIport+1
  462. and al,0FCH
  463. out PPIport+1,al
  464. ret far 0
  465. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  466. public AsmLib$Speaker : TotalTime=10; OnTime=8; OffTime=6
  467. (*ROM
  468. Generate sounds via the speaker. See the above comments.
  469. *)
  470. push bp; mov bp,sp
  471. in al,KBCtrl
  472. push ax
  473. mov bx,TotalTime
  474. $MainLoop:
  475. and al,0FCH
  476. jmp $Next
  477. $Next:
  478. out KBCtrl,al
  479. mov cx,OffTime
  480. $OffLoop:
  481. loop $OffLoop
  482. or al,2
  483. out KBCtrl,al
  484. mov cx,OnTime
  485. $OnLoop:
  486. loop $OnLoop
  487. dec bx
  488. jnz $MainLoop
  489. pop ax
  490. out KBCtrl,al
  491. ret far 6
  492. section;
  493. segment D_DATA(M_DATA,28H)
  494. segment INITCODE(CODE,28H)
  495. segment C_CODE(CODE,28H)
  496. group G_CODE(INITCODE,C_CODE)
  497. select D_DATA
  498. @DelayFactor : org 2
  499. Iter : org 2
  500. Count : org 2
  501. Semaphor : org 2
  502. select C_CODE
  503. extrn @D_DATA
  504. public AsmLib$Delay : p_time=6
  505. push bp; mov bp,sp; push ds
  506. mov ax, [bp][p_time]
  507. mov ds, cs:[@D_DATA]
  508. mov ds:[Iter], ax
  509. MoreDelay:
  510. cmp word ds:[Iter],0
  511. jz DelayEnd
  512. mov ax,ds:[@DelayFactor]
  513. mov ds:[Count],ax
  514. Here:
  515. mov ax, ds:[Count]
  516. or ax,ax
  517. jz Here2
  518. dec word ds:[Count]
  519. jmp Here
  520. Here2:
  521. dec word ds:[Iter]
  522. jmp MoreDelay
  523. DelayEnd:
  524. pop ds; pop bp; ret far 2
  525. (* the Int 1C ISR, installed below *)
  526. TimeTrap:
  527. push ds
  528. mov ds, cs:[@D_DATA]
  529. inc word ds:[Semaphor] (* used when establishing delay factor *)
  530. pop ds
  531. iret
  532. select INITCODE
  533. (* calibrate timer *)
  534. (*ROM
  535. (*INT8*)
  536. This routine uses the INT 1C hardware tick, instead of the INT 8 user timer
  537. tick. It relies on the hardware tick happening at the rate defined for
  538. PC's.
  539. *)
  540. xor ax,ax
  541. mov es,ax
  542. push es:[70H]
  543. push es:[72H]
  544. mov ds, cs:[@D_DATA]
  545. mov word ds:[Semaphor],0
  546. mov word ds:[@DelayFactor],55
  547. mov word ds:[Iter],0
  548. mov word ds:[Count],0
  549. cli
  550. mov word es:[70H],TimeTrap
  551. mov es:[72H],cs
  552. sti
  553. Estab1:
  554. cmp word ds:[Semaphor],2
  555. jne Estab1
  556. Estab2:
  557. cmp word ds:[Semaphor],3
  558. jz Estab5
  559. mov ax,ds:[@DelayFactor]
  560. mov ds:[Count],ax
  561. Estab3:
  562. mov ax,ds:[Count]
  563. or ax,ax
  564. jz Estab4
  565. dec word ds:[Count]
  566. jmp Estab3
  567. Estab4:
  568. inc word ds:[Iter]
  569. jmp Estab2
  570. Estab5:
  571. cli
  572. pop es:[72H]
  573. pop es:[70H]
  574. sti
  575. mov ax,ds:[Iter]
  576. mov ds:[@DelayFactor],ax
  577. in al,PPIport+1
  578. and al,0FCH
  579. out PPIport+1,al
  580. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  581. axr=0; bxr=2; cxr=4; dxr=6; bpr=8;
  582. sir=10; dir=12; dsr=14; esr=16; flags=18
  583. public @LoadRegisters :
  584. (* loads register in register pack pointed to by DS:SI *)
  585. push [si][dsr]
  586. push [si][sir]
  587. mov ax,[si][axr]
  588. mov bx,[si][bxr]
  589. mov cx,[si][cxr]
  590. mov dx,[si][dxr]
  591. mov di,[si][dir]
  592. mov bp,[si][bpr]
  593. mov es,[si][esr]
  594. pop si
  595. pop ds
  596. ret near 0
  597. public @SaveRegisters :
  598. (* saves register in register pack pointed to by pointer on stack *)
  599. push ds
  600. push si
  601. mov si,sp
  602. lds si,ss:[si][6]
  603. pushf
  604. pop [si][flags]
  605. pop [si][sir]
  606. pop [si][dsr]
  607. mov [si][axr],ax
  608. mov [si][bxr],bx
  609. mov [si][cxr],cx
  610. mov [si][dxr],dx
  611. mov [si][dir],di
  612. mov [si][bpr],bp
  613. mov [si][esr],es
  614. ret near 4
  615. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  616. extrn @D_DATA
  617. extrn @LoadRegisters
  618. extrn @SaveRegisters
  619. extrn @InProgramFlag
  620. extrn @StopProgramFlag
  621. extrn AsmLib$FatalError
  622. msg1 : db 'Fatal error: Dos reentered',0
  623. public AsmLib$Dos : p_seg=8; p_off=6
  624. (*ROM
  625. Perform a DOS call. Since you're in ROM, DOS probably doesn't exist. All
  626. references to this procedure should be removed.
  627. *)
  628. push bp; mov bp,sp
  629. push ds; push es; push si; push di
  630. pushf
  631. mov ds, cs:[@D_DATA]
  632. cmp byte [@InProgramFlag], 1
  633. je ok
  634. cld
  635. mov ax,100
  636. push ax
  637. push cs
  638. mov ax, msg1
  639. push ax
  640. push cs
  641. call near AsmLib$FatalError
  642. ok:
  643. cmp byte [@StopProgramFlag], 1
  644. je Stop (* wait for timer to stop us *)
  645. mov byte [@InProgramFlag], 0
  646. lds si,[bp][p_off]
  647. push ds (* save register pointer *)
  648. push si
  649. call @LoadRegisters
  650. int 21H
  651. call @SaveRegisters
  652. mov ds, cs:[@D_DATA]
  653. mov byte [@InProgramFlag], 1
  654. popf
  655. pop di; pop si; pop es; pop ds
  656. pop bp; ret far 4
  657. Stop:
  658. sti
  659. jmp Stop
  660. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  661. extrn @LoadRegisters
  662. extrn @SaveRegisters
  663. public AsmLib$Intr : p_seg=10; p_off=8; p_num=6
  664. (*ROM
  665. Perform a software interrupt. This procedure uses self-modifying code to
  666. generate an arbitrary interrupt.
  667. *)
  668. push bp; mov bp,sp
  669. push ds; push es; push si; push di
  670. pushf
  671. lds si,[bp][p_off]
  672. push ds (* save register pointer *)
  673. push si
  674. mov al,[bp][p_num]
  675. cli
  676. mov cs:[InterruptNo],al
  677. call @LoadRegisters
  678. db 0CDH (* INT *)
  679. InterruptNo :
  680. db 0
  681. call @SaveRegisters
  682. popf
  683. pop di; pop si; pop es; pop ds
  684. pop bp; ret far 6
  685. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  686. extrn @D_DATA
  687. extrn @PSP
  688. public AsmLib$Environment : p_n=6
  689. (*ROM
  690. Get an environment string. The environment is set up by DOS, which
  691. probably doesn't exist.
  692. *)
  693. push bp; mov bp,sp
  694. push ds; push es; push si; push di
  695. mov ds, cs:[@D_DATA]
  696. mov ds, [@PSP]
  697. mov es, ds:[2CH]
  698. mov di,0
  699. mov cx,[bp][p_n]
  700. xor ax,ax
  701. jcxz EnFound
  702. cmp byte es:[di],0
  703. je EnFound
  704. mov bx,cx
  705. EnSeMo:
  706. mov cx,8000H
  707. repne
  708. scasb
  709. cmp es:[di],al
  710. je EnFound
  711. dec bx
  712. jnz EnSeMo
  713. EnFound:
  714. mov dx,es
  715. mov ax,di
  716. pop di; pop si; pop es; pop ds
  717. pop bp; ret far 2
  718. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  719. extrn AsmLib@CommandLine
  720. comma=44
  721. space=32
  722. public AsmLib$ParamStr : p_sl=12; p_sh=10; p_s=8; p_n=6
  723. (*ROM
  724. Get an argument from the command line. Since DOS probably doesn't exist,
  725. there won't be a command line.
  726. *)
  727. push bp; mov bp,sp
  728. push ds; push es; push si; push di
  729. les di,[bp][p_s]
  730. mov ax, seg AsmLib@CommandLine
  731. mov ds,ax
  732. lds si,ds:[AsmLib@CommandLine]
  733. mov cx,[bp][p_n]
  734. jcxz $Finished
  735. jmp $Loop1
  736. $Loop:
  737. lodsb
  738. cmp al,0
  739. je $Finished
  740. cmp al,comma
  741. je $Loop1
  742. cmp al,space
  743. ja $Loop
  744. (* remove leading separators *)
  745. $Loop1:
  746. lodsb
  747. cmp al,0
  748. je $Finished
  749. cmp al,comma
  750. je $Loop1
  751. cmp al,space
  752. jbe $Loop1
  753. loop $Loop
  754. mov cx,[bp][p_sl]
  755. add cx,di
  756. $Loop2:
  757. stosb
  758. cmp di,cx
  759. je $Exit
  760. lodsb
  761. cmp al,0
  762. je $Finished
  763. cmp al,comma
  764. je $Finished
  765. cmp al,space
  766. ja $Loop2
  767. $Finished:
  768. sub al,al
  769. stosb
  770. $Exit:
  771. pop di; pop si; pop es; pop ds
  772. pop bp; ret far 8
  773. public AsmLib$ParamCount :
  774. (*ROM
  775. Return the number of arguments on the command line. See the above comment.
  776. *)
  777. push di; push si
  778. push bx
  779. mov si,sp
  780. sub di,di
  781. $Loop3:
  782. inc di
  783. mov ax,1
  784. push ax
  785. push ss
  786. push si
  787. push di
  788. call far AsmLib$ParamStr
  789. cmp byte ss:[si],0
  790. jne $Loop3
  791. dec di
  792. mov ax,di
  793. pop bx
  794. pop si; pop di
  795. ret far 0
  796. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  797. public AsmLib$Caps : Slen=10; Sseg=8; Sofs=6
  798. push bp; mov bp,sp
  799. push ds; push si
  800. lds si,[bp][Sofs]
  801. mov cx,[bp][Slen]
  802. $loop:
  803. lodsb
  804. cmp al,97 (* 'a' *)
  805. jb $notSmall
  806. cmp al,122 (* 'z' *)
  807. ja $notSmall
  808. sub al,32
  809. mov [si][-1],al
  810. $notSmall:
  811. or al,al
  812. loopnz $loop
  813. pop si; pop ds
  814. pop bp; ret far 6
  815. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  816. public AsmLib$Length : Slen=10; Sseg=8; Sofs=6
  817. push bp; mov bp,sp
  818. push es; push di
  819. les di,[bp][Sofs]
  820. mov cx,[bp][Slen]
  821. sub al,al
  822. repne
  823. scasb
  824. jne ExitLength
  825. inc cx
  826. ExitLength:
  827. mov ax,[bp][Slen]
  828. sub ax,cx
  829. pop di; pop es
  830. pop bp; ret far 6
  831. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  832. public AsmLib$CompareStr : S1len=16; S1seg=14; S1ofs=12; S2len=10; S2seg=8; S2ofs=6
  833. push bp; mov bp,sp
  834. push ds; push si; push es; push di
  835. lds si,[bp][S1ofs]
  836. les di,[bp][S2ofs]
  837. mov bx,[bp][S1len]
  838. mov dx,[bp][S2len]
  839. mov cx,bx
  840. cmp cx,dx
  841. jb CompareLoop
  842. mov cx,dx
  843. CompareLoop:
  844. lodsb
  845. scasb
  846. jne NotEqual
  847. or al,al
  848. loopne CompareLoop
  849. je Equal
  850. cmp bx,dx
  851. je Equal
  852. ja CheckSi
  853. cmp byte es:[di],0
  854. je Equal
  855. Less:
  856. mov ax,-1
  857. jmp Return
  858. CheckSi:
  859. cmp byte [si],0
  860. je Equal
  861. Greater:
  862. mov ax,1
  863. jmp Return
  864. NotEqual:
  865. cmp al,es:[di][-1]
  866. jb Less
  867. jmp Greater
  868. Equal:
  869. sub ax,ax
  870. Return:
  871. pop di; pop es; pop si; pop ds
  872. pop bp; ret far 12
  873. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  874. public AsmLib$Concat : NSlen=22; NSseg=20; NSofs=18; S1len=16; S1seg=14; S1ofs=12; S2len=10; S2seg=8; S2ofs=6
  875. push bp; mov bp,sp
  876. push ds; push si; push es; push di
  877. mov cx,[bp][S2len]
  878. sub sp,cx
  879. lds si,[bp][S2ofs]
  880. push ss
  881. pop es
  882. mov di,sp
  883. rep
  884. movsb
  885. mov bx,[bp][NSlen]
  886. lds si,[bp][S1ofs]
  887. les di,[bp][NSofs]
  888. mov cx,[bp][S1len]
  889. CopyLoop1:
  890. lodsb
  891. or al,al
  892. jz Finished1
  893. stosb
  894. dec bx
  895. loopnz CopyLoop1
  896. jz Exit
  897. Finished1:
  898. push ss
  899. pop ds
  900. mov si,sp
  901. mov cx,[bp][S2len]
  902. CopyLoop2:
  903. lodsb
  904. stosb
  905. or al,al
  906. jz Exit
  907. dec bx
  908. loopnz CopyLoop2
  909. jz Exit
  910. sub al,al
  911. stosb
  912. Exit:
  913. add sp,[bp][S2len]
  914. pop di; pop es; pop si; pop ds
  915. pop bp; ret far NSlen-4
  916. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  917. public AsmLib$Append : NSlen=16; NSseg=14; NSofs=12; Slen=10; Sseg=8; Sofs=6
  918. push bp; mov bp,sp
  919. push ds; push si; push es; push di
  920. les di,[bp][NSofs]
  921. mov cx,[bp][NSlen]
  922. sub al,al
  923. repne
  924. scasb
  925. jne Exit
  926. dec di
  927. mov bx,cx
  928. inc bx
  929. lds si,[bp][Sofs]
  930. mov cx,[bp][Slen]
  931. CopyLoop:
  932. lodsb
  933. stosb
  934. or al,al
  935. jz Exit
  936. dec bx
  937. loopnz CopyLoop
  938. jz Exit
  939. sub al,al
  940. stosb
  941. Exit:
  942. pop di; pop es; pop si; pop ds
  943. pop bp; ret far NSlen-4
  944. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  945. public AsmLib$Copy : NSlen=16; NSseg=14; NSofs=12; Slen=10; Sseg=8; Sofs=6
  946. push bp; mov bp,sp
  947. push ds; push si; push es; push di
  948. les di,[bp][Sofs]
  949. mov cx,[bp][Slen]
  950. sub al,al
  951. repne
  952. scasb
  953. jne LengthCalc
  954. inc cx
  955. LengthCalc:
  956. mov ax,[bp][Slen]
  957. sub ax,cx
  958. mov cx,[bp][NSlen]
  959. cmp ax,cx
  960. ja SourceBigger
  961. mov cx,ax
  962. SourceBigger:
  963. lds si,[bp][ Sofs]
  964. les di,[bp][NSofs]
  965. rep
  966. movsb
  967. jae Exit
  968. sub al,al
  969. stosb
  970. Exit:
  971. pop di; pop es; pop si; pop ds
  972. pop bp; ret far NSlen-4
  973. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  974. public AsmLib$Slice : NSlen=20; NSseg=18; NSofs=16; Slen=14; Sseg=12; Sofs=10; P=8; L=6
  975. push bp; mov bp,sp
  976. push ds; push si; push es; push di
  977. les di,[bp][Sofs]
  978. mov cx,[bp][Slen]
  979. sub al,al
  980. repne
  981. scasb
  982. jne LengthCalc
  983. inc cx
  984. LengthCalc:
  985. mov ax,[bp][Slen]
  986. sub ax,cx
  987. mov bx,[bp][P]
  988. sub ax,bx
  989. ja NotBeyondEnd
  990. sub ax,ax
  991. NotBeyondEnd:
  992. cmp ax,[bp][L]
  993. jb OffEnd
  994. mov ax,[bp][L]
  995. OffEnd:
  996. lds si,[bp][Sofs]
  997. add si,[bp][P]
  998. mov cx,[bp][NSlen]
  999. cmp ax,cx
  1000. ja SourceBigger
  1001. mov cx,ax
  1002. SourceBigger:
  1003. les di,[bp][NSofs]
  1004. rep
  1005. movsb
  1006. jae Exit
  1007. sub al,al
  1008. stosb
  1009. Exit:
  1010. pop di; pop es; pop si; pop ds
  1011. pop bp; ret far NSlen-4
  1012. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  1013. public AsmLib$Pos : Slen=16; Sseg=14; Sofs=12; Plen=10; Pseg=8; Pofs=6
  1014. push bp; mov bp,sp
  1015. push ds; push si; push es; push di
  1016. les di,[bp][Sofs]
  1017. mov cx,[bp][Slen]
  1018. mov bx,cx
  1019. sub al,al
  1020. repne
  1021. scasb
  1022. jne LengthCalc1
  1023. inc cx
  1024. LengthCalc1:
  1025. sub bx,cx
  1026. les di,[bp][Pofs]
  1027. mov cx,[bp][Plen]
  1028. mov dx,cx
  1029. sub al,al
  1030. repne
  1031. scasb
  1032. jne LengthCalc2
  1033. inc cx
  1034. LengthCalc2:
  1035. sub dx,cx
  1036. sub bx,dx
  1037. jb NotFound
  1038. mov ds,[bp][Sseg]
  1039. sub ax,ax
  1040. SearchLoop:
  1041. mov si,[bp][Sofs]
  1042. add si,ax
  1043. mov di,[bp][Pofs]
  1044. mov cx,dx
  1045. repe
  1046. cmpsb
  1047. je Found
  1048. inc ax
  1049. cmp ax,bx
  1050. jbe SearchLoop
  1051. NotFound:
  1052. mov ax,0FFFFH
  1053. Found:
  1054. Exit:
  1055. pop di; pop es; pop si; pop ds
  1056. pop bp; ret far Slen-4
  1057. section ;
  1058. segment D_DATA(M_DATA,28H); segment C_CODE(CODE,28H); group G_CODE(C_CODE);
  1059. (*ROM
  1060. These values are for direct-memory access to the screen memory.
  1061. *)
  1062. ColorStatusReg =03DAH (* port value for color status register *)
  1063. ColorRetrace =1 (* mask in color status for horiz. retrace *)
  1064. ColorVertRetrace =8 (* mask in color status for vert. retrace *)
  1065. extrn @D_DATA
  1066. select D_DATA
  1067. public AsmLib@ActivePage : org 1
  1068. public AsmLib@IsColor : org 1
  1069. public AsmLib@IsSnow : org 1
  1070. select C_CODE
  1071. public AsmLib@BWSeg : dw 0B000H
  1072. public AsmLib@ColorSeg : dw 0B800H
  1073. public AsmLib$BufferWrite : BuffH=16; BuffL=14; StrH=12; StrL=10; Len=8; Attr=6
  1074. push bp; mov bp,sp
  1075. push ds; push es; push si; push di
  1076. mov cx,[bp][Len]
  1077. jcxz $Exit
  1078. mov bx,[bp][Attr]
  1079. lds si,[bp][StrL]
  1080. les di,[bp][BuffL]
  1081. LDoWrite:
  1082. cld
  1083. mov ah,bl
  1084. LWriteLoop:
  1085. lodsb
  1086. stosw
  1087. loop LWriteLoop
  1088. $Exit:
  1089. pop di; pop si; pop es; pop ds
  1090. pop bp; ret far BuffH-4
  1091. public AsmLib$PalXlat : ToH=18; ToL=16; FromH=14; FromL=12; Len=10; PalH=8; PalL=6
  1092. push bp; mov bp,sp
  1093. push ds; push es; push si; push di
  1094. mov cx,[bp][Len]
  1095. jcxz PXExit
  1096. sub sp,10
  1097. mov di,sp
  1098. (* copy pallette onto stack *)
  1099. lds si,[bp][PalL]
  1100. push ss
  1101. pop es
  1102. mov cx,5
  1103. rep
  1104. movsw
  1105. mov bx,sp
  1106. lds si,[bp][FromL]
  1107. les di,[bp][ToL]
  1108. mov cx,[bp][Len]
  1109. PXloop:
  1110. lodsw
  1111. xchg al,ah
  1112. db 36H (* ss override for xlat *)
  1113. xlat
  1114. xchg al,ah
  1115. stosw
  1116. loop PXloop
  1117. add sp,10
  1118. PXExit:
  1119. pop di; pop si; pop es; pop ds
  1120. pop bp; ret far ToH-4
  1121. public AsmLib$BufferToScreen : X=14; Y=12; SourceH=10; SourceL=8; Len=6
  1122. push bp; mov bp,sp
  1123. push ds; push es; push si; push di
  1124. lds si,[bp][SourceL]
  1125. mov ax,[bp][Y]
  1126. mov di,[bp][X]
  1127. mov cl,4
  1128. shl ax,cl (* 16Y *)
  1129. add di,ax
  1130. shl ax,1
  1131. shl ax,1
  1132. add di,ax (* +64Y=80Y *)
  1133. shl di,1
  1134. mov cx,[bp][Len]
  1135. mov es,cs:[AsmLib@BWSeg]
  1136. push ds
  1137. mov ds, cs:[@D_DATA]
  1138. cmp byte [AsmLib@IsColor],True
  1139. jne BtsIsBW
  1140. cmp byte [AsmLib@IsSnow],True
  1141. mov es,cs:[AsmLib@ColorSeg]
  1142. jne BtsNoSnowMove
  1143. pop ds
  1144. pushf
  1145. mov dx,ColorStatusReg
  1146. mov bl,1
  1147. cld
  1148. sti
  1149. push bp
  1150. BtsLoop:
  1151. lodsw
  1152. mov bp,ax
  1153. BtsWaitNotHoriz:
  1154. in al,dx
  1155. rcr al,1
  1156. jc BtsWaitNotHoriz
  1157. cli
  1158. BtsWait:
  1159. in al,dx
  1160. rcr al,1
  1161. jnc BtsWait
  1162. xchg ax,bp
  1163. stosw
  1164. sti
  1165. loop BtsLoop
  1166. pop bp
  1167. popf
  1168. jmp BtsRet
  1169. BtsNoSnowMove:
  1170. BtsIsBW:
  1171. pop ds
  1172. cld
  1173. rep
  1174. movsw
  1175. BtsRet:
  1176. pop di; pop si; pop es; pop ds
  1177. pop bp; ret far X-4
  1178. public AsmLib$ScreenToBuffer : X=14; Y=12; DestH=10; DestL=8; Len=6
  1179. push bp; mov bp,sp
  1180. push ds; push es; push si; push di
  1181. les di,[bp][DestL]
  1182. mov ax,[bp][Y]
  1183. mov si,[bp][X]
  1184. mov cl,4
  1185. shl ax,cl (* 16Y *)
  1186. add si,ax
  1187. shl ax,1
  1188. shl ax,1
  1189. add si,ax (* +64Y=80Y *)
  1190. shl si,1
  1191. mov cx,[bp][Len]
  1192. mov ds, cs:[@D_DATA]
  1193. cmp byte [AsmLib@IsColor],True
  1194. mov ds, cs:[AsmLib@BWSeg]
  1195. jne StbIsBW
  1196. mov ds, cs:[@D_DATA]
  1197. cmp byte [AsmLib@IsSnow],True
  1198. mov ds, cs:[AsmLib@ColorSeg]
  1199. jne StbNoSnowMove
  1200. pushf
  1201. mov dx,ColorStatusReg
  1202. add cx,cx (* bytes *)
  1203. mov bl,1
  1204. cld
  1205. StbLoop:
  1206. StbWaitNotHoriz:
  1207. in al,dx
  1208. rcr al,1
  1209. jc StbWaitNotHoriz
  1210. cli
  1211. StbWait:
  1212. in al,dx
  1213. rcr al,1
  1214. jnc StbWait
  1215. movsb
  1216. sti
  1217. loop StbLoop
  1218. popf
  1219. jmp StbRet
  1220. StbNoSnowMove:
  1221. StbIsBW:
  1222. cld
  1223. rep
  1224. movsw
  1225. StbRet:
  1226. pop di; pop si; pop es; pop ds
  1227. pop bp; ret far X-4
  1228. public AsmLib$SetVideoPage : NewPage=6
  1229. push bp; mov bp,sp; push ds
  1230. mov ax,[bp][NewPage]
  1231. mov ds, cs:[@D_DATA]
  1232. mov [AsmLib@ActivePage],al
  1233. mov ah,5
  1234. push bp
  1235. int 10H
  1236. pop bp
  1237. mov ax,[bp][NewPage]
  1238. mov bx,100H
  1239. mul bx
  1240. add ax,0B800H
  1241. mov cs:[AsmLib@ColorSeg],ax
  1242. pop ds; pop bp; ret far NewPage-4
  1243. public AsmLib$ActivePage :
  1244. push ds
  1245. mov ds, cs:[@D_DATA]
  1246. mov al, [AsmLib@ActivePage]
  1247. cbw
  1248. pop ds; ret far 0
  1249. (* initialize screen type *)
  1250. public AsmLib$InitScreenType : IsSnow=6
  1251. push bp; mov bp,sp
  1252. push ds; push es; push si; push di
  1253. mov ds, cs:[@D_DATA]
  1254. mov byte [AsmLib@IsColor],True
  1255. mov byte [AsmLib@ActivePage],0
  1256. mov ah,15
  1257. push bp
  1258. int 10H
  1259. pop bp
  1260. cmp al,7
  1261. jne LIsColor
  1262. mov byte [AsmLib@IsColor],False
  1263. LIsColor:
  1264. mov ax,[bp][IsSnow]
  1265. mov [AsmLib@IsSnow],al
  1266. pop di; pop si; pop es; pop ds
  1267. pop bp; ret far 2
  1268. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  1269. SaveSS : dw 0
  1270. SaveSP : dw 0
  1271. public AsmLib$DosExec : NameLen=14; NameSeg=12; NameOfs=10; ParamSeg=8; ParamOfs=6
  1272. (*ROM
  1273. Execute a DOS program. Even if, for some very strange reason, a ROMmed
  1274. program could call this, it wouldn't work - this procedure needs to alter
  1275. certain values in the code segment (which is presumably ROM).
  1276. *)
  1277. push bp; mov bp,sp
  1278. push ds; push es; push si; push di
  1279. pushf
  1280. mov ax,4B00H
  1281. mov ds,[bp][NameSeg]
  1282. mov dx,[bp][NameOfs]
  1283. mov es,[bp][ParamSeg]
  1284. mov bx,[bp][ParamOfs]
  1285. push bp
  1286. push ss:[2EH] (* where DOS doth tread *)
  1287. push ss:[30H]
  1288. push cs:[SaveSS] (* to restore code seg *)
  1289. push cs:[SaveSP]
  1290. mov cs:[SaveSS],ss
  1291. mov cs:[SaveSP],sp
  1292. int 21H
  1293. mov ss,cs:[SaveSS]
  1294. mov sp,cs:[SaveSP]
  1295. pop cs:[SaveSP]
  1296. pop cs:[SaveSS]
  1297. pop ss:[30H]
  1298. pop ss:[2EH]
  1299. pop bp
  1300. jc ExitExec
  1301. sub ax,ax
  1302. ExitExec:
  1303. popf
  1304. pop di; pop si; pop es; pop ds
  1305. pop bp; ret far NameLen-4
  1306. section ; segment C_CODE(CODE,28H); group G_CODE(C_CODE); select C_CODE
  1307. extrn @D_DATA
  1308. extrn @InProgramFlag
  1309. public AsmLib$SetInProgramFlag : on=6
  1310. push bp; mov bp,sp; push ds
  1311. mov al, [bp][on]
  1312. mov ds, cs:[@D_DATA]
  1313. mov [@InProgramFlag], al
  1314. pop ds; pop bp; ret far 2
  1315. public AsmLib$GetInProgramFlag :
  1316. push ds
  1317. sub ah,ah
  1318. mov ds, cs:[@D_DATA]
  1319. mov al, [@InProgramFlag]
  1320. pop ds
  1321. ret far 0
  1322. section
  1323. extrn @D_DATA
  1324. extrn @PSP
  1325. segment INITCODE(CODE,28H); group G_CODE(INITCODE)
  1326. segment D_DATA(M_DATA,28H);
  1327. select D_DATA
  1328. public AsmLib@CommandLine : org 4
  1329. public AsmLib@PSP : org 2
  1330. select INITCODE
  1331. (*ROM
  1332. All of this initialization deals with the PSP and command line. It should
  1333. be safe to just comment it out.
  1334. *)
  1335. (* set up PSP and command line *)
  1336. mov ds, cs:[@D_DATA]
  1337. mov ds, [@PSP]
  1338. mov ax, D_DATA
  1339. mov es, ax
  1340. mov es:[AsmLib@PSP],ds
  1341. mov es:[AsmLib@CommandLine][2],ds
  1342. mov word es:[AsmLib@CommandLine],81H
  1343. (* make command line into asciiz string *)
  1344. mov byte bl,ds:[80H] (* make it a asciiz string *)
  1345. xor bh,bh
  1346. add bx,81H
  1347. mov byte [bx],0
  1348. mov bx,81H
  1349. again:
  1350. cmp byte [bx],0
  1351. je EndFound
  1352. cmp byte [bx],32 (* skip blanks *)
  1353. jne StartFound
  1354. inc bx
  1355. jmp again
  1356. EndFound:
  1357. StartFound:
  1358. mov es:[AsmLib@CommandLine],bx
  1359. end
  1360.