Silverfrost Forums

Welcome to our forums

Label@ routine

7 Aug 2025 1:42 #32267

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:

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
7 Aug 2025 2:35 #32268

Moji

LABEL@ and JUMP@ are implemented but not documented for x64.

At first sight it looks like they work like this for x64...

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.

7 Aug 2025 3:11 #32269

Quoted from PaulLaidler Moji

LABEL@ and JUMP@ are implemented but not documented for x64.

At first sight it looks like they work like this for x64...

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.

7 Aug 2025 3:45 #32270

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.

8 Aug 2025 6:38 #32271

Quoted from PaulLaidler 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.

8 Aug 2025 2:30 #32272

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...

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
11 Aug 2025 6:16 #32275

Paul thanks for your suggestion. I tried your code and it doesn't work actually (with the check option). I had to make the Jump_Sub subroutine also recursive, so that the program works. It means, all the routines in the stack must be recursive, so that the run time error does not happen. In our real program there are many routines and I am not sure making them all recursive to avoid this run time error, would be the best solution.

Please login to reply.