Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- test3
- "__gmpz_add (mpz_t gmpz, mpz_t op1, mpz_t op2)"
- <primitive: #primitiveNativeCall module: #NativeBoostPlugin>
- ^ NBFFICallout cdecl: #( void (mpz_t gmpz, mpz_t gmpz, mpz_t gmpz, ))
- emitCall: [:gen | | asm proxy gmpzAddFcnPtr sa sb sc|
- asm := gen asm.
- proxy := gen proxy.
- sa := gen reserveTemp.
- sb := gen reserveTemp.
- sc := gen reserveTemp.
- "save args"
- asm
- mov: asm ESP ptr to: asm EAX;
- mov: asm EAX to: sa; "a -> sa "
- mov: asm ESP ptr + 4 to: asm EAX;
- mov: asm EAX to: sb; "b -> sb"
- mov: asm ESP ptr + 8 to: asm EAX;
- mov: asm EAX to: sc . "c -> sc"
- gmpzAddFcnPtr := self nbGetSymbolAddress: '__gmpz_add' module:self nbLibraryNameOrHandle.
- asm mov: gmpzAddFcnPtr asUImm to: asm EAX.
- asm call: asm EAX.
- asm cdeclCall: [:call |
- "push function arguments (note, cdecl push order is from right to left )"
- asm
- push: sc;
- push: sb;
- push: sa.
- "get a function addres"
- gmpzAddFcnPtr := self nbGetSymbolAddress: '__gmpz_add' module:self nbLibraryNameOrHandle.
- "put a function address into EAX, and call function"
- asm mov: gmpzAddFcnPtr asUImm to: asm EAX.
- asm call: asm EAX.
- ] alignment: gen stackAlignment .
- ]
Advertisement
Add Comment
Please, Sign In to add comment