COREPMD.A 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. (* Release 3.10 *)
  2. (*-------------------------------------------------------------------------*
  3. * *
  4. * COREPMD.A - core post-mortem dumping *
  5. * *
  6. * COPYRIGHT (C) 1989..1992 Clarion Software Corporation. *
  7. * All Rights Reserved *
  8. * *
  9. *--------------------------------------------------------------------------*)
  10. include "corelib.inc"
  11. module CoreMain
  12. (*%T _DLL *)
  13. segment _BSS(BSS, 28H)
  14. public __PMDbody_vector : org FarCodePtrSize
  15. (*%E *)
  16. (*****************************************************************************)
  17. section
  18. stats? = 0 (* count hash collisions and table resets *)
  19. reset? = 0 (* possible values are 0,1 *)
  20. ebit = 1 (* possible values are 0,1,3 *)
  21. shift2 = ebit & 1
  22. shift4 = ( ebit & 2 ) / 2
  23. period = 8 / (ebit+1)
  24. max_hash = power2 (ebit+10 ) - 1
  25. max_code = power2 (ebit+9 ) - 1
  26. re_hash = 113
  27. segment PACK_DATA(FAR_DATA,28H)
  28. public EnvPack@prfx: org 2*(max_hash+1) + 4 (* must be at 0 in actual segment !! *)
  29. prfx = 0
  30. public EnvPack@reset_count: org 2
  31. public EnvPack@collision_count : org 2
  32. lim: org 2 (* limit for si *)
  33. public __p :
  34. public EnvPack@p: org (1000H/8)*(9+ebit)
  35. char: org max_hash+1 + 2
  36. code: org 2*(max_hash+1) + 4
  37. segment PACK_TEXT(CODE, 28H )
  38. ClearTable:
  39. push ax; push cx; push di; push es
  40. push ds; pop es
  41. mov di, prfx
  42. mov cx, max_hash+1
  43. mov ax, -1
  44. rep; stosw
  45. pop es; pop di; pop cx; pop ax
  46. ret 0
  47. public __Pack:
  48. public EnvPack$Pack: in = 6 ; n = 10
  49. (* Current register usage:
  50. al : input char
  51. ah : zero
  52. bx : hash table index
  53. cl : free bit count for ch
  54. ch : holds extra bits
  55. dx : current code or 256+number of codes output since reset
  56. es:si : input pointer
  57. ds:di : output pointer
  58. *)
  59. push bp
  60. mov bp, sp
  61. push si; push di; push ds; push es
  62. mov ax, PACK_DATA
  63. mov ds, ax
  64. (*%T stats?*)
  65. mov word [EnvPack@reset_count], 0
  66. mov word [EnvPack@collision_count],0
  67. (*%E*)
  68. call ClearTable
  69. les si, [bp][in]
  70. mov dx, si
  71. add dx,[bp][n]
  72. mov [lim],dx
  73. db 26H; lodsb
  74. sub ah,ah
  75. mov dx,ax
  76. mov word bp, 256
  77. mov di, EnvPack@p+1
  78. mov ch,0
  79. mov cl,period
  80. jmp loop1
  81. shift_zero:
  82. mov [di][-(period+1)], ch
  83. inc di
  84. mov cx,period
  85. (*%F reset?*)
  86. cmp bp, max_code
  87. jne shift_zero_done
  88. mov bp,[lim]
  89. jmp near _output_done
  90. (*%E*)
  91. (*%T reset?*)
  92. jmp shift_zero_done
  93. (*%E*)
  94. (*%T reset?*)
  95. clear:
  96. (*%T stats?*) inc word [EnvPack@reset_count] (*%E*)
  97. call ClearTable
  98. mov bp, 256
  99. jmp output_done
  100. (*%E*)
  101. else1:
  102. (*%T stats?*) inc word [EnvPack@collision_count] (*%E*)
  103. shl bx, 1
  104. add bx, re_hash*2
  105. jmp loop2
  106. exit1x:
  107. jmp near exit1
  108. match:
  109. shr bx,1
  110. cmp[char][bx], al
  111. jne else1
  112. shl bx,1
  113. mov dx, [code][bx]
  114. (*jmp loop1*) (*unrolled once*)
  115. cmp si,[lim]
  116. je exit1x
  117. db 26H; lodsb
  118. mov bx,dx
  119. add bl,al
  120. add bh,al
  121. (*loop2:*)
  122. and bx, max_hash*2
  123. cmp [prfx][bx], dx
  124. je match
  125. cmp word [prfx][bx],-1
  126. jne collide
  127. output:
  128. shl ch,1
  129. (*%T shift2*) shl ch,1 (*%E*)
  130. (*%T shift4*) shl ch,1 (*%E*)
  131. (*%T shift4*) shl ch,1 (*%E*)
  132. add ch, dh
  133. mov [di], dl
  134. inc di
  135. dec cl
  136. jz shift_zero
  137. shift_zero_done:
  138. mov [prfx][bx],dx
  139. mov [code][bx],bp
  140. shr bx,1
  141. mov [char][bx],al
  142. inc bp
  143. (*%T reset?*)
  144. cmp bp, max_code+1
  145. je clear
  146. (*%E*)
  147. output_done:
  148. mov dx,ax
  149. loop1:
  150. cmp si,[lim]
  151. je exit1
  152. db 26H; lodsb
  153. mov bx,dx
  154. add bl,al
  155. add bh,al
  156. loop2:
  157. and bx, max_hash*2
  158. cmp word [prfx][bx],-1
  159. je output
  160. cmp [prfx][bx], dx
  161. je match
  162. collide:
  163. (*%T stats?*) inc word [EnvPack@collision_count] (*%E*)
  164. add bx, re_hash*2
  165. (*jmp loop2*) (*unroll 1*)
  166. and bh, max_hash / 128
  167. cmp word [prfx][bx],-1
  168. je output
  169. cmp [prfx][bx], dx
  170. je match
  171. (*%T stats?*) inc word [EnvPack@collision_count] (*%E*)
  172. add bx, re_hash*2
  173. (*jmp loop2*) (*unroll 2*)
  174. and bh, max_hash / 128
  175. cmp word [prfx][bx],-1
  176. je output
  177. cmp [prfx][bx], dx
  178. je match
  179. (*%T stats?*) inc word [EnvPack@collision_count] (*%E*)
  180. add bx, re_hash*2
  181. jmp loop2 (*end unroll*)
  182. exit1:
  183. shl ch,1
  184. (*%T shift2*) shl ch,1 (*%E*)
  185. (*%T shift4*) shl ch,1 (*%E*)
  186. (*%T shift4*) shl ch,1 (*%E*)
  187. add ch, dh
  188. mov [di], dl
  189. inc di
  190. dec cl
  191. mov ax, di
  192. sub ax, EnvPack@p
  193. mov dl, ch
  194. sub ch,ch
  195. add di,cx
  196. (*%T shift2*) shl cl,1 (*%E*)
  197. (*%T shift4*) shl cl,1 (*%E*)
  198. shl dl,cl
  199. mov [di][-(period+1)], dl
  200. pop es; pop ds; pop di; pop si
  201. pop bp;
  202. ret far 6
  203. (*%F reset?*)
  204. _shift_zero:
  205. mov [di][-(period+1)], ch
  206. inc di
  207. mov cx,period
  208. jmp _shift_zero_done
  209. _else1:
  210. (*%T stats?*) inc word [EnvPack@collision_count] (*%E*)
  211. shl bx, 1
  212. add bx, re_hash*2
  213. jmp _loop2
  214. _exit1:
  215. jmp exit1
  216. _match:
  217. shr bx,1
  218. cmp[char][bx], al
  219. jne _else1
  220. shl bx,1
  221. mov dx, [code][bx]
  222. (*jmp _loop1*) (* unrolled copy of loop1*)
  223. cmp si,bp
  224. je exit1
  225. db 26H; lodsb
  226. mov bx,dx
  227. add bl,al
  228. add bh,al
  229. (*_loop2:*)
  230. and bx, max_hash*2
  231. cmp [prfx][bx], dx
  232. je _match
  233. cmp word [prfx][bx],-1
  234. jne _collide
  235. _output:
  236. shl ch,1
  237. (*%T shift2*) shl ch,1 (*%E*)
  238. (*%T shift4*) shl ch,1 (*%E*)
  239. (*%T shift4*) shl ch,1 (*%E*)
  240. add ch, dh
  241. mov [di], dl
  242. inc di
  243. dec cl
  244. jz _shift_zero
  245. _shift_zero_done:
  246. _output_done:
  247. mov dx,ax
  248. _loop1:
  249. cmp si,bp
  250. je _exit1
  251. db 26H; lodsb
  252. mov bx,dx
  253. add bl,al
  254. add bh,al
  255. _loop2:
  256. and bx, max_hash*2
  257. cmp word [prfx][bx],-1
  258. je _output
  259. cmp [prfx][bx], dx
  260. je _match
  261. _collide:
  262. (*%T stats?*) inc word [EnvPack@collision_count] (*%E*)
  263. add bx, re_hash*2
  264. (*jmp loop2*) (*unroll 1*)
  265. and bh, max_hash / 128
  266. cmp word [prfx][bx],-1
  267. je _output
  268. cmp [prfx][bx], dx
  269. je _match
  270. (*%T stats?*) inc word [EnvPack@collision_count] (*%E*)
  271. add bx, re_hash*2
  272. (*jmp loop2*) (*unroll 2*)
  273. and bh, max_hash / 128
  274. cmp word [prfx][bx],-1
  275. je _output
  276. cmp [prfx][bx], dx
  277. je _match
  278. (*%T stats?*) inc word [EnvPack@collision_count] (*%E*)
  279. add bx, re_hash*2
  280. jmp _loop2 (*end unroll*)
  281. (*%E*) (*reset?*)
  282. (*%F _OS2 *) (* NOT OS2 *)
  283. (****************************************************************************)
  284. section
  285. segment _INIT(INIT_CODE,28H)
  286. segment _TEXT(CODE,28H)
  287. segment _DATA(DATA,28H)
  288. extrn __pmd_stub
  289. extrn __pmd_entry
  290. (*%T _DLLOVL *)
  291. select _DATA
  292. PmdAdr: dd __pmd_entry
  293. (*%E *)
  294. select _TEXT
  295. do_initpmd : (* defined later on ! *)
  296. select _INIT
  297. (*%F NearCall *)
  298. initpmd : dw MAGIC_NUM
  299. db PR4
  300. dd do_initpmd
  301. (*%E *)
  302. (*%T NearCall *)
  303. initpmd : dw MAGIC_NUM
  304. db PR4
  305. dw do_initpmd
  306. (*%E *)
  307. select _DATA
  308. public _includePMD : dw 0, initpmd
  309. select _TEXT
  310. (*%T _DLLOVL *)
  311. push bp
  312. mov bp, sp
  313. (*%E *)
  314. (*%T _WINDOWS *)
  315. (*%F NearCall *)
  316. inc bp
  317. push bp
  318. mov bp, sp
  319. (*%E *)
  320. (*%E *)
  321. (*%F SameDS *)
  322. push ds
  323. mov ax, _DATA
  324. mov ds, ax
  325. (*%E *)
  326. (*%F _DLLOVL *)
  327. mov word [__pmd_stub], __pmd_entry (* initialise far proc var *)
  328. mov word [__pmd_stub][2], cs
  329. (*%E *)
  330. (*%T _DLLOVL *)
  331. mov ax, [PmdAdr]
  332. mov word [__pmd_stub], ax (* initialise far proc var *)
  333. mov ax, [PmdAdr][2]
  334. mov word [__pmd_stub][2], ax
  335. (*%E *)
  336. (*%F NearCall *)
  337. (*%F SameDS *)
  338. pop ds
  339. (*%E *)
  340. (*%T _DLLOVL *)
  341. pop bp
  342. (*%E *)
  343. (*%T _WINDOWS *)
  344. pop bp
  345. dec bp
  346. (*%E *)
  347. ret far 0
  348. (*%E *)
  349. (*%T NearCall *)
  350. (*%F SameDS *)
  351. pop ds
  352. (*%E *)
  353. ret 0
  354. (*%E *)
  355. (****************************************************************************)
  356. section
  357. segment _TEXT(CODE,28H)
  358. segment _DATA(DATA,28H)
  359. extrn __psp
  360. extrn __PMDbody
  361. extrn __PMDbody_vector
  362. extrn _includePMD
  363. select _DATA
  364. PSP = 0
  365. TopLim = 2
  366. BPreg = 4
  367. DSreg = 6
  368. DIreg = 8
  369. SIreg = 10
  370. CSreg = 12
  371. IPreg = 14
  372. SSreg = 16
  373. SPreg = 18
  374. Code = 20
  375. Msg = 22
  376. PName = 26
  377. CPstate = 106
  378. pmdBufferSize = CPstate+94
  379. pmdBuffer : org pmdBufferSize
  380. select _TEXT
  381. public __pmd_entry:
  382. tempDS = 0
  383. tempSI = 2
  384. tempDI = 4
  385. tempBP = 6
  386. (* bp = pointer to ds, si, di, bp *)
  387. cmp word [_includePMD], 1 (* bx:ax = cs:ip, di = code *)
  388. jne noDump
  389. (*%F SameDS *)
  390. push ds (* dx:cx = pointer to user message *)
  391. mov si, _DATA
  392. mov ds, si
  393. (*%E *)
  394. mov si, pmdBuffer
  395. mov [si][Msg], cx (* store message string *)
  396. mov [si][Msg][2], dx
  397. mov [si][Code], di (* store exit code *)
  398. mov [si][CSreg], bx (* store cs:ip *)
  399. mov [si][IPreg], ax
  400. mov [si][SSreg], ss (* store ss:sp *)
  401. mov ax, bp
  402. add ax, 22
  403. mov [si][SPreg], ax
  404. mov bx, bp
  405. mov ax, ss:[bx][tempBP] (* store ds, bp, di, si *)
  406. mov [si][BPreg], ax
  407. mov ax, ss:[bx][tempDS]
  408. mov [si][DSreg], ax
  409. mov ax, ss:[bx][tempDI]
  410. mov [si][DIreg], ax
  411. mov ax, ss:[bx][tempSI]
  412. mov [si][SIreg], ax
  413. push ds
  414. pop es
  415. mov ax, es:[__psp] (* PSP segment *)
  416. mov [si][PSP], ax
  417. mov es, ax
  418. mov ax, es:[2]
  419. mov [si][TopLim], ax (* top of allocated memory *)
  420. lea bx, [si][CPstate]
  421. fsave [bx]
  422. mov ax, si
  423. mov bx, ds
  424. (*%F _DLL *)
  425. (*%T NearCall *)
  426. call __PMDbody
  427. (*%E *)
  428. (*%F NearCall *)
  429. call far __PMDbody
  430. (*%E *)
  431. (*%E *)
  432. (*%T _DLL *)
  433. call far [__PMDbody_vector]
  434. (*%E *)
  435. (*%F SameDS *)
  436. pop ds
  437. (*%E *)
  438. noDump:
  439. ret far 0
  440. (*%E *)
  441. (****************************************************************************)
  442. (*%T _DLL *)
  443. section
  444. segment _TEXT(CODE,28H)
  445. segment _DATA(DATA,28H)
  446. extrn __PMDbody_vector
  447. public __set_PMDbody_vector :
  448. push ds
  449. mov cx, _DATA
  450. mov ds, cx
  451. mov [__PMDbody_vector][2], bx
  452. mov [__PMDbody_vector], ax
  453. pop ds
  454. ret far 0
  455. (*%E *)
  456. (*%T _OS2 *)
  457. (****************************************************************************)
  458. section
  459. segment _INIT(INIT_CODE,28H)
  460. segment _TEXT(CODE,28H)
  461. segment _DATA(DATA,28H)
  462. extrn __pmd_stub
  463. extrn __pmd_entry
  464. select _TEXT
  465. do_initpmd : (* defined later on ! *)
  466. select _INIT
  467. (*%F NearCall *)
  468. initpmd : dw MAGIC_NUM
  469. db PR4
  470. dd do_initpmd
  471. (*%E *)
  472. (*%T NearCall *)
  473. initpmd : dw MAGIC_NUM
  474. db PR4
  475. dw do_initpmd
  476. (*%E *)
  477. select _DATA
  478. public _includePMD : dw 0, initpmd
  479. select _TEXT
  480. (*%F SameDS *)
  481. push ds
  482. mov ax, _DATA
  483. mov ds, ax
  484. (*%E *)
  485. mov word [__pmd_stub], __pmd_entry (* initialise far proc var *)
  486. mov word [__pmd_stub][2], cs
  487. (*%F NearCall *)
  488. (*%F SameDS *)
  489. pop ds
  490. (*%E *)
  491. (*%T _DLL *)
  492. public __lsl@: (* Required for link, but no longer used *)
  493. (*%E *)
  494. ret far 0
  495. (*%E *)
  496. (*%T NearCall *)
  497. (*%F SameDS *)
  498. pop ds
  499. (*%E *)
  500. ret 0
  501. (*%E *)
  502. (****************************************************************************)
  503. section
  504. segment _TEXT(CODE,28H)
  505. segment _DATA(DATA,28H)
  506. extrn __PMDbody
  507. extrn __PMDbody_vector
  508. extrn _includePMD
  509. select _DATA
  510. PSP = 0 (* unused under OS2 *)
  511. TopLim = 2 (* unused under OS2 *)
  512. BPreg = 4
  513. DSreg = 6
  514. DIreg = 8
  515. SIreg = 10
  516. CSreg = 12
  517. IPreg = 14
  518. SSreg = 16
  519. SPreg = 18
  520. Code = 20
  521. Msg = 22
  522. PName = 26
  523. CPstate = 106
  524. pmdBufferSize = CPstate+94
  525. pmdBuffer : org pmdBufferSize
  526. select _TEXT
  527. public __pmd_entry:
  528. tempDS = 0
  529. tempSI = 2
  530. tempDI = 4
  531. tempBP = 6
  532. cmp word [_includePMD], 1
  533. jne noDump (* bp = pointer to ds, si, di, bp *)
  534. (* bx:ax = cs:ip, di = code *)
  535. (*%F SameDS *)
  536. push ds (* dx:cx = pointer to user message *)
  537. mov si, _DATA
  538. mov ds, si
  539. (*%E *)
  540. mov si, pmdBuffer
  541. mov [si][Msg], cx (* store message string *)
  542. mov [si][Msg][2], dx
  543. mov [si][Code], di (* store exit code *)
  544. mov [si][CSreg], bx (* store cs:ip *)
  545. mov [si][IPreg], ax
  546. mov [si][SSreg], ss (* store ss:sp *)
  547. mov ax, bp
  548. add ax, 22
  549. mov [si][SPreg], ax
  550. mov bx, bp
  551. mov ax, ss:[bx][tempBP] (* store ds, bp, di, si *)
  552. mov [si][BPreg], ax
  553. mov ax, ss:[bx][tempDS]
  554. mov [si][DSreg], ax
  555. mov ax, ss:[bx][tempDI]
  556. mov [si][DIreg], ax
  557. mov ax, ss:[bx][tempSI]
  558. mov [si][SIreg], ax
  559. lea bx, [si][CPstate]
  560. fsave [bx]
  561. mov ax, si
  562. mov bx, _DATA
  563. (*%F _DLL *)
  564. (*%T NearCall *)
  565. call __PMDbody
  566. (*%E *)
  567. (*%F NearCall *)
  568. call far __PMDbody
  569. (*%E *)
  570. (*%E *)
  571. (*%T _DLL *)
  572. call far [__PMDbody_vector]
  573. (*%E *)
  574. (*%F SameDS *)
  575. pop ds
  576. (*%E *)
  577. noDump:
  578. ret far 0
  579. (*%E *)
  580. end
  581.