set.inc 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by the Free Pascal development team
  5. Include file with set operations called by the compiler
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {$define FPC_SYSTEM_HAS_FPC_SET_LOAD_SMALL}
  13. function fpc_set_load_small(l: fpc_small_set): fpc_normal_set;assembler;[public,alias:'FPC_SET_LOAD_SMALL']; {$ifdef hascompilerproc} compilerproc; {$endif}
  14. {
  15. load a normal set p from a smallset l
  16. }
  17. var
  18. saveedi : longint;
  19. asm
  20. movl %edi,saveedi
  21. movl __RESULT,%edi
  22. {$ifndef REGCALL}
  23. movl l,%eax
  24. {$endif}
  25. stosl
  26. xorl %eax,%eax
  27. movl $7,%ecx
  28. rep
  29. stosl
  30. movl saveedi,%edi
  31. end;
  32. {$define FPC_SYSTEM_HAS_FPC_SET_CREATE_ELEMENT}
  33. function fpc_set_create_element(b : byte): fpc_normal_set;assembler;[public,alias:'FPC_SET_CREATE_ELEMENT']; {$ifdef hascompilerproc} compilerproc; {$endif}
  34. {
  35. create a new set in p from an element b
  36. }
  37. var
  38. saveedi : longint;
  39. asm
  40. {$ifndef hascompilerproc}
  41. pushl %eax
  42. pushl %ecx
  43. {$endif not hascompilerproc}
  44. movl %edi,saveedi
  45. {$ifdef REGCALL}
  46. movl %eax,%edi
  47. andl $0xff,%edx
  48. {$else}
  49. movzbl b,%edx
  50. movl __RESULT,%edi
  51. {$endif}
  52. xorl %eax,%eax
  53. movl $8,%ecx
  54. rep
  55. stosl
  56. leal -32(%edi),%eax
  57. btsl %edx,(%eax)
  58. movl saveedi,%edi
  59. {$ifndef hascompilerproc}
  60. popl %ecx
  61. popl %eax
  62. {$endif hascompilerproc}
  63. end;
  64. {$define FPC_SYSTEM_HAS_FPC_SET_SET_BYTE}
  65. {$ifdef hascompilerproc}
  66. function fpc_set_set_byte(const source: fpc_normal_set; b : byte): fpc_normal_set;assembler; compilerproc;
  67. {
  68. add the element b to the set pointed by source
  69. }
  70. var
  71. saveesi,saveedi : longint;
  72. asm
  73. movl %edi,saveedi
  74. movl %esi,saveesi
  75. movl $8,%ecx
  76. {$ifdef REGCALL}
  77. movl %eax,%edi
  78. movl %edx,%esi
  79. movzbl %cl,%edx
  80. {$else}
  81. movl source,%esi
  82. movzbl b,%edx
  83. movl __RESULT,%edi
  84. {$endif}
  85. rep
  86. movsl
  87. leal -32(%edi),%eax
  88. btsl %edx,(%eax)
  89. movl saveedi,%edi
  90. movl saveesi,%esi
  91. end;
  92. {$else hascompilerproc}
  93. function fpc_set_set_byte(b : byte): fpc_normal_set;assembler;[public,alias:'FPC_SET_SET_BYTE'];
  94. {
  95. add the element b to the set pointed by p
  96. }
  97. asm
  98. pushl %eax
  99. movl __RESULT,%edi
  100. movb b,%al
  101. andl $0xf8,%eax
  102. shrl $3,%eax
  103. addl %eax,%edi
  104. movb b,%al
  105. andl $7,%eax
  106. btsl %eax,(%edi)
  107. popl %eax
  108. end;
  109. {$endif hascompilerproc}
  110. {$define FPC_SYSTEM_HAS_FPC_SET_UNSET_BYTE}
  111. {$ifdef hascompilerproc}
  112. function fpc_set_unset_byte(const source: fpc_normal_set; b : byte): fpc_normal_set;assembler; compilerproc;
  113. {
  114. add the element b to the set pointed by source
  115. }
  116. var
  117. saveesi,saveedi : longint;
  118. asm
  119. movl %edi,saveedi
  120. movl %esi,saveesi
  121. {$ifdef REGCALL}
  122. movl %eax,%edi
  123. movl %edx,%esi
  124. movzbl %cl,%edx
  125. {$else}
  126. movl source,%esi
  127. movl __RESULT,%edi
  128. movzbl b,%edx
  129. {$endif}
  130. movl $8,%ecx
  131. rep
  132. movsl
  133. leal -32(%edi),%eax
  134. btrl %edx,(%eax)
  135. movl saveedi,%edi
  136. movl saveesi,%esi
  137. end;
  138. {$else hascompilerproc}
  139. function fpc_set_unset_byte(b : byte): fpc_normal_set;assembler;[public,alias:'FPC_SET_UNSET_BYTE']; {$ifdef hascompilerproc} compilerproc; {$endif}
  140. {
  141. suppresses the element b to the set pointed by p
  142. used for exclude(set,element)
  143. }
  144. asm
  145. pushl %eax
  146. movl __RESULT,%edi
  147. movb b,%al
  148. andl $0xf8,%eax
  149. shrl $3,%eax
  150. addl %eax,%edi
  151. movb b,%al
  152. andl $7,%eax
  153. btrl %eax,(%edi)
  154. popl %eax
  155. end;
  156. {$endif hascompilerproc}
  157. {$define FPC_SYSTEM_HAS_FPC_SET_SET_RANGE}
  158. {$ifdef hascompilerproc}
  159. function fpc_set_set_range(const orgset: fpc_normal_set; l,h : byte): fpc_normal_set;assembler; compilerproc;
  160. {
  161. adds the range [l..h] to the set pointed to by p
  162. }
  163. var
  164. saveesi,saveedi,saveebx : longint;
  165. asm
  166. movl %edi,saveedi
  167. movl %esi,saveesi
  168. movl %ebx,saveebx
  169. {$ifdef REGCALL}
  170. movl %eax,%edi
  171. movl %edx,%esi
  172. movzbl l,%eax // lowest bit to be set in eax
  173. movzbl h,%ebx // highest in ebx
  174. {$else}
  175. movzbl l,%eax // lowest bit to be set in eax
  176. movzbl h,%ebx // highest in ebx
  177. movl __RESULT,%edi // target set address in edi
  178. movl orgset, %esi // source set address in esi
  179. {$endif}
  180. movl $8,%ecx // we have to copy 32 bytes
  181. cmpl %eax,%ebx // high < low?
  182. rep // copy source to dest (it's possible to do the range
  183. movsl // setting and copying simultanuously of course, but
  184. // that would result in many more jumps and code)
  185. movl %eax,%ecx // lowest also in ecx
  186. jb .Lset_range_done // if high > low, then dest := source
  187. shrl $3,%eax // divide by 8 to get starting and ending byte
  188. shrl $3,%ebx // address
  189. andb $31,%cl // low five bits of lo determine start of bit mask
  190. andl $0x0fffffffc,%eax // clear two lowest bits to get start/end longint
  191. subl $32,%edi // get back to start of dest
  192. andl $0x0fffffffc,%ebx // address * 4
  193. movl $0x0ffffffff,%edx // edx = bitmask to be inserted
  194. shll %cl,%edx // shift bitmask to clear bits below lo
  195. addl %eax,%edi // go to starting pos in set
  196. subl %eax,%ebx // are bit lo and hi in the same longint?
  197. jz .Lset_range_hi // yes, keep current mask and adjust for hi bit
  198. orl %edx,(%edi) // no, store current mask
  199. movl $0x0ffffffff,%edx // new mask
  200. addl $4,%edi // next longint of set
  201. subl $4,%ebx // bit hi in this longint?
  202. jz .Lset_range_hi // yes, keep full mask and adjust for hi bit
  203. .Lset_range_loop:
  204. movl %edx,(%edi) // no, fill longints in between with full mask
  205. addl $4,%edi
  206. subl $4,%ebx
  207. jnz .Lset_range_loop
  208. .Lset_range_hi:
  209. movb h,%cl // this is ok, h is on the stack
  210. movl %edx,%ebx // save current bitmask
  211. andb $31,%cl
  212. subb $31,%cl // cl := (31 - (hi and 31)) = shift count to
  213. negb %cl // adjust bitmask for hi bit
  214. shrl %cl,%edx // shift bitmask to clear bits higher than hi
  215. andl %edx,%ebx // combine both bitmasks
  216. orl %ebx,(%edi) // store to set
  217. .Lset_range_done:
  218. movl saveedi,%edi
  219. movl saveesi,%esi
  220. movl saveebx,%ebx
  221. end;
  222. {$else hascompilerproc}
  223. function fpc_set_set_range(l,h : byte): fpc_normal_set;assembler;[public,alias:'FPC_SET_SET_RANGE'];
  224. {
  225. adds the range [l..h] to the set pointed to by p
  226. }
  227. asm
  228. movl __RESULT,%edi // set address in edi
  229. movzbl l,%eax // lowest bit to be set in eax
  230. movzbl h,%ebx // highest in ebx
  231. cmpl %eax,%ebx
  232. jb .Lset_range_done
  233. movl %eax,%ecx // lowest also in ecx
  234. shrl $3,%eax // divide by 8 to get starting and ending byte
  235. shrl $3,%ebx // address
  236. andb $31,%cl // low five bits of lo determine start of bit mask
  237. movl $0x0ffffffff,%edx // edx = bitmask to be inserted
  238. andl $0x0fffffffc,%eax // clear two lowest bits to get start/end longint
  239. andl $0x0fffffffc,%ebx // address * 4
  240. shll %cl,%edx // shift bitmask to clear bits below lo
  241. addl %eax,%edi // go to starting pos in set
  242. subl %eax,%ebx // are bit lo and hi in the same longint?
  243. jz .Lset_range_hi // yes, keep current mask and adjust for hi bit
  244. orl %edx,(%edi) // no, store current mask
  245. movl $0x0ffffffff,%edx // new mask
  246. addl $4,%edi // next longint of set
  247. subl $4,%ebx // bit hi in this longint?
  248. jz .Lset_range_hi // yes, keep full mask and adjust for hi bit
  249. .Lset_range_loop:
  250. movl %edx,(%edi) // no, fill longints in between with full mask
  251. addl $4,%edi
  252. subl $4,%ebx
  253. jnz .Lset_range_loop
  254. .Lset_range_hi:
  255. movb h,%cl
  256. movl %edx,%ebx // save current bitmask
  257. andb $31,%cl
  258. subb $31,%cl // cl := (31 - (hi and 31)) = shift count to
  259. negb %cl // adjust bitmask for hi bit
  260. shrl %cl,%edx // shift bitmask to clear bits higher than hi
  261. andl %edx,%ebx // combine both bitmasks
  262. orl %ebx,(%edi) // store to set
  263. .Lset_range_done:
  264. end;
  265. {$endif hascompilerproc}
  266. {$define FPC_SYSTEM_HAS_FPC_SET_IN_BYTE}
  267. function fpc_set_in_byte(const p: fpc_normal_set; b: byte): boolean; assembler; [public,alias:'FPC_SET_IN_BYTE']; {$ifdef hascompilerproc} compilerproc; {$else} saveregisters; {$endif}
  268. {
  269. tests if the element b is in the set p the carryflag is set if it present
  270. }
  271. asm
  272. {$ifdef hascompilerproc}
  273. {$ifdef REGCALL}
  274. xchgl %edx,%eax
  275. andl $0xff,%eax
  276. {$else}
  277. movl p,%edx
  278. movzbl b,%eax
  279. {$endif}
  280. btl %eax,(%edx)
  281. {$else hascompilerproc}
  282. pushl %eax
  283. movl p,%edi
  284. movzbl b,%eax
  285. btl %eax,(%edi)
  286. popl %eax
  287. {$endif hascompilerproc}
  288. end;
  289. {$define FPC_SYSTEM_HAS_FPC_SET_ADD_SETS}
  290. {$ifdef hascompilerproc}
  291. function fpc_set_add_sets(const set1,set2: fpc_normal_set): fpc_normal_set;assembler;[public,alias:'FPC_SET_ADD_SETS']; compilerproc;
  292. {$else hascompilerproc}
  293. procedure fpc_set_add_sets(set1,set2,dest : pointer);assembler;[public,alias:'FPC_SET_ADD_SETS'];
  294. {$endif hascompilerproc}
  295. {
  296. adds set1 and set2 into set dest
  297. }
  298. var
  299. saveesi,saveedi : longint;
  300. asm
  301. movl %edi,saveedi
  302. movl %esi,saveesi
  303. {$ifdef REGCALL}
  304. movl set1,%esi
  305. movl __RESULT,%edi
  306. movl set2,%edx
  307. {$else}
  308. movl set1,%esi
  309. movl set2,%edx
  310. {$ifdef hascompilerproc}
  311. movl __RESULT,%edi
  312. {$else hascompilerproc}
  313. movl dest,%edi
  314. {$endif hascompilerproc}
  315. {$endif}
  316. movl $8,%ecx
  317. .LMADDSETS1:
  318. lodsl
  319. orl (%edx),%eax
  320. stosl
  321. addl $4,%edx
  322. decl %ecx
  323. jnz .LMADDSETS1
  324. movl saveedi,%edi
  325. movl saveesi,%esi
  326. end;
  327. {$define FPC_SYSTEM_HAS_FPC_SET_MUL_SETS}
  328. {$ifdef hascompilerproc}
  329. function fpc_set_mul_sets(const set1,set2: fpc_normal_set): fpc_normal_set;assembler;[public,alias:'FPC_SET_MUL_SETS']; compilerproc;
  330. {$else hascompilerproc}
  331. procedure fpc_set_mul_sets(set1,set2,dest:pointer);assembler;[public,alias:'FPC_SET_MUL_SETS'];
  332. {$endif hascompilerproc}
  333. {
  334. multiplies (takes common elements of) set1 and set2 result put in dest
  335. }
  336. var
  337. saveesi,saveedi : longint;
  338. asm
  339. movl %edi,saveedi
  340. movl %esi,saveesi
  341. {$ifdef REGCALL}
  342. movl set1,%esi
  343. movl __RESULT,%edi
  344. movl set2,%edx
  345. {$else}
  346. movl set1,%esi
  347. movl set2,%edx
  348. {$ifdef hascompilerproc}
  349. movl __RESULT,%edi
  350. {$else hascompilerproc}
  351. movl dest,%edi
  352. {$endif hascompilerproc}
  353. {$endif}
  354. movl $8,%ecx
  355. .LMMULSETS1:
  356. lodsl
  357. andl (%edx),%eax
  358. stosl
  359. addl $4,%edx
  360. decl %ecx
  361. jnz .LMMULSETS1
  362. movl saveedi,%edi
  363. movl saveesi,%esi
  364. end;
  365. {$define FPC_SYSTEM_HAS_FPC_SET_SUB_SETS}
  366. {$ifdef hascompilerproc}
  367. function fpc_set_sub_sets(const set1,set2: fpc_normal_set): fpc_normal_set;assembler;[public,alias:'FPC_SET_SUB_SETS']; compilerproc;
  368. {$else hascompilerproc}
  369. procedure fpc_set_sub_sets(set1,set2,dest:pointer);assembler;[public,alias:'FPC_SET_SUB_SETS'];
  370. {$endif hascompilerproc}
  371. {
  372. computes the diff from set1 to set2 result in dest
  373. }
  374. var
  375. saveesi,saveedi,saveebx : longint;
  376. asm
  377. movl %edi,saveedi
  378. movl %esi,saveesi
  379. movl %ebx,saveebx
  380. {$ifdef REGCALL}
  381. movl set1,%esi
  382. movl __RESULT,%edi
  383. movl set2,%edx
  384. {$else}
  385. movl set1,%esi
  386. movl set2,%ebx
  387. {$ifdef hascompilerproc}
  388. movl __RESULT,%edi
  389. {$else hascompilerproc}
  390. movl dest,%edi
  391. {$endif hascompilerproc}
  392. {$endif}
  393. movl $8,%ecx
  394. .LMSUBSETS1:
  395. lodsl
  396. movl (%ebx),%edx
  397. notl %edx
  398. andl %edx,%eax
  399. stosl
  400. addl $4,%ebx
  401. decl %ecx
  402. jnz .LMSUBSETS1
  403. movl saveedi,%edi
  404. movl saveesi,%esi
  405. movl saveebx,%ebx
  406. end;
  407. {$define FPC_SYSTEM_HAS_FPC_SET_SYMDIF_SETS}
  408. {$ifdef hascompilerproc}
  409. function fpc_set_symdif_sets(const set1,set2: fpc_normal_set): fpc_normal_set;assembler;[public,alias:'FPC_SET_SYMDIF_SETS']; compilerproc;
  410. {$else hascompilerproc}
  411. procedure fpc_set_symdif_sets(set1,set2,dest:pointer);assembler;[public,alias:'FPC_SET_SYMDIF_SETS'];
  412. {$endif hascompilerproc}
  413. {
  414. computes the symetric diff from set1 to set2 result in dest
  415. }
  416. var
  417. saveesi,saveedi : longint;
  418. asm
  419. movl %edi,saveedi
  420. movl %esi,saveesi
  421. {$ifdef REGCALL}
  422. movl set1,%esi
  423. movl __RESULT,%edi
  424. movl set2,%edx
  425. {$else}
  426. movl set1,%esi
  427. movl set2,%edx
  428. {$ifdef hascompilerproc}
  429. movl __RESULT,%edi
  430. {$else hascompilerproc}
  431. movl dest,%edi
  432. {$endif hascompilerproc}
  433. {$endif}
  434. movl $8,%ecx
  435. .LMSYMDIFSETS1:
  436. lodsl
  437. xorl (%edx),%eax
  438. stosl
  439. addl $4,%edx
  440. decl %ecx
  441. jnz .LMSYMDIFSETS1
  442. movl saveedi,%edi
  443. movl saveesi,%esi
  444. end;
  445. {$define FPC_SYSTEM_HAS_FPC_SET_COMP_SETS}
  446. function fpc_set_comp_sets(const set1,set2: fpc_normal_set): boolean;assembler;[public,alias:'FPC_SET_COMP_SETS']; {$ifdef hascompilerproc} compilerproc; {$endif}
  447. {
  448. compares set1 and set2 zeroflag is set if they are equal
  449. }
  450. var
  451. saveesi,saveedi : longint;
  452. asm
  453. movl %edi,saveedi
  454. movl %esi,saveesi
  455. movl set1,%esi
  456. movl set2,%edi
  457. movl $8,%ecx
  458. .LMCOMPSETS1:
  459. movl (%esi),%eax
  460. movl (%edi),%edx
  461. cmpl %edx,%eax
  462. jne .LMCOMPSETEND
  463. addl $4,%esi
  464. addl $4,%edi
  465. decl %ecx
  466. jnz .LMCOMPSETS1
  467. { we are here only if the two sets are equal
  468. we have zero flag set, and that what is expected }
  469. .LMCOMPSETEND:
  470. {$ifdef hascompilerproc}
  471. seteb %al
  472. {$endif hascompilerproc}
  473. movl saveedi,%edi
  474. movl saveesi,%esi
  475. end;
  476. {$define FPC_SYSTEM_HAS_FPC_SET_CONTAINS_SET}
  477. function fpc_set_contains_sets(const set1,set2: fpc_normal_set): boolean;assembler;[public,alias:'FPC_SET_CONTAINS_SETS']; {$ifdef hascompilerproc} compilerproc; {$endif}
  478. {
  479. on exit, zero flag is set if set1 <= set2 (set2 contains set1)
  480. }
  481. var
  482. saveesi,saveedi : longint;
  483. asm
  484. movl %edi,saveedi
  485. movl %esi,saveesi
  486. movl set1,%esi
  487. movl set2,%edi
  488. movl $8,%ecx
  489. .LMCONTAINSSETS1:
  490. movl (%esi),%eax
  491. movl (%edi),%edx
  492. andl %eax,%edx
  493. cmpl %edx,%eax {set1 and set2 = set1?}
  494. jne .LMCONTAINSSETEND
  495. addl $4,%esi
  496. addl $4,%edi
  497. decl %ecx
  498. jnz .LMCONTAINSSETS1
  499. { we are here only if set2 contains set1
  500. we have zero flag set, and that what is expected }
  501. .LMCONTAINSSETEND:
  502. {$ifdef hascompilerproc}
  503. seteb %al
  504. {$endif hascompilerproc}
  505. movl saveedi,%edi
  506. movl saveesi,%esi
  507. end;
  508. {$ifdef LARGESETS}
  509. {$error Needs to be fixed for register calling first!}
  510. procedure fpc_largeset_set_word(p : pointer;b : word);assembler;[public,alias:'FPC_LARGESET_SET_WORD']; {$ifdef hascompilerproc} compilerproc; {$endif}
  511. {
  512. sets the element b in set p works for sets larger than 256 elements
  513. not yet use by the compiler so
  514. }
  515. asm
  516. pushl %eax
  517. movl p,%edi
  518. movw b,%ax
  519. andl $0xfff8,%eax
  520. shrl $3,%eax
  521. addl %eax,%edi
  522. movb 12(%ebp),%al
  523. andl $7,%eax
  524. btsl %eax,(%edi)
  525. popl %eax
  526. end;
  527. procedure fpc_largeset_in_word(p : pointer;b : word);assembler;[public,alias:'FPC_LARGESET_IN_WORD']; {$ifdef hascompilerproc} compilerproc; {$endif}
  528. {
  529. tests if the element b is in the set p the carryflag is set if it present
  530. works for sets larger than 256 elements
  531. }
  532. asm
  533. pushl %eax
  534. movl p,%edi
  535. movw b,%ax
  536. andl $0xfff8,%eax
  537. shrl $3,%eax
  538. addl %eax,%edi
  539. movb 12(%ebp),%al
  540. andl $7,%eax
  541. btl %eax,(%edi)
  542. popl %eax
  543. end;
  544. procedure fpc_largeset_add_sets(set1,set2,dest : pointer;size : longint);assembler;[public,alias:'FPC_LARGESET_ADD_SETS']; {$ifdef hascompilerproc} compilerproc; {$endif}
  545. {
  546. adds set1 and set2 into set dest size is the number of bytes in the set
  547. }
  548. asm
  549. movl set1,%esi
  550. movl set2,%ebx
  551. movl dest,%edi
  552. movl size,%ecx
  553. .LMADDSETSIZES1:
  554. lodsl
  555. orl (%ebx),%eax
  556. stosl
  557. addl $4,%ebx
  558. decl %ecx
  559. jnz .LMADDSETSIZES1
  560. end;
  561. procedure fpc_largeset_mul_sets(set1,set2,dest : pointer;size : longint);assembler;[public,alias:'FPC_LARGESET_MUL_SETS']; {$ifdef hascompilerproc} compilerproc; {$endif}
  562. {
  563. multiplies (i.E. takes common elements of) set1 and set2 result put in
  564. dest size is the number of bytes in the set
  565. }
  566. asm
  567. movl set1,%esi
  568. movl set2,%ebx
  569. movl dest,%edi
  570. movl size,%ecx
  571. .LMMULSETSIZES1:
  572. lodsl
  573. andl (%ebx),%eax
  574. stosl
  575. addl $4,%ebx
  576. decl %ecx
  577. jnz .LMMULSETSIZES1
  578. end;
  579. procedure fpc_largeset_sub_sets(set1,set2,dest : pointer;size : longint);assembler;[public,alias:'FPC_LARGESET_SUB_SETS']; {$ifdef hascompilerproc} compilerproc; {$endif}
  580. asm
  581. movl set1,%esi
  582. movl set2,%ebx
  583. movl dest,%edi
  584. movl size,%ecx
  585. .LMSUBSETSIZES1:
  586. lodsl
  587. movl (%ebx),%edx
  588. notl %edx
  589. andl %edx,%eax
  590. stosl
  591. addl $4,%ebx
  592. decl %ecx
  593. jnz .LMSUBSETSIZES1
  594. end;
  595. procedure fpc_largeset_symdif_sets(set1,set2,dest : pointer;size : longint);assembler;[public,alias:'FPC_LARGESET_SYMDIF_SETS']; {$ifdef hascompilerproc} compilerproc; {$endif}
  596. {
  597. computes the symetric diff from set1 to set2 result in dest
  598. }
  599. asm
  600. movl set1,%esi
  601. movl set2,%ebx
  602. movl dest,%edi
  603. movl size,%ecx
  604. .LMSYMDIFSETSIZE1:
  605. lodsl
  606. movl (%ebx),%edx
  607. xorl %edx,%eax
  608. stosl
  609. addl $4,%ebx
  610. decl %ecx
  611. jnz .LMSYMDIFSETSIZE1
  612. end;
  613. procedure fpc_largeset_comp_sets(set1,set2 : pointer;size : longint);assembler;[public,alias:'FPC_LARGESET_COMP_SETS']; {$ifdef hascompilerproc} compilerproc; {$endif}
  614. asm
  615. movl set1,%esi
  616. movl set2,%edi
  617. movl size,%ecx
  618. .LMCOMPSETSIZES1:
  619. lodsl
  620. movl (%edi),%edx
  621. cmpl %edx,%eax
  622. jne .LMCOMPSETSIZEEND
  623. addl $4,%edi
  624. decl %ecx
  625. jnz .LMCOMPSETSIZES1
  626. { we are here only if the two sets are equal
  627. we have zero flag set, and that what is expected }
  628. .LMCOMPSETSIZEEND:
  629. end;
  630. procedure fpc_largeset_contains_sets(set1,set2 : pointer; size: longint);assembler;[public,alias:'FPC_LARGESET_CONTAINS_SETS']; {$ifdef hascompilerproc} compilerproc; {$endif}
  631. {
  632. on exit, zero flag is set if set1 <= set2 (set2 contains set1)
  633. }
  634. asm
  635. movl set1,%esi
  636. movl set2,%edi
  637. movl size,%ecx
  638. .LMCONTAINSSETS2:
  639. movl (%esi),%eax
  640. movl (%edi),%edx
  641. andl %eax,%edx
  642. cmpl %edx,%eax {set1 and set2 = set1?}
  643. jne .LMCONTAINSSETEND2
  644. addl $4,%esi
  645. addl $4,%edi
  646. decl %ecx
  647. jnz .LMCONTAINSSETS2
  648. { we are here only if set2 contains set1
  649. we have zero flag set, and that what is expected }
  650. .LMCONTAINSSETEND2:
  651. end;
  652. {$endif LARGESET}
  653. {
  654. $Log$
  655. Revision 1.13 2003-11-23 16:50:49 peter
  656. * register calling updates
  657. Revision 1.12 2003/11/11 21:08:17 peter
  658. * REGCALL define added
  659. Revision 1.11 2003/09/08 18:21:37 peter
  660. * save edi,esi,ebx
  661. Revision 1.10 2003/05/26 19:36:46 peter
  662. * fpc_shortstr_concat is now the same for all targets
  663. * fpc_shortstr_append_shortstr added for optimized code generation
  664. Revision 1.9 2002/09/07 16:01:19 peter
  665. * old logs removed and tabs fixed
  666. Revision 1.8 2002/03/29 20:15:44 peter
  667. * fixed load_smallset
  668. }