set.inc 21 KB

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