compiler-rt.S 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. // This file contains assembly implementations of:
  2. // __udivdi3
  3. // __umoddi3
  4. // ... from LLVM's compiler-rt, for use with building
  5. // the ToaruOS kernel with a bare clang, with no need to link
  6. // to libgcc or compiler-rt directly. If more function
  7. // implementations are needed in the future, these should also
  8. // be included here.
  9. // ==============================================================================
  10. // The LLVM Project is under the Apache License v2.0 with LLVM Exceptions:
  11. // ==============================================================================
  12. //
  13. // Apache License
  14. // Version 2.0, January 2004
  15. // http://www.apache.org/licenses/
  16. //
  17. // TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
  18. //
  19. // 1. Definitions.
  20. //
  21. // "License" shall mean the terms and conditions for use, reproduction,
  22. // and distribution as defined by Sections 1 through 9 of this document.
  23. //
  24. // "Licensor" shall mean the copyright owner or entity authorized by
  25. // the copyright owner that is granting the License.
  26. //
  27. // "Legal Entity" shall mean the union of the acting entity and all
  28. // other entities that control, are controlled by, or are under common
  29. // control with that entity. For the purposes of this definition,
  30. // "control" means (i) the power, direct or indirect, to cause the
  31. // direction or management of such entity, whether by contract or
  32. // otherwise, or (ii) ownership of fifty percent (50%) or more of the
  33. // outstanding shares, or (iii) beneficial ownership of such entity.
  34. //
  35. // "You" (or "Your") shall mean an individual or Legal Entity
  36. // exercising permissions granted by this License.
  37. //
  38. // "Source" form shall mean the preferred form for making modifications,
  39. // including but not limited to software source code, documentation
  40. // source, and configuration files.
  41. //
  42. // "Object" form shall mean any form resulting from mechanical
  43. // transformation or translation of a Source form, including but
  44. // not limited to compiled object code, generated documentation,
  45. // and conversions to other media types.
  46. //
  47. // "Work" shall mean the work of authorship, whether in Source or
  48. // Object form, made available under the License, as indicated by a
  49. // copyright notice that is included in or attached to the work
  50. // (an example is provided in the Appendix below).
  51. //
  52. // "Derivative Works" shall mean any work, whether in Source or Object
  53. // form, that is based on (or derived from) the Work and for which the
  54. // editorial revisions, annotations, elaborations, or other modifications
  55. // represent, as a whole, an original work of authorship. For the purposes
  56. // of this License, Derivative Works shall not include works that remain
  57. // separable from, or merely link (or bind by name) to the interfaces of,
  58. // the Work and Derivative Works thereof.
  59. //
  60. // "Contribution" shall mean any work of authorship, including
  61. // the original version of the Work and any modifications or additions
  62. // to that Work or Derivative Works thereof, that is intentionally
  63. // submitted to Licensor for inclusion in the Work by the copyright owner
  64. // or by an individual or Legal Entity authorized to submit on behalf of
  65. // the copyright owner. For the purposes of this definition, "submitted"
  66. // means any form of electronic, verbal, or written communication sent
  67. // to the Licensor or its representatives, including but not limited to
  68. // communication on electronic mailing lists, source code control systems,
  69. // and issue tracking systems that are managed by, or on behalf of, the
  70. // Licensor for the purpose of discussing and improving the Work, but
  71. // excluding communication that is conspicuously marked or otherwise
  72. // designated in writing by the copyright owner as "Not a Contribution."
  73. //
  74. // "Contributor" shall mean Licensor and any individual or Legal Entity
  75. // on behalf of whom a Contribution has been received by Licensor and
  76. // subsequently incorporated within the Work.
  77. //
  78. // 2. Grant of Copyright License. Subject to the terms and conditions of
  79. // this License, each Contributor hereby grants to You a perpetual,
  80. // worldwide, non-exclusive, no-charge, royalty-free, irrevocable
  81. // copyright license to reproduce, prepare Derivative Works of,
  82. // publicly display, publicly perform, sublicense, and distribute the
  83. // Work and such Derivative Works in Source or Object form.
  84. //
  85. // 3. Grant of Patent License. Subject to the terms and conditions of
  86. // this License, each Contributor hereby grants to You a perpetual,
  87. // worldwide, non-exclusive, no-charge, royalty-free, irrevocable
  88. // (except as stated in this section) patent license to make, have made,
  89. // use, offer to sell, sell, import, and otherwise transfer the Work,
  90. // where such license applies only to those patent claims licensable
  91. // by such Contributor that are necessarily infringed by their
  92. // Contribution(s) alone or by combination of their Contribution(s)
  93. // with the Work to which such Contribution(s) was submitted. If You
  94. // institute patent litigation against any entity (including a
  95. // cross-claim or counterclaim in a lawsuit) alleging that the Work
  96. // or a Contribution incorporated within the Work constitutes direct
  97. // or contributory patent infringement, then any patent licenses
  98. // granted to You under this License for that Work shall terminate
  99. // as of the date such litigation is filed.
  100. //
  101. // 4. Redistribution. You may reproduce and distribute copies of the
  102. // Work or Derivative Works thereof in any medium, with or without
  103. // modifications, and in Source or Object form, provided that You
  104. // meet the following conditions:
  105. //
  106. // (a) You must give any other recipients of the Work or
  107. // Derivative Works a copy of this License; and
  108. //
  109. // (b) You must cause any modified files to carry prominent notices
  110. // stating that You changed the files; and
  111. //
  112. // (c) You must retain, in the Source form of any Derivative Works
  113. // that You distribute, all copyright, patent, trademark, and
  114. // attribution notices from the Source form of the Work,
  115. // excluding those notices that do not pertain to any part of
  116. // the Derivative Works; and
  117. //
  118. // (d) If the Work includes a "NOTICE" text file as part of its
  119. // distribution, then any Derivative Works that You distribute must
  120. // include a readable copy of the attribution notices contained
  121. // within such NOTICE file, excluding those notices that do not
  122. // pertain to any part of the Derivative Works, in at least one
  123. // of the following places: within a NOTICE text file distributed
  124. // as part of the Derivative Works; within the Source form or
  125. // documentation, if provided along with the Derivative Works; or,
  126. // within a display generated by the Derivative Works, if and
  127. // wherever such third-party notices normally appear. The contents
  128. // of the NOTICE file are for informational purposes only and
  129. // do not modify the License. You may add Your own attribution
  130. // notices within Derivative Works that You distribute, alongside
  131. // or as an addendum to the NOTICE text from the Work, provided
  132. // that such additional attribution notices cannot be construed
  133. // as modifying the License.
  134. //
  135. // You may add Your own copyright statement to Your modifications and
  136. // may provide additional or different license terms and conditions
  137. // for use, reproduction, or distribution of Your modifications, or
  138. // for any such Derivative Works as a whole, provided Your use,
  139. // reproduction, and distribution of the Work otherwise complies with
  140. // the conditions stated in this License.
  141. //
  142. // 5. Submission of Contributions. Unless You explicitly state otherwise,
  143. // any Contribution intentionally submitted for inclusion in the Work
  144. // by You to the Licensor shall be under the terms and conditions of
  145. // this License, without any additional terms or conditions.
  146. // Notwithstanding the above, nothing herein shall supersede or modify
  147. // the terms of any separate license agreement you may have executed
  148. // with Licensor regarding such Contributions.
  149. //
  150. // 6. Trademarks. This License does not grant permission to use the trade
  151. // names, trademarks, service marks, or product names of the Licensor,
  152. // except as required for reasonable and customary use in describing the
  153. // origin of the Work and reproducing the content of the NOTICE file.
  154. //
  155. // 7. Disclaimer of Warranty. Unless required by applicable law or
  156. // agreed to in writing, Licensor provides the Work (and each
  157. // Contributor provides its Contributions) on an "AS IS" BASIS,
  158. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  159. // implied, including, without limitation, any warranties or conditions
  160. // of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
  161. // PARTICULAR PURPOSE. You are solely responsible for determining the
  162. // appropriateness of using or redistributing the Work and assume any
  163. // risks associated with Your exercise of permissions under this License.
  164. //
  165. // 8. Limitation of Liability. In no event and under no legal theory,
  166. // whether in tort (including negligence), contract, or otherwise,
  167. // unless required by applicable law (such as deliberate and grossly
  168. // negligent acts) or agreed to in writing, shall any Contributor be
  169. // liable to You for damages, including any direct, indirect, special,
  170. // incidental, or consequential damages of any character arising as a
  171. // result of this License or out of the use or inability to use the
  172. // Work (including but not limited to damages for loss of goodwill,
  173. // work stoppage, computer failure or malfunction, or any and all
  174. // other commercial damages or losses), even if such Contributor
  175. // has been advised of the possibility of such damages.
  176. //
  177. // 9. Accepting Warranty or Additional Liability. While redistributing
  178. // the Work or Derivative Works thereof, You may choose to offer,
  179. // and charge a fee for, acceptance of support, warranty, indemnity,
  180. // or other liability obligations and/or rights consistent with this
  181. // License. However, in accepting such obligations, You may act only
  182. // on Your own behalf and on Your sole responsibility, not on behalf
  183. // of any other Contributor, and only if You agree to indemnify,
  184. // defend, and hold each Contributor harmless for any liability
  185. // incurred by, or claims asserted against, such Contributor by reason
  186. // of your accepting any such warranty or additional liability.
  187. //
  188. // END OF TERMS AND CONDITIONS
  189. //
  190. // APPENDIX: How to apply the Apache License to your work.
  191. //
  192. // To apply the Apache License to your work, attach the following
  193. // boilerplate notice, with the fields enclosed by brackets "[]"
  194. // replaced with your own identifying information. (Don't include
  195. // the brackets!) The text should be enclosed in the appropriate
  196. // comment syntax for the file format. We also recommend that a
  197. // file or class name and description of purpose be included on the
  198. // same "printed page" as the copyright notice for easier
  199. // identification within third-party archives.
  200. //
  201. // Copyright [yyyy] [name of copyright owner]
  202. //
  203. // Licensed under the Apache License, Version 2.0 (the "License");
  204. // you may not use this file except in compliance with the License.
  205. // You may obtain a copy of the License at
  206. //
  207. // http://www.apache.org/licenses/LICENSE-2.0
  208. //
  209. // Unless required by applicable law or agreed to in writing, software
  210. // distributed under the License is distributed on an "AS IS" BASIS,
  211. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  212. // See the License for the specific language governing permissions and
  213. // limitations under the License.
  214. //
  215. //
  216. // ---- LLVM Exceptions to the Apache 2.0 License ----
  217. //
  218. // As an exception, if, as a result of your compiling your source code, portions
  219. // of this Software are embedded into an Object form of such source code, you
  220. // may redistribute such embedded portions in such Object form without complying
  221. // with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
  222. //
  223. // In addition, if you combine or link compiled forms of this Software with
  224. // software that is licensed under the GPLv2 ("Combined Software") and if a
  225. // court of competent jurisdiction determines that the patent provision (Section
  226. // 3), the indemnity provision (Section 9) or other Section of the License
  227. // conflicts with the conditions of the GPLv2, you may retroactively and
  228. // prospectively choose to deem waived or otherwise exclude such Section(s) of
  229. // the License, but only in their entirety and only with respect to the Combined
  230. // Software.
  231. //
  232. // ==============================================================================
  233. // Software from third parties included in the LLVM Project:
  234. // ==============================================================================
  235. // The LLVM Project contains third party software which is under different license
  236. // terms. All such code will be identified clearly using at least one of two
  237. // mechanisms:
  238. // 1) It will be in a separate directory tree with its own `LICENSE.txt` or
  239. // `LICENSE` file at the top containing the specific license and restrictions
  240. // which apply to that software, or
  241. // 2) It will contain specific license and restriction terms at the top of every
  242. // file.
  243. //
  244. // ==============================================================================
  245. // Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy):
  246. // ==============================================================================
  247. //
  248. // The compiler_rt library is dual licensed under both the University of Illinois
  249. // "BSD-Like" license and the MIT license. As a user of this code you may choose
  250. // to use it under either license. As a contributor, you agree to allow your code
  251. // to be used under both.
  252. //
  253. // Full text of the relevant licenses is included below.
  254. //
  255. // ==============================================================================
  256. //
  257. // University of Illinois/NCSA
  258. // Open Source License
  259. //
  260. // Copyright (c) 2009-2019 by the contributors listed in CREDITS.TXT
  261. //
  262. // All rights reserved.
  263. //
  264. // Developed by:
  265. //
  266. // LLVM Team
  267. //
  268. // University of Illinois at Urbana-Champaign
  269. //
  270. // http://llvm.org
  271. //
  272. // Permission is hereby granted, free of charge, to any person obtaining a copy of
  273. // this software and associated documentation files (the "Software"), to deal with
  274. // the Software without restriction, including without limitation the rights to
  275. // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  276. // of the Software, and to permit persons to whom the Software is furnished to do
  277. // so, subject to the following conditions:
  278. //
  279. // * Redistributions of source code must retain the above copyright notice,
  280. // this list of conditions and the following disclaimers.
  281. //
  282. // * Redistributions in binary form must reproduce the above copyright notice,
  283. // this list of conditions and the following disclaimers in the
  284. // documentation and/or other materials provided with the distribution.
  285. //
  286. // * Neither the names of the LLVM Team, University of Illinois at
  287. // Urbana-Champaign, nor the names of its contributors may be used to
  288. // endorse or promote products derived from this Software without specific
  289. // prior written permission.
  290. //
  291. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  292. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  293. // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  294. // CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  295. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  296. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
  297. // SOFTWARE.
  298. //
  299. // ==============================================================================
  300. //
  301. // Copyright (c) 2009-2015 by the contributors listed in CREDITS.TXT
  302. //
  303. // Permission is hereby granted, free of charge, to any person obtaining a copy
  304. // of this software and associated documentation files (the "Software"), to deal
  305. // in the Software without restriction, including without limitation the rights
  306. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  307. // copies of the Software, and to permit persons to whom the Software is
  308. // furnished to do so, subject to the following conditions:
  309. //
  310. // The above copyright notice and this permission notice shall be included in
  311. // all copies or substantial portions of the Software.
  312. //
  313. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  314. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  315. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  316. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  317. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  318. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  319. // THE SOFTWARE.
  320. .text
  321. .balign 4
  322. .globl __udivdi3
  323. __udivdi3:
  324. pushl %ebx
  325. movl 20(%esp), %ebx // Find the index i of the leading bit in b.
  326. bsrl %ebx, %ecx // If the high word of b is zero, jump to
  327. jz 9f // the code to handle that special case [9].
  328. // High word of b is known to be non-zero on this branch
  329. movl 16(%esp), %eax // Construct bhi, containing bits [1+i:32+i] of b
  330. shrl %cl, %eax // Practically, this means that bhi is given by:
  331. shrl %eax //
  332. notl %ecx // bhi = (high word of b) << (31 - i) |
  333. shll %cl, %ebx // (low word of b) >> (1 + i)
  334. orl %eax, %ebx //
  335. movl 12(%esp), %edx // Load the high and low words of a, and jump
  336. movl 8(%esp), %eax // to [1] if the high word is larger than bhi
  337. cmpl %ebx, %edx // to avoid overflowing the upcoming divide.
  338. jae 1f
  339. // High word of a is greater than or equal to (b >> (1 + i)) on this branch
  340. divl %ebx // eax <-- qs, edx <-- r such that ahi:alo = bs*qs + r
  341. pushl %edi
  342. notl %ecx
  343. shrl %eax
  344. shrl %cl, %eax // q = qs >> (1 + i)
  345. movl %eax, %edi
  346. mull 20(%esp) // q*blo
  347. movl 12(%esp), %ebx
  348. movl 16(%esp), %ecx // ECX:EBX = a
  349. subl %eax, %ebx
  350. sbbl %edx, %ecx // ECX:EBX = a - q*blo
  351. movl 24(%esp), %eax
  352. imull %edi, %eax // q*bhi
  353. subl %eax, %ecx // ECX:EBX = a - q*b
  354. sbbl $0, %edi // decrement q if remainder is negative
  355. xorl %edx, %edx
  356. movl %edi, %eax
  357. popl %edi
  358. popl %ebx
  359. retl
  360. 1: // High word of a is greater than or equal to (b >> (1 + i)) on this branch
  361. subl %ebx, %edx // subtract bhi from ahi so that divide will not
  362. divl %ebx // overflow, and find q and r such that
  363. //
  364. // ahi:alo = (1:q)*bhi + r
  365. //
  366. // Note that q is a number in (31-i).(1+i)
  367. // fix point.
  368. pushl %edi
  369. notl %ecx
  370. shrl %eax
  371. orl $0x80000000, %eax
  372. shrl %cl, %eax // q = (1:qs) >> (1 + i)
  373. movl %eax, %edi
  374. mull 20(%esp) // q*blo
  375. movl 12(%esp), %ebx
  376. movl 16(%esp), %ecx // ECX:EBX = a
  377. subl %eax, %ebx
  378. sbbl %edx, %ecx // ECX:EBX = a - q*blo
  379. movl 24(%esp), %eax
  380. imull %edi, %eax // q*bhi
  381. subl %eax, %ecx // ECX:EBX = a - q*b
  382. sbbl $0, %edi // decrement q if remainder is negative
  383. xorl %edx, %edx
  384. movl %edi, %eax
  385. popl %edi
  386. popl %ebx
  387. retl
  388. 9: // High word of b is zero on this branch
  389. movl 12(%esp), %eax // Find qhi and rhi such that
  390. movl 16(%esp), %ecx //
  391. xorl %edx, %edx // ahi = qhi*b + rhi with 0 ≤ rhi < b
  392. divl %ecx //
  393. movl %eax, %ebx //
  394. movl 8(%esp), %eax // Find qlo such that
  395. divl %ecx //
  396. movl %ebx, %edx // rhi:alo = qlo*b + rlo with 0 ≤ rlo < b
  397. popl %ebx //
  398. retl // and return qhi:qlo
  399. .text
  400. .balign 4
  401. .globl __umoddi3
  402. __umoddi3:
  403. pushl %ebx
  404. movl 20(%esp), %ebx // Find the index i of the leading bit in b.
  405. bsrl %ebx, %ecx // If the high word of b is zero, jump to
  406. jz 9f // the code to handle that special case [9].
  407. // High word of b is known to be non-zero on this branch
  408. movl 16(%esp), %eax // Construct bhi, containing bits [1+i:32+i] of b
  409. shrl %cl, %eax // Practically, this means that bhi is given by:
  410. shrl %eax //
  411. notl %ecx // bhi = (high word of b) << (31 - i) |
  412. shll %cl, %ebx // (low word of b) >> (1 + i)
  413. orl %eax, %ebx //
  414. movl 12(%esp), %edx // Load the high and low words of a, and jump
  415. movl 8(%esp), %eax // to [2] if the high word is larger than bhi
  416. cmpl %ebx, %edx // to avoid overflowing the upcoming divide.
  417. jae 2f
  418. // High word of a is greater than or equal to (b >> (1 + i)) on this branch
  419. divl %ebx // eax <-- qs, edx <-- r such that ahi:alo = bs*qs + r
  420. pushl %edi
  421. notl %ecx
  422. shrl %eax
  423. shrl %cl, %eax // q = qs >> (1 + i)
  424. movl %eax, %edi
  425. mull 20(%esp) // q*blo
  426. movl 12(%esp), %ebx
  427. movl 16(%esp), %ecx // ECX:EBX = a
  428. subl %eax, %ebx
  429. sbbl %edx, %ecx // ECX:EBX = a - q*blo
  430. movl 24(%esp), %eax
  431. imull %edi, %eax // q*bhi
  432. subl %eax, %ecx // ECX:EBX = a - q*b
  433. jnc 1f // if positive, this is the result.
  434. addl 20(%esp), %ebx // otherwise
  435. adcl 24(%esp), %ecx // ECX:EBX = a - (q-1)*b = result
  436. 1: movl %ebx, %eax
  437. movl %ecx, %edx
  438. popl %edi
  439. popl %ebx
  440. retl
  441. 2: // High word of a is greater than or equal to (b >> (1 + i)) on this branch
  442. subl %ebx, %edx // subtract bhi from ahi so that divide will not
  443. divl %ebx // overflow, and find q and r such that
  444. //
  445. // ahi:alo = (1:q)*bhi + r
  446. //
  447. // Note that q is a number in (31-i).(1+i)
  448. // fix point.
  449. pushl %edi
  450. notl %ecx
  451. shrl %eax
  452. orl $0x80000000, %eax
  453. shrl %cl, %eax // q = (1:qs) >> (1 + i)
  454. movl %eax, %edi
  455. mull 20(%esp) // q*blo
  456. movl 12(%esp), %ebx
  457. movl 16(%esp), %ecx // ECX:EBX = a
  458. subl %eax, %ebx
  459. sbbl %edx, %ecx // ECX:EBX = a - q*blo
  460. movl 24(%esp), %eax
  461. imull %edi, %eax // q*bhi
  462. subl %eax, %ecx // ECX:EBX = a - q*b
  463. jnc 3f // if positive, this is the result.
  464. addl 20(%esp), %ebx // otherwise
  465. adcl 24(%esp), %ecx // ECX:EBX = a - (q-1)*b = result
  466. 3: movl %ebx, %eax
  467. movl %ecx, %edx
  468. popl %edi
  469. popl %ebx
  470. retl
  471. 9: // High word of b is zero on this branch
  472. movl 12(%esp), %eax // Find qhi and rhi such that
  473. movl 16(%esp), %ecx //
  474. xorl %edx, %edx // ahi = qhi*b + rhi with 0 ≤ rhi < b
  475. divl %ecx //
  476. movl %eax, %ebx //
  477. movl 8(%esp), %eax // Find rlo such that
  478. divl %ecx //
  479. movl %edx, %eax // rhi:alo = qlo*b + rlo with 0 ≤ rlo < b
  480. popl %ebx //
  481. xorl %edx, %edx // and return 0:rlo
  482. retl //