mersenneforum.org  

Go Back   mersenneforum.org > Extra Stuff > Programming

Reply
 
Thread Tools
Old 2015-09-02, 12:23   #1
R.D. Silverman
 
R.D. Silverman's Avatar
 
Nov 2003

22·5·373 Posts
Default Visual Studio (yech)

I am trying to recompile some old code as a 64-bit app rather than a win32 App.

I am having trouble doing the LA for a recent NFS computation. It is an address space
problem in Windows. The code will not perform a required malloc. I need to recompile as
a 64-bit app.

Visual Studio reports that both srand48 and mrand48 are unresolved; The linker
can't find them.

Are they no longer supported? They are supposed to be part of POSIX in stdlib.h
R.D. Silverman is offline   Reply With Quote
Old 2015-09-02, 12:46   #2
alpertron
 
alpertron's Avatar
 
Aug 2002
Buenos Aires, Argentina

22×3×113 Posts
Default

They just compute pseudo-random numbers using linear congruential algorithm. So it is faster to replace them by your own code (two or three lines) than typing your problem here. Just look for good multipliers on Knuth's book.
alpertron is offline   Reply With Quote
Old 2015-09-02, 14:11   #3
R.D. Silverman
 
R.D. Silverman's Avatar
 
Nov 2003

11101001001002 Posts
Default

Quote:
Originally Posted by alpertron View Post
They just compute pseudo-random numbers using linear congruential algorithm. So it is faster to replace them by your own code (two or three lines) than typing your problem here. Just look for good multipliers on Knuth's book.
I just finished doing just that....
R.D. Silverman is offline   Reply With Quote
Old 2015-09-02, 14:39   #4
R.D. Silverman
 
R.D. Silverman's Avatar
 
Nov 2003

22×5×373 Posts
Default

Quote:
Originally Posted by R.D. Silverman View Post
I just finished doing just that....
And the beat goes on......

I am trying to rebuild my filter code. It is currently a Win32 app. I am trying to make it
into an x64 app.

Visual Studio is refusing to compile an _asm routine. It reports a lot of syntax errors.
(I've compiled this routine many many times)

It says that the _asm keyword is a non-standard extension and that it is not supported
under the x64 architecture.


Am I screwed? Are _asm directives not supported under Visual Studio 64 bit apps?
R.D. Silverman is offline   Reply With Quote
Old 2015-09-02, 14:56   #5
alpertron
 
alpertron's Avatar
 
Aug 2002
Buenos Aires, Argentina

22·3·113 Posts
Default

I think the best solution is download NASM (which is free) and build the separate assembler files to win64 format. Then you can link the objects generated by the compiler and the ones generated by the assembler.

There is some information at: http://www.nasm.us/doc/nasmdoc7.html

Of course, from the point of view of modularity, it is best to have code in different languages in different files.

Notice that NASM uses Intel syntax, so if you have inline code from gcc, you will need to convert from AT&T to Intel syntax.

Last fiddled with by alpertron on 2015-09-02 at 14:56
alpertron is offline   Reply With Quote
Old 2015-09-02, 15:01   #6
R.D. Silverman
 
R.D. Silverman's Avatar
 
Nov 2003

1D2416 Posts
Default

Quote:
Originally Posted by alpertron View Post
I think the best solution is download NASM (which is free) and build the separate assembler files to win64 format. Then you can link the objects generated by the compiler and the ones generated by the assembler.

There is some information at: http://www.nasm.us/doc/nasmdoc7.html

Of course, from the point of view of modularity, it is best to have code in different languages in different files.
This code is in its own file.
It uses MASM. (i.e. Microsoft syntax)

Quote:



Notice that NASM uses Intel syntax, so if you have inline code from gcc, you will need to convert from AT&T to Intel syntax.
A royal pain in the ass.......

And of course, I don't know Intel syntax......

Last fiddled with by R.D. Silverman on 2015-09-02 at 15:13 Reason: add sentence
R.D. Silverman is offline   Reply With Quote
Old 2015-09-02, 15:12   #7
alpertron
 
alpertron's Avatar
 
Aug 2002
Buenos Aires, Argentina

22×3×113 Posts
Default

I think converting from MASM syntax to NASM is not too difficult, depending of course of the length of your assembler file. But of course you will need a few days to do that. It is not immediate.

Notice that for some instructions, there are registers that are forbidden in 64 bits. Examples: PUSH <reg32bits>, the use of AH, BH, CH or DH if a REX prefix is generated, etc.

You will also need to change the ABI, passing the first parameters in registers RCX, RDX, R8, and R9 instead of the stack. Fifth and next parameters will have to be pushed onto stack.
alpertron is offline   Reply With Quote
Old 2015-09-02, 15:24   #8
R.D. Silverman
 
R.D. Silverman's Avatar
 
Nov 2003

22×5×373 Posts
Default

Quote:
Originally Posted by alpertron View Post
I think converting from MASM syntax to NASM is not too difficult, depending of course of the length of your assembler file. But of course you will need a few days to do that. It is not immediate.

Notice that for some instructions, there are registers that are forbidden in 64 bits. Examples: PUSH <reg32bits>, the use of AH, BH, CH or DH if a REX prefix is generated, etc.

You will also need to change the ABI, passing the first parameters in registers RCX, RDX, R8, and R9 instead of the stack. Fifth and next parameters will have to be pushed onto stack.
I am very much obliged.....

Right now, I don't have the time. Real Work (TM) gets in the way.
R.D. Silverman is offline   Reply With Quote
Old 2015-09-03, 12:33   #9
jasonp
Tribal Bullet
 
jasonp's Avatar
 
Oct 2004

353810 Posts
Default

The 64-bit MS compilers do not allow inline assembly language. Yes, it is a major pain for these kind of projects. If what you want is simple, you may be able to use compiler intrinsics to get the critical instructions, but there's a sharp limit to what intrinsics can do.

Last fiddled with by jasonp on 2015-09-03 at 12:34
jasonp is offline   Reply With Quote
Old 2015-09-06, 08:11   #10
ewmayer
2ω=0
 
ewmayer's Avatar
 
Sep 2002
Rep├║blica de California

1163010 Posts
Default

Quote:
Originally Posted by jasonp View Post
The 64-bit MS compilers do not allow inline assembly language.
That was the precise piece of MSFT stupidity - continuing to charge 'new compiler' money for VS while not doing any work to upgrade its capabilities to keep up with the needs of 64-bit developers - that caused me to finally ditch VS and switch to all-GCC (and GCC-compatible, i.e. clang) for my own code, 4-5 years ago. MSFT actually had a really sweet 32-bit setup, you could inline your ASM without having to worry about GCC-style clobber lists, and do step-through debug of the mixed C/ASM code, it was very pleasant to work with. Which is why they abandoned it in their 64-bit releases, naturally. /sarc

Bob, is there some overriding reason you still use Windows? And, did you resolve your mingw64-download/install issues?
ewmayer is offline   Reply With Quote
Old 2015-09-06, 21:35   #11
R.D. Silverman
 
R.D. Silverman's Avatar
 
Nov 2003

11101001001002 Posts
Default

Quote:
Originally Posted by ewmayer View Post
That was the precise piece of MSFT stupidity - continuing to charge 'new compiler' money for VS while not doing any work to upgrade its capabilities to keep up with the needs of 64-bit developers - that caused me to finally ditch VS and switch to all-GCC (and GCC-compatible, i.e. clang) for my own code, 4-5 years ago. MSFT actually had a really sweet 32-bit setup, you could inline your ASM without having to worry about GCC-style clobber lists, and do step-through debug of the mixed C/ASM code, it was very pleasant to work with. Which is why they abandoned it in their 64-bit releases, naturally. /sarc

Bob, is there some overriding reason you still use Windows? And, did you resolve your mingw64-download/install issues?
I am using Windows because all of the computers that are available to me run Windows........

If I had access to a Unix/Linux machine, I would use it. At work ALL of the Unix development
machines are very very restrictive --> they may be used for project work ONLY. (and there are
other restrictions as well; read between the lines). Public machines run Windows.
R.D. Silverman is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Building GMP-ECM with Visual Studio 2017 Brian Gladman GMP-ECM 16 2017-11-06 16:44
Visual Studio 2015 build Brian Gladman Msieve 3 2016-10-04 10:40
GMP-ECM with Visual Studio 2015 Brian Gladman GMP-ECM 0 2016-09-29 11:33
Using YAFU in Visual Studio queremendi YAFU 12 2015-07-09 15:40
AMD64 Applications with Visual Studio 6 or .Net Ethan (EO) Software 0 2004-08-09 04:07

All times are UTC. The time now is 21:35.

Wed May 12 21:35:54 UTC 2021 up 34 days, 16:16, 0 users, load averages: 2.80, 2.81, 2.66

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.