set.inc 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739
  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 %eax,%edi
  305. movl %edx,%esi
  306. movl %ecx,%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 %eax,%edi
  343. movl %edx,%esi
  344. movl %ecx,%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 %eax,%edi
  382. movl %edx,%esi
  383. movl %ecx,%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 %eax,%edi
  423. movl %edx,%esi
  424. movl %ecx,%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. {$ifdef REGCALL}
  456. movl %eax,%esi
  457. movl %edx,%edi
  458. {$else}
  459. movl set1,%esi
  460. movl set2,%edi
  461. {$endif}
  462. movl $8,%ecx
  463. .LMCOMPSETS1:
  464. movl (%esi),%eax
  465. movl (%edi),%edx
  466. cmpl %edx,%eax
  467. jne .LMCOMPSETEND
  468. addl $4,%esi
  469. addl $4,%edi
  470. decl %ecx
  471. jnz .LMCOMPSETS1
  472. { we are here only if the two sets are equal
  473. we have zero flag set, and that what is expected }
  474. .LMCOMPSETEND:
  475. {$ifdef hascompilerproc}
  476. seteb %al
  477. {$endif hascompilerproc}
  478. movl saveedi,%edi
  479. movl saveesi,%esi
  480. end;
  481. {$define FPC_SYSTEM_HAS_FPC_SET_CONTAINS_SET}
  482. function fpc_set_contains_sets(const set1,set2: fpc_normal_set): boolean;assembler;[public,alias:'FPC_SET_CONTAINS_SETS']; {$ifdef hascompilerproc} compilerproc; {$endif}
  483. {
  484. on exit, zero flag is set if set1 <= set2 (set2 contains set1)
  485. }
  486. var
  487. saveesi,saveedi : longint;
  488. asm
  489. movl %edi,saveedi
  490. movl %esi,saveesi
  491. {$ifdef REGCALL}
  492. movl %eax,%esi
  493. movl %edx,%edi
  494. {$else}
  495. movl set1,%esi
  496. movl set2,%edi
  497. {$endif}
  498. movl $8,%ecx
  499. .LMCONTAINSSETS1:
  500. movl (%esi),%eax
  501. movl (%edi),%edx
  502. andl %eax,%edx
  503. cmpl %edx,%eax {set1 and set2 = set1?}
  504. jne .LMCONTAINSSETEND
  505. addl $4,%esi
  506. addl $4,%edi
  507. decl %ecx
  508. jnz .LMCONTAINSSETS1
  509. { we are here only if set2 contains set1
  510. we have zero flag set, and that what is expected }
  511. .LMCONTAINSSETEND:
  512. {$ifdef hascompilerproc}
  513. seteb %al
  514. {$endif hascompilerproc}
  515. movl saveedi,%edi
  516. movl saveesi,%esi
  517. end;
  518. {$ifdef LARGESETS}
  519. {$error Needs to be fixed for register calling first!}
  520. procedure fpc_largeset_set_word(p : pointer;b : word);assembler;[public,alias:'FPC_LARGESET_SET_WORD']; {$ifdef hascompilerproc} compilerproc; {$endif}
  521. {
  522. sets the element b in set p works for sets larger than 256 elements
  523. not yet use by the compiler so
  524. }
  525. asm
  526. pushl %eax
  527. movl p,%edi
  528. movw b,%ax
  529. andl $0xfff8,%eax
  530. shrl $3,%eax
  531. addl %eax,%edi
  532. movb 12(%ebp),%al
  533. andl $7,%eax
  534. btsl %eax,(%edi)
  535. popl %eax
  536. end;
  537. procedure fpc_largeset_in_word(p : pointer;b : word);assembler;[public,alias:'FPC_LARGESET_IN_WORD']; {$ifdef hascompilerproc} compilerproc; {$endif}
  538. {
  539. tests if the element b is in the set p the carryflag is set if it present
  540. works for sets larger than 256 elements
  541. }
  542. asm
  543. pushl %eax
  544. movl p,%edi
  545. movw b,%ax
  546. andl $0xfff8,%eax
  547. shrl $3,%eax
  548. addl %eax,%edi
  549. movb 12(%ebp),%al
  550. andl $7,%eax
  551. btl %eax,(%edi)
  552. popl %eax
  553. end;
  554. procedure fpc_largeset_add_sets(set1,set2,dest : pointer;size : longint);assembler;[public,alias:'FPC_LARGESET_ADD_SETS']; {$ifdef hascompilerproc} compilerproc; {$endif}
  555. {
  556. adds set1 and set2 into set dest size is the number of bytes in the set
  557. }
  558. asm
  559. movl set1,%esi
  560. movl set2,%ebx
  561. movl dest,%edi
  562. movl size,%ecx
  563. .LMADDSETSIZES1:
  564. lodsl
  565. orl (%ebx),%eax
  566. stosl
  567. addl $4,%ebx
  568. decl %ecx
  569. jnz .LMADDSETSIZES1
  570. end;
  571. procedure fpc_largeset_mul_sets(set1,set2,dest : pointer;size : longint);assembler;[public,alias:'FPC_LARGESET_MUL_SETS']; {$ifdef hascompilerproc} compilerproc; {$endif}
  572. {
  573. multiplies (i.E. takes common elements of) set1 and set2 result put in
  574. dest size is the number of bytes in the set
  575. }
  576. asm
  577. movl set1,%esi
  578. movl set2,%ebx
  579. movl dest,%edi
  580. movl size,%ecx
  581. .LMMULSETSIZES1:
  582. lodsl
  583. andl (%ebx),%eax
  584. stosl
  585. addl $4,%ebx
  586. decl %ecx
  587. jnz .LMMULSETSIZES1
  588. end;
  589. procedure fpc_largeset_sub_sets(set1,set2,dest : pointer;size : longint);assembler;[public,alias:'FPC_LARGESET_SUB_SETS']; {$ifdef hascompilerproc} compilerproc; {$endif}
  590. asm
  591. movl set1,%esi
  592. movl set2,%ebx
  593. movl dest,%edi
  594. movl size,%ecx
  595. .LMSUBSETSIZES1:
  596. lodsl
  597. movl (%ebx),%edx
  598. notl %edx
  599. andl %edx,%eax
  600. stosl
  601. addl $4,%ebx
  602. decl %ecx
  603. jnz .LMSUBSETSIZES1
  604. end;
  605. procedure fpc_largeset_symdif_sets(set1,set2,dest : pointer;size : longint);assembler;[public,alias:'FPC_LARGESET_SYMDIF_SETS']; {$ifdef hascompilerproc} compilerproc; {$endif}
  606. {
  607. computes the symetric diff from set1 to set2 result in dest
  608. }
  609. asm
  610. movl set1,%esi
  611. movl set2,%ebx
  612. movl dest,%edi
  613. movl size,%ecx
  614. .LMSYMDIFSETSIZE1:
  615. lodsl
  616. movl (%ebx),%edx
  617. xorl %edx,%eax
  618. stosl
  619. addl $4,%ebx
  620. decl %ecx
  621. jnz .LMSYMDIFSETSIZE1
  622. end;
  623. procedure fpc_largeset_comp_sets(set1,set2 : pointer;size : longint);assembler;[public,alias:'FPC_LARGESET_COMP_SETS']; {$ifdef hascompilerproc} compilerproc; {$endif}
  624. asm
  625. movl set1,%esi
  626. movl set2,%edi
  627. movl size,%ecx
  628. .LMCOMPSETSIZES1:
  629. lodsl
  630. movl (%edi),%edx
  631. cmpl %edx,%eax
  632. jne .LMCOMPSETSIZEEND
  633. addl $4,%edi
  634. decl %ecx
  635. jnz .LMCOMPSETSIZES1
  636. { we are here only if the two sets are equal
  637. we have zero flag set, and that what is expected }
  638. .LMCOMPSETSIZEEND:
  639. end;
  640. procedure fpc_largeset_contains_sets(set1,set2 : pointer; size: longint);assembler;[public,alias:'FPC_LARGESET_CONTAINS_SETS']; {$ifdef hascompilerproc} compilerproc; {$endif}
  641. {
  642. on exit, zero flag is set if set1 <= set2 (set2 contains set1)
  643. }
  644. asm
  645. movl set1,%esi
  646. movl set2,%edi
  647. movl size,%ecx
  648. .LMCONTAINSSETS2:
  649. movl (%esi),%eax
  650. movl (%edi),%edx
  651. andl %eax,%edx
  652. cmpl %edx,%eax {set1 and set2 = set1?}
  653. jne .LMCONTAINSSETEND2
  654. addl $4,%esi
  655. addl $4,%edi
  656. decl %ecx
  657. jnz .LMCONTAINSSETS2
  658. { we are here only if set2 contains set1
  659. we have zero flag set, and that what is expected }
  660. .LMCONTAINSSETEND2:
  661. end;
  662. {$endif LARGESET}
  663. {
  664. $Log$
  665. Revision 1.12 2003-11-11 21:08:17 peter
  666. * REGCALL define added
  667. Revision 1.11 2003/09/08 18:21:37 peter
  668. * save edi,esi,ebx
  669. Revision 1.10 2003/05/26 19:36:46 peter
  670. * fpc_shortstr_concat is now the same for all targets
  671. * fpc_shortstr_append_shortstr added for optimized code generation
  672. Revision 1.9 2002/09/07 16:01:19 peter
  673. * old logs removed and tabs fixed
  674. Revision 1.8 2002/03/29 20:15:44 peter
  675. * fixed load_smallset
  676. }