 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
Moji
Joined: 30 Sep 2020 Posts: 33
|
Posted: Thu Aug 07, 2025 2:42 pm Post subject: Label@ routine |
|
|
Hello,
I become a run time error in the following test program as I enter the JUMP_Sub for the second time in 64-bit mode. In 32-bit, I can enter the JUMP_Sub recursively without problem, as I expected.
Apart from that, I had also difficulties, in debugging the code and finding the reason of error in our program. As you can see, the run time error apears in Interface_Sub, although this subroutine has no silverfrost function in it. Here is the test code:
Code: |
Module MTest
Complex (Kind=2) :: komp
End Module
Program Test_Label
Use MTest
Integer a
komp = (0.D0, 0.D0)
100 Write(*,*) 'Enter a number: '
Read(*,*) a
Call LABEL@ (komp,*200)
Call Interface_Sub()
200 Continue
Write(*,*) 'Next'
Goto 100
End Program
Subroutine Interface_Sub()
Write(*,*) 'within Interface_Sub'
Call Jump_Sub()
End Subroutine
Subroutine Jump_Sub()
Use MTest
Call Jump@(komp)
End Subroutine |
|
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8240 Location: Salford, UK
|
Posted: Thu Aug 07, 2025 3:35 pm Post subject: |
|
|
Moji
LABEL@ and JUMP@ are implemented but not documented for x64.
At first sight it looks like they work like this for x64...
Code: |
Module MTest
integer LAB1
End Module
Program Test_Label
Use MTest
Integer a
Call LABEL@(LAB1)
100 Write(*,*) 'Enter a number: '
Read(*,*) a
Call Interface_Sub()
Write(*,*) 'Next'
Goto 100
End Program
Subroutine Interface_Sub()
Write(*,*) 'within Interface_Sub'
Call Jump_Sub()
End Subroutine
Subroutine Jump_Sub()
Use MTest
Call Jump@(LAB1)
End Subroutine |
The call to LABEL@ takes one argument that could be of any type. The point where LABEL@ is called sets a label using the address of the argument.
In this sample program 'Next' is not printed and a jump is made directly to the point immediately after the call to LABEL@ which is the same as the explicit 100.
LAB1 does not need a value and the explicit label 100 is not used. |
|
Back to top |
|
 |
Moji
Joined: 30 Sep 2020 Posts: 33
|
Posted: Thu Aug 07, 2025 4:11 pm Post subject: Re: |
|
|
PaulLaidler wrote: |
Moji
LABEL@ and JUMP@ are implemented but not documented for x64.
At first sight it looks like they work like this for x64...
Code: |
Module MTest
integer LAB1
End Module
Program Test_Label
Use MTest
Integer a
Call LABEL@(LAB1)
100 Write(*,*) 'Enter a number: '
Read(*,*) a
Call Interface_Sub()
Write(*,*) 'Next'
Goto 100
End Program
Subroutine Interface_Sub()
Write(*,*) 'within Interface_Sub'
Call Jump_Sub()
End Subroutine
Subroutine Jump_Sub()
Use MTest
Call Jump@(LAB1)
End Subroutine |
The call to LABEL@ takes one argument that could be of any type. The point where LABEL@ is called sets a label using the address of the argument.
In this sample program 'Next' is not printed and a jump is made directly to the point immediately after the call to LABEL@ which is the same as the explicit 100.
LAB1 does not need a value and the explicit label 100 is not used. |
Paul
Thanks for the explanation. Now I understand how it actually works. However, it doesn't solve the issue. I tested your code also, and it still gives me a runtime error, this time for 64bit and 32bit. In 32bit, right after the first call of LABEL@. The 64bit program behaves different than 32bit, and same as my test program, the first time that the JUMP@ is called, it works fine. But before JUMP@ is called for the second time, the error happens. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8240 Location: Salford, UK
|
Posted: Thu Aug 07, 2025 4:45 pm Post subject: |
|
|
Moji
You can't use the same code for both Win32 and x64.
For x64 you can start with my template and vary it according to your needs.
If the result does not work then please post a sample. |
|
Back to top |
|
 |
Moji
Joined: 30 Sep 2020 Posts: 33
|
Posted: Fri Aug 08, 2025 7:38 am Post subject: Re: |
|
|
PaulLaidler wrote: |
Moji
You can't use the same code for both Win32 and x64.
For x64 you can start with my template and vary it according to your needs.
If the result does not work then please post a sample. |
Paul
I used your template for x64 and still get the error message. I use the 9.06 version of the compiler and the /check option.
If I deactivate the /check option, the program works fine. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8240 Location: Salford, UK
|
Posted: Fri Aug 08, 2025 3:30 pm Post subject: |
|
|
First a correction: You can use the same coding for Win32 and x64 but for x64 the second argument of LABEL@ is not used.
The simple fix for the failure is to make the routine RECURSIVE...
Code: |
Module MTest
integer LAB1
End Module
Program Test_Label
Use MTest
Integer a
Call LABEL@(LAB1,*100)
100 Write(*,*) 'Enter a number: '
Read(*,*) a
Call Interface_Sub()
Write(*,*) 'Next'
Goto 100
End Program
Recursive Subroutine Interface_Sub()
Write(*,*) 'within Interface_Sub'
Call Jump_Sub()
End Subroutine
Subroutine Jump_Sub()
Use MTest
Call Jump@(LAB1)
End Subroutine |
|
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|