32 to 64

New to FreeBASIC? Post your questions here.
opicard
Posts: 81
Joined: Feb 26, 2008 16:40

32 to 64

Post by opicard »

Hi,

What precautions to move from 32 to 64 bits with Freebasic?

In truth my code under 32 bits no longer works under 64 bits, and I have yet well used Fb 64b compiler ...

It seems to be a memory pointer problem ...

Thanks in advance
fxm
Moderator
Posts: 12109
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: 32 to 64

Post by fxm »

Size of Integers and Pointers is 32 bits in 32-bit mode and 64 bits in 64-bit mode.
More details about non-functioning in 64-bit would be welcome.

Sometimes a real bug (such as accessing out of its allocated memory) can even be inconsequential in 32-bit and cause a crash in 64-bit (depending on memory mapping).

Does your program work in 32-bit, compiled with gas and also compiled with gcc?
St_W
Posts: 1626
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: 32 to 64

Post by St_W »

The most common fault is the use if (U)INTEGER instead of LONG or INTEGER<32> in places where a 32-bit integer is required. Note that INTEGER is 32-bits on 32-bit systems and 64-bits on 64-bit systems.

Other problems can occur when pointer arithmetic is used wrongly (e.g. with constants instead of SIZEOF(...) or using the wrong pointer data type).
opicard
Posts: 81
Joined: Feb 26, 2008 16:40

Re: 32 to 64

Post by opicard »

fxm wrote:Size of Integers and Pointers is 32 bits in 32-bit mode and 64 bits in 64-bit mode.
More details about non-functioning in 64-bit would be welcome.

Sometimes a real bug (such as accessing out of its allocated memory) can even be inconsequential in 32-bit and cause a crash in 64-bit (depending on memory mapping).

Does your program work in 32-bit, compiled with gas and also compiled with gcc?

see http://france3-regions.francetvinfo.fr/ ... 86541.html

It works successfully sicne 5 years, but i never compiled it with gas or gcc...

the job is supposed to access a camera image with the help of the Escapi Dll, or to access a .bmp file using the Bload instruction.
Instead of the camera image, or the image file, the program displays a pink screen ... then after about a second of loop, a windows error appears and closes the program
opicard
Posts: 81
Joined: Feb 26, 2008 16:40

Re: 32 to 64

Post by opicard »

St_W wrote:The most common fault is the use if (U)INTEGER instead of LONG or INTEGER<32> in places where a 32-bit integer is required. Note that INTEGER is 32-bits on 32-bit systems and 64-bits on 64-bit systems.

Other problems can occur when pointer arithmetic is used wrongly (e.g. with constants instead of SIZEOF(...) or using the wrong pointer data type).
Ok thanks, but it works very successfully since 5 years without any error on a 32 bit windos system... see https://www.youtube.com/user/Picolclav

the job is supposed to access a camera image with the help of the Escapi Dll, or to access a .bmp file using the Bload instruction.
Instead of the camera image, or the image file, the program displays a pink screen ... then after about a second of loop, a windows error appears and closes the program
St_W
Posts: 1626
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: 32 to 64

Post by St_W »

opicard wrote:Ok thanks, but it works very successfully since 5 years without any error on a 32 bit windos system... see https://www.youtube.com/user/Picolclav
Of course, as INTEGER and LONG are practically the same in the 32-bit version of the compiler. As soon as you use the 64-bit compiler that's not the case anymore as INTEGER is a 64-bit number then.
opicard wrote:the job is supposed to access a camera image with the help of the Escapi Dll, or to access a .bmp file using the Bload instruction.
Instead of the camera image, or the image file, the program displays a pink screen ... then after about a second of loop, a windows error appears and closes the program
If you're using an external DLL you need it as 64-bit version for the 64-bit build, but I guess you're already doing that correctly as it probably wouldn't even compile otherwise.

As the INTEGER/LONG issue is so common I'm quite sure that this is also the problem in your code. Especially take a look at the code locations handling with pointers and binary file I/O. If you want us to help you'd need to share (at least parts of) your code, if that is an option.
BasicCoder2
Posts: 3906
Joined: Jan 01, 2009 7:03
Location: Australia

Re: 32 to 64

Post by BasicCoder2 »

opicard wrote:Ok thanks, but it works very successfully since 5 years without any error on a 32 bit windows system... see https://www.youtube.com/user/Picolclav
Really? That is a FreeBASIC program using a webcam?
My usb webcam images were too slow and I had to rely on the laptop's inbuilt camera for fastest responses.

Although I could translate the text of the page I was unable to follow the utube speech as I am limited to the English language.
I think there are visual systems that warn drivers if they stray over a white line. Most of our major highways also have little bumps that cause a vibrating sound should you wander over the line.
.
opicard
Posts: 81
Joined: Feb 26, 2008 16:40

Re: 32 to 64

Post by opicard »

St_W wrote:[
As the INTEGER/LONG issue is so common I'm quite sure that this is also the problem in your code. Especially take a look at the code locations handling with pointers and binary file I/O. If you want us to help you'd need to share (at least parts of) your code, if that is an option.
OK to share, but 22 000 lines too big! is there some other way to send you the code?
opicard
Posts: 81
Joined: Feb 26, 2008 16:40

Re: 32 to 64

Post by opicard »

BasicCoder2 wrote:
opicard wrote:Ok thanks, but it works very successfully since 5 years without any error on a 32 bit windows system... see https://www.youtube.com/user/Picolclav
Really? That is a FreeBASIC program using a webcam?
My usb webcam images were too slow and I had to rely on the laptop's inbuilt camera for fastest responses.

Although I could translate the text of the page I was unable to follow the utube speech as I am limited to the English language.
I think there are visual systems that warn drivers if they stray over a white line. Most of our major highways also have little bumps that cause a vibrating sound should you wander over the line.
.
Yes it does drive my car since 5 years. I do not have to hold the steering wheel when the white lines are clearly visible by the camera, and if not, an alert prompts me to take over the steering wheel.

But it doesn't on 64 bits...
St_W
Posts: 1626
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: 32 to 64

Post by St_W »

opicard wrote:OK to share, but 22 000 lines too big! is there some other way to send you the code?
Wow, that's really a lot of code and probably makes finding the issue quite time consuming. I can't promise that I or other forum members will be able to find the issue(s) in a reasonable amount of time we'd like to invest. Anyway, I'll try my best . To share your file(s) you have to use some external file sharing service and share the link here on the forums. Examples for common sites with registration: Dropbox, Mediafire, OneDrive, Google Drive; without registration: file-upload.net , ... and a lot more; feel free to choose any (but please avoid sites requiring a paid account to download without hassles like e.g. uploaded.net).
paul doe
Moderator
Posts: 1733
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: 32 to 64

Post by paul doe »

opicard wrote:OK to share, but 22 000 lines too big! is there some other way to send you the code?
You can also use GitHub. It's not only for source code, you can put anything in the repository if you wish (all the data that you program needs to run, for example, images, dlls and the like)
opicard
Posts: 81
Joined: Feb 26, 2008 16:40

Re: 32 to 64

Post by opicard »

St_W wrote:
opicard wrote:OK to share, but 22 000 lines too big! is there some other way to send you the code?
Wow, that's really a lot of code and probably makes finding the issue quite time consuming. I can't promise that I or other forum members will be able to find the issue(s) in a reasonable amount of time we'd like to invest. Anyway, I'll try my best . To share your file(s) you have to use some external file sharing service and share the link here on the forums. Examples for common sites with registration: Dropbox, Mediafire, OneDrive, Google Drive; without registration: file-upload.net , ... and a lot more; feel free to choose any (but please avoid sites requiring a paid account to download without hassles like e.g. uploaded.net).

here you are (on one drive) : https://1drv.ms/f/s!AtIs3LBT5S-HdOTqpvs-TJvbYpE

The folder contains the. BAS, the .exe, and the mini environment to work.
You need a 64 bit PC with a camera.
By launching the program, you should get the camera image on the screen, not a pink screen ...
I lightened the code for you ...
grindstone
Posts: 862
Joined: May 05, 2015 5:35
Location: Germany

Re: 32 to 64

Post by grindstone »

Only a suggestion: Replace all Integer keywords with Long (using find & replace of your IDE) and all UInteger with ULong and see if it works. I can't test it, I'm still on 32bit.
opicard
Posts: 81
Joined: Feb 26, 2008 16:40

Re: 32 to 64

Post by opicard »

grindstone wrote:Only a suggestion: Replace all Integer keywords with Long (using find & replace of your IDE) and all UInteger with ULong and see if it works. I can't test it, I'm still on 32bit.
Thanks but... same result...
caseih
Posts: 2157
Joined: Feb 26, 2007 5:32

Re: 32 to 64

Post by caseih »

When you say, "same result" do you mean a crash? Please be specific. There are lots of definitions of "it doesn't work." You said something about a pink screen before.

I'm afraid there's no shortcut to debugging. You'll have to do the normal process of isolating the code where the problem most likely is occurring, and examining the values your data structures are holding vs the working 32-bit version.
Post Reply