flat assembler
Message board for the users of flat assembler.
Index
> Main > gmp help plz |
Author |
|
Picnic 14 Oct 2011, 22:19
Hi,
I never used GMP, but i saw the integer functions 4.1: 5 and play a bit. This works fine on my pc, outputs: 18446744073709551615 Code: section '.text' code readable executable start: cinvoke mpz_init, t1 cinvoke mpz_init, t2 cinvoke mpz_set_str, t2, big, 16 cinvoke mpz_set, t1, t2 cinvoke mpz_get_str, buff, 10, t1 cinvoke printf, buff cinvoke mpz_clear, t1 cinvoke mpz_clear, t2 ; ; section '.data' data readable writeable t1 mpz_t t2 mpz_t big db "FFFFFFFFFFFFFFFF",0 buff rb 1024 To load a signed long int i used mpz_set_si Code: cinvoke mpz_set_si, t1, [dval] |
|||
14 Oct 2011, 22:19 |
|
magicSqr 14 Oct 2011, 23:15
Thanks for the quick reply
Picnic wrote:
Sorry, feeling very blond here. I have to set the number as a string first? magicĀ² |
|||
14 Oct 2011, 23:15 |
|
Picnic 15 Oct 2011, 00:22
You're welcome magicSqr.
Depends, i see there are plenty of funtions. I tested an addition, a dword in a big number, success! I have to practise the lib to be more helpful. Code: cinvoke mpz_set_ui, t1, [dval] ; load an unsigned long int cinvoke mpz_init_set_str, t2, big, 16 ; initialize & set big number cinvoke mpz_add, t3, t2, t1 Code: t1 mpz_t t2 mpz_t t3 mpz_t dval dd 4294967295 big db "FFFFFFFFFFFFFFFF",0 |
|||
15 Oct 2011, 00:22 |
|
magicSqr 15 Oct 2011, 10:15
Thanks for the kick-start
Think I'm getting there now Code: format PE console entry start include '%fasminc%\win32a.inc' struct MP_INT _mp_alloc dd ? _mp_size dd ? _mp_d dd ? ends mpz_t fix MP_INT ;--------------------------------------------- section '.text' code readable executable start: cinvoke mpz_init_set_ui, t1, [x] cinvoke mpz_init_set_ui, t2, [y] cinvoke mpz_init, t3 cinvoke mpz_cdiv_q, t3, t2, t1 ;(mpz_t quotient, mpz_t number, mpz_t divisor) ;if t1 or t2 weren't needed after the division ;they could be used for the quotient cinvoke gmp_printf, szFmt, t2, t1, t3 cinvoke system, szPause ret ;--------------------------------------------- section '.data' data readable writeable t1 mpz_t t2 mpz_t t3 mpz_t x dd 47 y dd 7473 szFmt db '%Zd / %Zd = %Zd',0ah,0 szPause db 'pause',0 ;--------------------------------------------- section '.idata' import data readable writeable library libgmp,'libgmp-3.dll',\ msvcrt,'msvcrt.dll' import libgmp,\ mpz_init,'__gmpz_init',\ mpz_init_set_ui,'__gmpz_init_set_ui',\ mpz_cdiv_q, '__gmpz_cdiv_q',\ gmp_printf,'__gmp_printf' import msvcrt,\ printf,'printf',\ system,'system' magicĀ² |
|||
15 Oct 2011, 10:15 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.