Recent Posts

Pages: 1 ... 8 9 [10]
91
The Workshop / 15000 Digits of PI
« Last post by mabdelouahab on September 16, 2018, 02:41:32 AM »
Code: [Select]
Calc__Pi proc
XOR RAX,RAX
MOV a,RAX
MOV R12,__N
loop1:
PUSH R12
;-----------------------------------------------------
MOV d,0
MOV i,r12
Loop2:
;-------------------------------------------------
XOR R11,R11
MOV R11 ,i
ADD R11 ,R11
ADD R11 ,R11
ADD R11 ,R11
LEA RAX,r
ADD R11,RAX
MOV RAX,QWORD PTR [R11]
IMUL RAX,RAX,10000
ADD d,RAX
MOV RAX,i
ADD RAX,RAX
DEC RAX
MOV b,RAX
MOV RAX, d
CDQ
IDIV b
MOV QWORD PTR [R11], RDX
MOV RAX, d
CDQ
IDIV b
MOV d, RAX
SUB R11,8
DEC i
CMP i,0
JE _next
MOV RAX, d
IMUL RAX, i
MOV d, RAX
;-------------------------------------------------
JMP loop2
_next:
MOV RCX,10000
MOV RAX, d
CDQ
IDIV RCX
ADD RAX,a
invoke printf,"%.4d",Rax
MOV RCX,10000
MOV RAX, d
CDQ
IDIV RCX
MOV a, RDX
;-----------------------------------------------------
POP R12
SUB R12,14
CMP R12,0
JG  loop1
ret
Calc__Pi endp

Quote
31415926535897932384626433832795028841971693993751058209749445923078164062862089
98628034825342117067982148086513282306647093844609550582231725359408128481117450
28410270193852110555964462294895493038196442881097566593344612847564823378678316
52712019091456485669234603486104543266482133936072602491412737245870066063155881
74881520920962829254091715364367892590360011330530548820466521384146951941511609
43305727036575959195309218611738193261179310511854807446237996274956735188575272
48912279381830119491298336733624406566430860213949463952247371907021798609437027
70539217176293176752384674818467669405132000568127145263560827785771342757789609
17363717872146844090122495343014654958537105079227968925892354201995611212902196
08640344181598136297747713099605187072113499999983729780499510597317328160963185
95024459455346908302642522308253344685035261931188171010003137838752886587533208
38142061717766914730359825349042875546873115956286388235378759375195778185778053
21712268066130019278766111959092164201989380952572010654858632788659361533818279
68230301952035301852968995773622599413891249721775283479131515574857242454150695
95082953311686172785588907509838175463746493931925506040092770167113900984882401
28583616035637076601047101819429555961989467678374494482553797747268471040475346
46208046684259069491293313677028989152104752162056966024058038150193511253382430
03558764024749647326391419927260426992279678235478163600934172164121992458631503
02861829745557067498385054945885869269956909272107975093029553211653449872027559
60236480665499119881834797753566369807426542527862551818417574672890977772793800
08164706001614524919217321721477235014144197356854816136115735255213347574184946
84385233239073941433345477624168625189835694855620992192221842725502542568876717
90494601653466804988627232791786085784383827967976681454100953883786360950680064
22512520511739298489608412848862694560424196528502221066118630674427862203919494
50471237137869609563643719172874677646575739624138908658326459958133904780275900
99465764078951269468398352595709825822620522489407726719478268482601476990902640
13639443745530506820349625245174939965143142980919065925093722169646151570985838
74105978859597729754989301617539284681382686838689427741559918559252459539594310
49972524680845987273644695848653836736222626099124608051243884390451244136549762
78079771569143599770012961608944169486855584840635342207222582848864815845602850
60168427394522674676788952521385225499546667278239864565961163548862305774564980
35593634568174324112515076069479451096596094025228879710893145669136867228748940
56010150330861792868092087476091782493858900971490967598526136554978189312978482
16829989487226588048575640142704775551323796414515237462343645428584447952658678
21051141354735739523113427166102135969536231442952484937187110145765403590279934
40374200731057853906219838744780847848968332144571386875194350643021845319104848
10053706146806749192781911979399520614196634287544406437451237181921799983910159
19561814675142691239748940907186494231961567945208095146550225231603881930142093
76213785595663893778708303906979207734672218256259966150142150306803844773454920
26054146659252014974428507325186660021324340881907104863317346496514539057962685
61005508106658796998163574736384052571459102897064140110971206280439039759515677
15770042033786993600723055876317635942187312514712053292819182618612586732157919
84148488291644706095752706957220917567116722910981690915280173506712748583222871
83520935396572512108357915136988209144421006751033467110314126711136990865851639
83150197016515116851714376576183515565088490998985998238734552833163550764791853
58932261854896321329330898570642046752590709154814165498594616371802709819943099
24488957571282890592323326097299712084433573265489382391193259746366730583604142
81388303203824903758985243744170291327656180937734440307074692112019130203303801
97621101100449293215160842444859637669838952286847831235526582131449576857262433
44189303968642624341077322697802807318915441101044682325271620105265227211166039
66655730925471105578537634668206531098965269186205647693125705863566201855810072
93606598764861179104533488503461136576867532494416680396265797877185560845529654
12665408530614344431858676975145661406800700237877659134401712749470420562230538
99456131407112700040785473326993908145466464588079727082668306343285878569830523
58089330657574067954571637752542021149557615814002501262285941302164715509792592
30990796547376125517656751357517829666454779174501129961489030463994713296210734
04375189573596145890193897131117904297828564750320319869151402870808599048010941
21472213179476477726224142548545403321571853061422881375850430633217518297986622
37172159160771669254748738986654949450114654062843366393790039769265672146385306
73609657120918076383271664162748888007869256029022847210403172118608204190004229
66171196377921337575114959501566049631862947265473642523081770367515906735023507
28354056704038674351362222477158915049530984448933309634087807693259939780541934
14473774418426312986080998886874132604721569516239658645730216315981931951673538
12974167729478672422924654366800980676928238280689964004824354037014163149658979
40924323789690706977942236250822168895738379862300159377647165122893578601588161
75578297352334460428151262720373431465319777741603199066554187639792933441952154
13418994854447345673831624993419131814809277771038638773431772075456545322077709
21201905166096280490926360197598828161332316663652861932668633606273567630354477
62803504507772355471058595487027908143562401451718062464362679456127531813407833
03362542327839449753824372058353114771199260638133467768796959703098339130771098
70408591337464144282277263465947047458784778720192771528073176790770715721344473
06057007334924369311383504931631284042512192565179806941135280131470130478164378
85185290928545201165839341965621349143415956258658655705526904965209858033850722
42648293972858478316305777756068887644624824685792603953527734803048029005876075
82510474709164396136267604492562742042083208566119062545433721315359584506877246
02901618766795240616342522577195429162991930645537799140373404328752628889639958
79475729174642635745525407909145135711136941091193932519107602082520261879853188
77058429725916778131496990090192116971737278476847268608490033770242429165130050
05168323364350389517029893922334517220138128069650117844087451960121228599371623
13017114448464090389064495444006198690754851602632750529834918740786680881833851
02283345085048608250393021332197155184306354550076682829493041377655279397517546
13953984683393638304746119966538581538420568533862186725233402830871123282789212
50771262946322956398989893582116745627010218356462201349671518819097303811980049
73407239610368540664319395097901906996395524530054505806855019567302292191393391
85680344903982059551002263535361920419947455385938102343955449597783779023742161
72711172364343543947822181852862408514006660443325888569867054315470696574745855
03323233421073015459405165537906866273337995851156257843229882737231989875714159
57811196358330059408730681216028764962867446047746491599505497374256269010490377
81986835938146574126804925648798556145372347867330390468838343634655379498641927
05638729317487233208376011230299113679386270894387993620162951541337142489283072
20126901475466847653576164773794675200490757155527819653621323926406160136358155
90742202020318727760527721900556148425551879253034351398442532234157623361064250
63904975008656271095359194658975141310348227693062474353632569160781547818115284
36679570611086153315044521274739245449454236828860613408414863776700961207151249
14043027253860764823634143346235189757664521641376796903149501910857598442391986
29164219399490723623464684411739403265918404437805133389452574239950829659122850
85558215725031071257012668302402929525220118726767562204154205161841634847565169
99811614101002996078386909291603028840026910414079288621507842451670908700069928
21206604183718065355672525325675328612910424877618258297651579598470356222629348
60034158722980534989650226291748788202734209222245339856264766914905562842503912
75771028402799806636582548892648802545661017296702664076559042909945681506526530
53718294127033693137851786090407086671149655834343476933857817113864558736781230
14587687126603489139095620099393610310291616152881384379099042317473363948045759
31493140529763475748119356709110137751721008031559024853090669203767192203322909
43346768514221447737939375170344366199104033751117354719185504644902636551281622
88244625759163330391072253837421821408835086573917715096828874782656995995744906
61758344137522397096834080053559849175417381883999446974867626551658276584835884
53142775687900290951702835297163445621296404352311760066510124120065975585127617
85838292041974844236080071930457618932349229279650198751872127267507981255470958
90455635792122103334669749923563025494780249011419521238281530911407907386025152
27429958180724716259166854513331239480494707911915326734302824418604142636395480
00448002670496248201792896476697583183271314251702969234889627668440323260927524
96035799646925650493681836090032380929345958897069536534940603402166544375589004
56328822505452556405644824651518754711962184439658253375438856909411303150952617
93780029741207665147939425902989695946995565761218656196733786236256125216320862
86922210327488921865436480229678070576561514463204692790682120738837781423356282
36089632080682224680122482611771858963814091839036736722208883215137556003727983
94004152970028783076670944474560134556417254370906979396122571429894671543578468
78861444581231459357198492252847160504922124247014121478057345510500801908699603
30276347870810817545011930714122339086639383395294257869050764310063835198343893
41596131854347546495569781038293097164651438407007073604112373599843452251610507
02705623526601276484830840761183013052793205427462865403603674532865105706587488
22569815793678976697422057505968344086973502014102067235850200724522563265134105
59240190274216248439140359989535394590944070469120914093870012645600162374288021
09276457931065792295524988727584610126483699989225695968815920560010165525637567
85667227966198857827948488558343975187445455129656344348039664205579829368043522
02770984294232533022576341807039476994159791594530069752148293366555661567873640
05366656416547321704390352132954352916941459904160875320186837937023488868947915
10716378529023452924407736594956305100742108714261349745956151384987137570471017
87957310422969066670214498637464595280824369445789772330048764765241339075920434
01963403911473202338071509522201068256342747164602433544005152126693249341967397
70415956837535551667302739007497297363549645332888698440611964961627734495182736
95588220757355176651589855190986665393549481068873206859907540792342402300925900
70173196036225475647894064754834664776041146323390565134330684495397907090302346
04614709616968868850140834704054607429586991382966824681857103188790652870366508
32431974404771855678934823089431068287027228097362480939962706074726455399253994
42808113736943388729406307926159599546262462970706259484556903471197299640908941
80595343932512362355081349490043642785271383159125689892951964272875739469142725
34366941532361004537304881985517065941217352462589548730167600298865925786628561
24966552353382942878542534048308330701653722856355915253478445981831341129001999
20598135220511733658564078264849427644113763938669248031183644536985891754426473
99882284621844900877769776312795722672655562596282542765318300134070922334365779
16012809317940171859859993384923549564005709955856113498025249906698423301735035
80440811685526531170995708994273287092584878944364600504108922669178352587078595
12983441729535195378855345737426085902908176515578039059464087350612322611200937
31080485485263572282576820341605048466277504500312620080079980492548534694146977
51649327095049346393824322271885159740547021482897111777923761225788734771881968
25462981268685817050740272550263329044976277894423621674119186269439650671515779
58675648239939176042601763387045499017614364120469218237076488783419689686118155
81587360629386038101712158552726683008238340465647588040513808016336388742163714
06435495561868964112282140753302655100424104896783528588290243670904887118190909
49453314421828766181031007354770549815968077200947469613436092861484941785017180
77930681085469000944589952794243981392135055864221964834915126390128038320010977
38680662877923971801461343244572640097374257007359210031541508936793008169980536
52027600727749674584002836240534603726341655425902760183484030681138185510597970
56640075094260878857357960373245141467867036880988060971642584975951380693094494
01515422221943291302173912538355915031003330325111749156969174502714943315155885
40392216409722910112903552181576282328318234254832611191280092825256190205263016
39114772473314857391077758744253876117465786711694147764214411112635835538713610
11023267987756410246824032264834641766369806637857681349204530224081972785647198
39630878154322116691224641591177673225326433568614618654522268126887268445968442
41610785401676814208088502800541436131462308210259417375623899420757136275167457
31891894562835257044133543758575342698699472547031656613991999682628247270641336
22217892390317608542894373393561889165125042440400895271983787386480584726895462
43882343751788520143956005710481194988423906061369573423155907967034614914344788
63604103182350736502778590897578272731305048893989009923913503373250855982655867
08924261242947367019390772713070686917092646254842324074855036608013604668951184
00936686095463250021458529309500009071510582362672932645373821049387249966993394
24685516483261134146110680267446637334375340764294026682973865220935701626384648
52851490362932019919968828517183953669134522244470804592396602817156551565666111
35982311225062890585491450971575539002439315351909021071194573002438801766150352
70862602537881797519478061013715004489917210022201335013106016391541589578037117
79277522597874289191791552241718958536168059474123419339842021874564925644346239
25319531351033114763949119950728584306583619353693296992898379149419394060857248
63968836903265564364216644257607914710869984315733749648835292769328220762947282
38153740996154559879825989109371712621828302584811238901196822142945766758071865
38065064870261338928229949725745303328389638184394477077940228435988341003583854
23897354243956475556840952248445541392394100016207693636846776413017819659379971
55746854194633489374843912974239143365936041003523437770658886778113949861647874
71407932638587386247328896456435987746676384794665040741118256583788784548581489
62961273998413442726086061872455452360643153710112746809778704464094758280348769
75894832824123929296058294861919667091895808983320121031843034012849511620353428
01441276172858302435598300320420245120728725355811958401491809692533950757784000
67465526031446167050827682772223534191102634163157147406123850425845988419907611
28725805911393568960143166828317632356732541707342081733223046298799280490851409
47903688786878949305469557030726190095020764334933591060245450864536289354568629
58531315337183868265617862273637169757741830239860065914816164049449650117321313
8957470620884748023653710311508984279927
        3687ms for 15000 Digit of PI
Source: Computing Pi in C
92
The Workshop / Re: Multiply two QWORDs
« Last post by jj2007 on September 16, 2018, 02:41:25 AM »
Interesting: CVTSI2SD--Convert Doubleword Integer to Scalar Double-Precision Floating-Point Value

That is the definition, but in your code it loads a QWORD. And in 32-bit land, it refuses to load more than a DWORD. Something is wrong with the definition :(
93
The Laboratory / Re: Floating point PRNG
« Last post by HSE on September 16, 2018, 02:30:47 AM »
Exactly!!

Later:
Just in case try 32 bit version.
I think 64 bit version only erase some macros implemented like HLL in JWASM derivatives, but I'm not sure.
   

I write well in previous post: 32 bit
94
The Workshop / Re: Multiply two QWORDs
« Last post by hutch-- on September 16, 2018, 02:19:03 AM »
Don't know if its fast but the results are correct. LATER : Cleaned up.

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    include \masm32\include64\masm64rt.inc

    .code

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

 entry_point proc

    LOCAL quad1 :QWORD
    LOCAL quad2 :QWORD

    mov quad1, 100
    mov quad2, 100

    cvtsi2sd xmm0, quad1
    cvtsi2sd xmm1, quad2
    mulsd xmm0, xmm1
    cvtsd2si r11, xmm0

    conout str$(r11),lf

    waitkey
    .exit

 entry_point endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    end
95
The Laboratory / Re: Floating point PRNG
« Last post by AW on September 16, 2018, 02:16:40 AM »
96
The Workshop / Re: Multiply two QWORDs
« Last post by jj2007 on September 16, 2018, 01:48:51 AM »
Thanks, will have a look. It doesn't look any simpler, though.
97
The Laboratory / Re: Floating point PRNG
« Last post by HSE on September 16, 2018, 01:12:03 AM »
ObjAsm32 RNG  :t
98
The Laboratory / Floating point PRNG
« Last post by AW on September 16, 2018, 01:01:45 AM »
Probably, it is buried somewhere but I could not find any ASM floating point pseudo-random number generator (PRNG). Sure I found many ASM integer PRNG  :t
Actually, it is very easy to produce a floating point PRNG from an integer one, using the knowledge we have (or might have) about IEEE 754.
This is the main purpose of this essay, but I will use the opportunity to present the results for REAL8, REAL4 and HALF with 15, 6 and 3 significant digits (YES, printf does have a little know capacity for that).

And this time I will have no mercy for people with too old computers (older than Ivy Bridge), sorry. I will use the rdrand for random numbers, and the vcvtps2ph and vcvtph2ps for the HALFs in order to make the code shorter.

Code: [Select]
REAL8 Value (15 significant digits)=-9650.29779824708
REAL4 Value (6 significant digits)=-9650.3
HALF Value (3 significant digits)=-9.65e+003


REAL8 Value (15 significant digits)=-40373.2896508689
REAL4 Value (6 significant digits)=-40373.3
HALF Value (3 significant digits)=-4.04e+004


REAL8 Value (15 significant digits)=-22474.0836345981
REAL4 Value (6 significant digits)=-22474.1
HALF Value (3 significant digits)=-2.25e+004


REAL8 Value (15 significant digits)=43495.2071411472
REAL4 Value (6 significant digits)=43495.2
HALF Value (3 significant digits)=4.35e+004


REAL8 Value (15 significant digits)=42173.4249726214
REAL4 Value (6 significant digits)=42173.4
HALF Value (3 significant digits)=4.22e+004


REAL8 Value (15 significant digits)=10021.6594674816
REAL4 Value (6 significant digits)=10021.7
HALF Value (3 significant digits)=1e+004


REAL8 Value (15 significant digits)=14000.1614663608
REAL4 Value (6 significant digits)=14000.2
HALF Value (3 significant digits)=1.4e+004


REAL8 Value (15 significant digits)=7151.36409892466
REAL4 Value (6 significant digits)=7151.36
HALF Value (3 significant digits)=7.15e+003


REAL8 Value (15 significant digits)=16185.3460413327
REAL4 Value (6 significant digits)=16185.3
HALF Value (3 significant digits)=1.62e+004


REAL8 Value (15 significant digits)=-58318.6575650965
REAL4 Value (6 significant digits)=-58318.7
HALF Value (3 significant digits)=-5.83e+004


REAL8 Value (15 significant digits)=21377.3863558798
REAL4 Value (6 significant digits)=21377.4
HALF Value (3 significant digits)=2.14e+004


REAL8 Value (15 significant digits)=62768.6210416745
REAL4 Value (6 significant digits)=62768.6
HALF Value (3 significant digits)=6.28e+004


REAL8 Value (15 significant digits)=-7787.06495612929
REAL4 Value (6 significant digits)=-7787.06
HALF Value (3 significant digits)=-7.79e+003


REAL8 Value (15 significant digits)=42013.0045911184
REAL4 Value (6 significant digits)=42013
HALF Value (3 significant digits)=4.2e+004


REAL8 Value (15 significant digits)=-61322.6968192349
REAL4 Value (6 significant digits)=-61322.7
HALF Value (3 significant digits)=-6.13e+004


REAL8 Value (15 significant digits)=27707.4044548888
REAL4 Value (6 significant digits)=27707.4
HALF Value (3 significant digits)=2.77e+004


REAL8 Value (15 significant digits)=-4169.53884418745
REAL4 Value (6 significant digits)=-4169.54
HALF Value (3 significant digits)=-4.17e+003


REAL8 Value (15 significant digits)=21556.1687919651
REAL4 Value (6 significant digits)=21556.2
HALF Value (3 significant digits)=2.16e+004


REAL8 Value (15 significant digits)=54650.2552792932
REAL4 Value (6 significant digits)=54650.3
HALF Value (3 significant digits)=5.47e+004


REAL8 Value (15 significant digits)=29722.4088189263
REAL4 Value (6 significant digits)=29722.4
HALF Value (3 significant digits)=2.97e+004
99
The Workshop / Re: Multiply two QWORDs
« Last post by Biterider on September 16, 2018, 12:44:57 AM »
Hi JJ
I found this old macro
Code: [Select]
; Macro:      qdmul
; Purpose:    Multiply a QWORD by a DWORD.
; Arguments:  ecx::edx::eax = edx::eax * ebx.

qdmul macro
    push eax
    mov eax, edx
    mul ebx
    mov ecx, edx
    pop edx
    xchg eax, edx
    push edx
    mul ebx
    pop ebx
    add edx, ebx
    adc ecx, 0
endm

You can use it, splitting the multiplication in 4 steps:
1. multiply be the high 32 bit using the macro
2. shift the result by 32 ecx::edx::eax --> edi::ecx::edx::eax
3. multiply be the low 32 bit using the macro ecx::edx::eax
4. add the result of step 2 & 3

Biterider
100
ASMC Development / Re: Large integers and floats
« Last post by nidud on September 16, 2018, 12:38:56 AM »
Added the streamed versions of the conversion.
Code: [Select]
include DirectXPackedVector.inc

    .code

XMConvertHalfToFloatStream proc uses rsi rdi rbx pOutputStream:ptr float, OutputStride:size_t,
        pInputStream:ptr HALF, InputStride:size_t, HalfCount:size_t

    .assert(pOutputStream)
    .assert(pInputStream)
    .assert(InputStride >= sizeof(HALF))
    .assert(OutputStride >= sizeof(float))

    .for (rsi = r8, rdi = rcx, ebx = 0: rbx < HalfCount: ebx++)

        XMConvertHalfToFloat([rsi])
        mov [rdi],eax
        add rsi,InputStride
        add rdi,OutputStride
    .endf

    mov rax,pOutputStream
    ret

XMConvertHalfToFloatStream endp

    end
So, mostly about storage.
Pages: 1 ... 8 9 [10]