Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

702 lines
13 KiB

  1. ;;STRUC--Stucture Macro Library
  2. ;;Optimizing Version 2.30 03/31/87
  3. if1
  4. $NoConj equ 0
  5. $And equ 1
  6. $Or equ 2
  7. $Short equ 3
  8. $Near equ 4
  9. $NearToShort equ 5
  10. $ncxz equ 6
  11. $AndOr = 0
  12. $Temp = 0
  13. $Temp2 = 0
  14. $Dist = 0
  15. $NoType equ 10
  16. $ConjIfType equ 11
  17. $IfType equ 12
  18. $ElseType equ 13
  19. $WhileType equ 14
  20. $ConjWhileType equ 15
  21. $RepeatType equ 16
  22. $ConjUntilType equ 17
  23. $ForType equ 18
  24. $ConjLeaveType equ 19
  25. $SelectType equ 20
  26. $WhenType equ 21
  27. $ConjWhenType equ 22
  28. $OtherwiseType equ $ElseType
  29. $StrucError macro text
  30. Structure error -- text
  31. endm
  32. J macro
  33. endm
  34. JN macro
  35. endm
  36. $BuildJump macro j1,j2
  37. j1 macro t
  38. .xcref j1
  39. j2 t
  40. endm
  41. endm
  42. irp x,<<jeq,je>,<jlt,jl>,<jgt,jg>,<jneq,jne>,<jnlt,jnl>,<jngt,jng>,<jnpe,jpo>,<jnpo,jpe>>
  43. $BuildJump x
  44. endm
  45. irp x,<<jzero,jz>,<jnzero,jnz>,<jnonzero,jnz>,<jnnonzero,jz>,<jand,jnz>,<jnand,jz>,<jnnand,jnz>>
  46. $BuildJump x
  47. endm
  48. irp x,<a,ae,b,be,c,e,g,ge,l,le,o,p,s,z,cxz>
  49. $BuildJump jnn&x,j&x
  50. endm
  51. jncxz macro t
  52. if $Dist eq $NearToShort
  53. jcxz $+5
  54. jmp t
  55. else
  56. jcxz $+4
  57. jmp short t
  58. endif
  59. endm
  60. purge $BuildJump
  61. $GetConj macro p1,p2
  62. $AndOr = $NoConj
  63. irp parm,<p1,p2>
  64. ifnb <&parm>
  65. irp x,<and,AND,or,OR>
  66. ifidn <parm>,<x>
  67. $AndOr = $&&&x
  68. exitm
  69. endif
  70. endm
  71. endif
  72. endm
  73. endm
  74. $GetDist macro p1,p2
  75. irp parm,<p1,p2>
  76. ifnb <parm>
  77. irp x,<short,SHORT,near,NEAR>
  78. ifidn <parm>,<x>
  79. $Dist = $&&&x
  80. exitm
  81. endif
  82. endm
  83. endif
  84. endm
  85. endm
  86. $Poke macro n,m
  87. $st&n = m
  88. .xcref $st&n
  89. endm
  90. $Peek macro x,n
  91. x = $st&n
  92. endm
  93. $Push macro n
  94. $st = $st+1
  95. $Poke %$st,n
  96. endm
  97. $Pop macro x
  98. if $st gt 0
  99. $Peek x,%$st
  100. $st = $st-1
  101. else
  102. $StrucError <open structure>
  103. endif
  104. endm
  105. $EquateLabel macro last,this
  106. if $LastLabelOrg eq $
  107. $ll&last = this
  108. .xcref $ll&last
  109. endif
  110. endm
  111. $TraceLabel macro n,a,b
  112. if $ll&a eq $ll&b
  113. $ll&n = b
  114. .xcref $ll&n
  115. else
  116. $TraceLabel n,%$ll&a,%$ll&b
  117. endif
  118. endm
  119. $Label macro n
  120. if1
  121. $EquateLabel %$LastLabel,n
  122. $ll&n = n
  123. .xcref $ll&n
  124. $LastLabel = n
  125. $LastLabelOrg = $
  126. $l&n:
  127. else
  128. if $ll&n eq n
  129. $l&n:
  130. else
  131. .xcref $l&n
  132. .xcref $ll&n
  133. endif
  134. endif
  135. endm
  136. $CondJump macro l,tf,c
  137. if1
  138. ifb <c>
  139. $EquateLabel %$LastLabel,l
  140. endif
  141. ifndef <$ll&l>
  142. $ll&l = l
  143. .xcref $ll&l
  144. endif
  145. else
  146. $TraceLabel l,l,%$ll&l
  147. endif
  148. $CondJump2 %$ll&l,tf,c
  149. endm
  150. $CondJump2 macro l,tf,c
  151. if $Dist eq $Short
  152. ifb <c>
  153. jmp short $l&l
  154. else
  155. ifidn <tf>,<f>
  156. jn&c $l&l
  157. else
  158. j&c $l&l
  159. endif
  160. endif
  161. else
  162. ifnb <c>
  163. ifdef $l&l
  164. if (($ - $l&l) le 126) and (($l&l - $) le 129)
  165. $Dist = $NearToShort
  166. $nops = 3
  167. ifidn <tf>,<f>
  168. jn&c $l&l
  169. ifdef $n&c
  170. if $n&c eq $ncxz
  171. $nops = 0
  172. endif
  173. endif
  174. ifdef $&c
  175. if $&c eq $ncxz
  176. $nops = 5
  177. endif
  178. endif
  179. else
  180. j&c $l&l
  181. ifdef $n&c
  182. if $n&c eq $ncxz
  183. $nops = 5
  184. endif
  185. endif
  186. ifdef $&c
  187. if $&c eq $ncxz
  188. $nops = 0
  189. endif
  190. endif
  191. endif
  192. rept $nops
  193. nop
  194. endm
  195. else
  196. ifidn <tf>,<f>
  197. j&c $+5
  198. else
  199. jn&c $+5
  200. endif
  201. jmp $l&l
  202. endif
  203. else
  204. ifidn <tf>,<f>
  205. j&c $+5
  206. else
  207. jn&c $+5
  208. endif
  209. jmp $l&l
  210. endif
  211. else
  212. ifdef $l&l
  213. ifidn <tf>,<NoFold>
  214. jmp $l&l
  215. else
  216. if (($ - $l&l) le 126) and (($l&l - $) le 129)
  217. jmp short $l&l
  218. nop
  219. else
  220. jmp $l&l
  221. endif
  222. endif
  223. else
  224. jmp $l&l
  225. endif
  226. endif
  227. endif
  228. endm
  229. $CondLoop macro l,c
  230. loop&c $l&l
  231. endm
  232. $Test macro tgt,a1,a2,a3,a4,x
  233. ifb <a1>
  234. $StrucError <invalid condition>
  235. else
  236. ifb <a2>
  237. $CondJump %&tgt,a1
  238. else
  239. ifb <a3>
  240. ifdif <a1>,<zero>
  241. ifdif <a1>,<nonzero>
  242. ifdif <a1>,<ZERO>
  243. ifdif <a1>,<NONZERO>
  244. $StrucError <invalid condition>
  245. exitm
  246. endif
  247. endif
  248. endif
  249. endif
  250. or a2,a2
  251. $CondJump %&tgt,a1
  252. else
  253. ifb <a4>
  254. cmp a1,a3
  255. $CondJump %&tgt,a2
  256. else
  257. ifb <x>
  258. ifdif <a1>,<bit>
  259. ifdif <a1>,<BIT>
  260. $StrucError <invalid condition>
  261. exitm
  262. endif
  263. endif
  264. test a2,a4
  265. $CondJump %&tgt,a3
  266. else
  267. $StrucError <invalid condition>
  268. endif
  269. endif
  270. endif
  271. endif
  272. endif
  273. endm
  274. $TopTest macro args,n,c,p4,p5
  275. $GetConj p4,p5
  276. $Dist = $DefDist
  277. $GetDist p4,p5
  278. if $AndOr eq $NoConj
  279. $Test <$sn-1,f>,args
  280. $Pop $Temp
  281. if $OrFound
  282. $Label %$Temp
  283. endif
  284. $Push n
  285. else
  286. if $AndOr eq $And
  287. $Test <$sn-1,f>,args
  288. else
  289. $OrFound = 1
  290. $Test <$sn,t>,args
  291. endif
  292. $Push c
  293. endif
  294. endm
  295. ;;*****************************************************************************
  296. .if macro t,p2,p3
  297. $Peek $Temp,%$st
  298. if $Temp eq $ConjIfType
  299. $Pop $Temp
  300. else
  301. $OrFound = 0
  302. $sn = $sn+1
  303. $Push $sn
  304. $sn = $sn+1
  305. $Push $sn
  306. $sn = $sn+1
  307. $Push $sn
  308. endif
  309. $TopTest <t>,$IfType,$ConjIfType,p2,p3
  310. endm
  311. ;;*****************************************************************************
  312. .then macro
  313. $Peek $Temp,%$st
  314. if $Temp ne $IfType
  315. if $Temp ne $WhenType
  316. $StrucError <then without if or when>
  317. endif
  318. endif
  319. endm
  320. ;;*****************************************************************************
  321. .elseif macro t,p2,p3
  322. $Pop $Temp
  323. if $Temp ne $IfType
  324. $StrucError <elseif without if>
  325. exitm
  326. endif
  327. $OrFound = 0
  328. $Pop $Temp
  329. $Peek $Temp2,%$st
  330. $Dist = $Near
  331. $CondJump %$Temp2
  332. $Label %$Temp
  333. $sn = $sn+1
  334. $Push $sn
  335. $sn = $sn+1
  336. $Push $sn
  337. $TopTest <t>,$IfType,$ConjIfType,p2,p3
  338. endm
  339. ;;*****************************************************************************
  340. .else macro dist
  341. $Pop $Temp
  342. if $Temp ne $IfType
  343. if $Temp ne $WhenType
  344. if $Temp ne $SelectType
  345. $StrucError <else without if, when or select>
  346. exitm
  347. endif
  348. endif
  349. endif
  350. $sn = $sn+1
  351. if $Temp eq $SelectType
  352. $Push $sn
  353. else
  354. $Dist = $DefDist
  355. $GetDist dist
  356. $CondJump %$sn
  357. $Pop $Temp
  358. $Label %$Temp
  359. $Push $sn
  360. endif
  361. $push $ElseType
  362. endm
  363. ;;*****************************************************************************
  364. .endif macro
  365. $Pop $Temp
  366. if $Temp ne $IfType
  367. if $Temp ne $ElseType
  368. $StrucError <endif without if>
  369. exitm
  370. endif
  371. endif
  372. $Pop $Temp
  373. $Label %$Temp
  374. $Pop $Temp
  375. $Label %$Temp
  376. endm
  377. ;;*****************************************************************************
  378. .select macro x
  379. $OrFound = 0
  380. $sn = $sn+1
  381. $Push $sn
  382. $Push $SelectType
  383. endm
  384. ;;*****************************************************************************
  385. .when macro tst,p2,p3
  386. $Pop $Temp
  387. if $Temp ne $SelectType
  388. if $Temp ne $WhenType
  389. if $Temp ne $ConjWhenType
  390. $StrucError <when without select>
  391. exitm
  392. endif
  393. endif
  394. endif
  395. if $Temp ne $ConjWhenType
  396. $Dist = $Near
  397. $OrFound = 0
  398. if $Temp eq $WhenType
  399. $Pop $Temp2
  400. $Peek $Temp,%$st
  401. $CondJump %$Temp
  402. $Label %$Temp2
  403. endif
  404. $sn = $sn+1
  405. $Push $sn
  406. $sn = $sn+1
  407. $Push $sn
  408. endif
  409. $TopTest <tst>,$WhenType,$ConjWhenType,p2,p3
  410. endm
  411. ;;*****************************************************************************
  412. .otherwise macro dist
  413. $Pop $Temp
  414. if $Temp ne $WhenType
  415. if $Temp ne $SelectType
  416. if $Temp ne $IfType
  417. $StrucError <otherwise without if, when or select>
  418. exitm
  419. endif
  420. endif
  421. endif
  422. $sn = $sn+1
  423. if $Temp eq $SelectType
  424. $Push $sn
  425. else
  426. $Dist = $DefDist
  427. $GetDist dist
  428. $CondJump %$sn
  429. $Pop $Temp
  430. $Label %$Temp
  431. $Push $sn
  432. endif
  433. $push $OtherwiseType
  434. endm
  435. ;;*****************************************************************************
  436. .endselect macro
  437. $Pop $Temp
  438. if $Temp ne $WhenType
  439. if $Temp ne $OtherwiseType
  440. if $Temp ne $SelectType
  441. $StrucError <endselect without select>
  442. exitm
  443. endif
  444. endif
  445. endif
  446. $pop $Temp2
  447. if $Temp ne $SelectType
  448. $Label %$Temp2
  449. $Pop $Temp2
  450. $Label %$Temp2
  451. endif
  452. endm
  453. ;;*****************************************************************************
  454. .while macro t,p2,p3
  455. $Peek $Temp,%$st
  456. if $Temp eq $ConjWhileType
  457. $Pop $Temp
  458. else
  459. $Push $LoopEnd
  460. $OrFound = 0
  461. $sn = $sn + 1
  462. $Push $sn
  463. $Label %$sn
  464. $sn = $sn + 2
  465. $Push $sn
  466. $LoopEnd = $sn - 1
  467. endif
  468. $TopTest <t>,$WhileType,$ConjWhileType,p2,p3
  469. endm
  470. ;;*****************************************************************************
  471. .endwhile macro p1
  472. $Pop $Temp
  473. if $Temp ne $WhileType
  474. $StrucError <endwhile without while>
  475. exitm
  476. endif
  477. $Dist = $Near
  478. $Pop $Temp
  479. $CondJump %$Temp,NoFold
  480. $Label %$Temp+1
  481. $Pop $LoopEnd
  482. endm
  483. ;;*****************************************************************************
  484. .repeat macro
  485. $Push $LoopEnd
  486. $Push $LeaveFound
  487. $sn = $sn+1
  488. $Label %$sn
  489. $Push $sn
  490. $Push $RepeatType
  491. $sn = $sn+1
  492. $LoopEnd = $sn
  493. $LeaveFound = 0
  494. endm
  495. ;;*****************************************************************************
  496. .until macro t,p2,p3
  497. $until2 p2,p3,t
  498. endm
  499. $until2 macro p2,p3,a1,a2,a3,a4,x
  500. $Pop $Temp
  501. if $Temp ne $RepeatType
  502. if $Temp ne $ConjUntilType
  503. $StrucError <until without repeat>
  504. exitm
  505. endif
  506. else
  507. $OrFound = 0
  508. endif
  509. $Dist = $DefDist
  510. $GetDist p2,p3
  511. $GetConj p2,p3
  512. if $AndOr eq $NoConj
  513. $Pop $Temp
  514. ifb <a1>
  515. $Dist = $Near
  516. $CondJump %$Temp,NoFold
  517. else
  518. $Test <$Temp,f>,<a1>,<a2>,<a3>,<a4>,<x>
  519. endif
  520. if $OrFound or $LeaveFound
  521. $Label %$Temp+1
  522. endif
  523. $Pop $LeaveFound
  524. $Pop $LoopEnd
  525. else
  526. $Peek $Temp,%$st
  527. if $AndOr eq $And
  528. $Test <$Temp,f>,<a1>,<a2>,<a3>,<a4>,<x>
  529. else
  530. $OrFound = 1
  531. $Test <$Temp+1,t>,<a1>,<a2>,<a3>,<a4>,<x>
  532. endif
  533. $Push $ConjUntilType
  534. endif
  535. endm
  536. ;;*****************************************************************************
  537. .loop macro cond
  538. $Pop $Temp
  539. if $Temp ne $RepeatType
  540. $StrucError <loop without repeat>
  541. exitm
  542. endif
  543. $Pop $Temp
  544. $CondLoop %$Temp,cond
  545. if $LeaveFound
  546. $Label %$Temp+1
  547. endif
  548. $Pop $LeaveFound
  549. $Pop $LoopEnd
  550. endm
  551. ;;*****************************************************************************
  552. .for macro index,equals,start,to,stop,by,step,dist
  553. mov index,start
  554. $Push $LoopEnd
  555. $sn = $sn+1
  556. $Push $sn
  557. $Label %$sn
  558. $sn = $sn+1
  559. $LoopEnd = $sn
  560. cmp index,stop
  561. $Dist = $DefDist
  562. ifb <step>
  563. $Push 1
  564. $GetDist by
  565. $CondJump %$sn,t,gt
  566. else
  567. $GetDist dist
  568. $Push %(step)
  569. if step lt 0
  570. $CondJump %$sn,t,lt
  571. else
  572. $CondJump %$sn,t,gt
  573. endif
  574. endif
  575. $Push $ForType
  576. endm
  577. ;;*****************************************************************************
  578. .next macro index,dist
  579. $Pop $Temp
  580. if $Temp ne $ForType
  581. $StrucError <next without for>
  582. exitm
  583. endif
  584. $Pop $Temp
  585. if $Temp eq 1
  586. inc index
  587. else
  588. if $Temp eq -1
  589. dec index
  590. else
  591. add index,$Temp
  592. endif
  593. endif
  594. $Pop $Temp
  595. $Dist = $Near
  596. $CondJump %$Temp,NoFold
  597. $Label %$Temp+1
  598. $Pop $LoopEnd
  599. endm
  600. ;;*****************************************************************************
  601. .leave macro t,p2,p3
  602. $leave2 p2,p3,t
  603. endm
  604. $leave2 macro p2,p3,a1,a2,a3,a4,x
  605. ife $LoopEnd
  606. $StrucError <leave outside a loop>
  607. exitm
  608. endif
  609. $LeaveFound = 1
  610. $Peek $Temp,%$st
  611. if $Temp eq $ConjLeaveType
  612. $Pop $Temp
  613. else
  614. $OrFound = 0
  615. $sn = $sn + 1
  616. endif
  617. $Dist = 0
  618. $GetDist <a1>
  619. if $Dist
  620. $CondJump %$LoopEnd
  621. if $OrFound
  622. $Label %$sn
  623. endif
  624. else
  625. $Dist = $DefDist
  626. $GetDist p2,p3
  627. $GetConj p2,p3
  628. if $AndOr eq $NoConj
  629. ifb <a1>
  630. $CondJump %$LoopEnd,t
  631. else
  632. $Test <$LoopEnd,t>,<a1>,<a2>,<a3>,<a4>,<x>
  633. endif
  634. if $OrFound
  635. $Label %$sn
  636. endif
  637. else
  638. if $AndOr eq $And
  639. $OrFound = 1
  640. $Test <$sn,f>,<a1>,<a2>,<a3>,<a4>,<x>
  641. else
  642. $Test <$LoopEnd,t>,<a1>,<a2>,<a3>,<a4>,<x>
  643. endif
  644. $Push $ConjLeaveType
  645. endif
  646. endif
  647. endm
  648. ;;*****************************************************************************
  649. else ;else for if1
  650. $Pop $Temp
  651. ;;if $Temp ne $NoType
  652. if $st ne 0
  653. $StrucError <open structure(s)>
  654. endif
  655. .xcref $NoConj,$And,$Or,$Short,$Near,$NearToShort,$AndOr,$Temp,$Temp2,$Dist
  656. .xcref $NoType,$ConjIfType,$IfType,$ElseType,$WhileType,$ConjWhileType
  657. .xcref $RepeatType,$ConjUntilType,$ForType,$ConjLeaveType,jncxz
  658. .xcref $SelectType,$WhenType,$OtherwiseType,$ConjWhenType
  659. .xcref jeq,jgt,jlt,jneq,jngt,jnlt,jnna,jnnae,jnnb,jnnbe,jnnc,jnncxz
  660. .xcref jnne,jnng,jnnge,jnnl,jnnle,jnno,jnnp,jnns,jnnz,jnpe,jnpo,$BuildJump
  661. .xcref $GetConj,$GetDist,$Poke,$Peek,$Push,$Pop,$Label,$CondJump,$CondLoop,$Test
  662. .xcref $TopTest,$leave2,$until2,$StrucError,j,jn,jand,jnand,jnnand
  663. .xcref jnnonzero,jnonzero,jnzero,jzero
  664. .xcref $st,$sn,$OrFound,$LoopEnd,$LeaveFound,$DefDist
  665. .xcref $LastLabel,$LastLabelOrg,$EquateLabel,$TraceLabel,$CondJump2,$ncxz
  666. endif
  667. $st = 0
  668. $sn = 0
  669. $OrFound = 0
  670. $LoopEnd = 0
  671. $LeaveFound = 0
  672. $LastLabel = -1
  673. $LastLabelOrg = $
  674. $DefDist= $Short
  675. $Push %$NoType