2 dnl AMD64 MULX
/ADX simulation support.
4 dnl Contributed to the GNU project by Torbjörn Granlund.
6 dnl Copyright
2013 Free Software Foundation
, Inc.
8 dnl
This file is part of the GNU MP Library.
10 dnl The GNU MP Library is free software
; you can redistribute it and/or modify
11 dnl it under the terms of
either:
13 dnl
* the GNU Lesser General
Public License as published by the Free
14 dnl Software Foundation
; either version 3 of the License, or (at your
15 dnl option
) any later version.
19 dnl
* the GNU General
Public License as published by the Free Software
20 dnl Foundation
; either version 2 of the License, or (at your option) any
23 dnl
or both
in parallel
, as here.
25 dnl The GNU MP Library is distributed
in the hope that it will be useful
, but
26 dnl WITHOUT ANY WARRANTY
; without even the implied warranty of MERCHANTABILITY
27 dnl
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License
30 dnl You should have received copies of the GNU General
Public License
and the
31 dnl GNU Lesser General
Public License along with the GNU MP Library. If
not,
32 dnl see
https://www.gnu.
org/licenses
/.
35 include(`..
/config.m4
')
39 C Fake the MULX instruction
41 C Accept the single explicit parameter on the stack, return the two result
42 C words on the stack. This calling convention means that we need to move the
49 pushfq C preserve all flags
50 mov 32(%rsp), %rax C move retaddr...
51 mov %rax, 24(%rsp) C ...up the stack
52 mov 40(%rsp), %rax C input parameter
56 popfq C restore eflags
64 C Fake the ADOX instruction
66 C Accept the two parameters on the stack, return the result word on the stack.
67 C This calling convention means that we need to move the return address down.
73 mov 32(%rsp), %rcx C src2
74 mov 24(%rsp), %rax C move retaddr...
75 mov %rax, 32(%rsp) C ...down the stack
77 C copy 0(%rsp):11 to 0(%rsp):0
83 C put manipulated flags into eflags, execute a plain adc
86 C copy CF to 0(%rsp):11
88 sbb R32(%rax), R32(%rax)
90 and $0xfffffffffffff7ff, %rbx
93 C put manipulated flags into eflags
104 C Fake the ADCX instruction
106 C Accept the two parameters on the stack, return the result word on the stack.
107 C This calling convention means that we need to move the return address down.
113 mov 32(%rsp), %rcx C src2
114 mov 24(%rsp), %rax C move retaddr...
115 mov %rax, 32(%rsp) C ...down the stack
119 sbb R32(%rax), R32(%rax)
120 and $`'0xfffffffffffffffe, %rbx