Author Topic: Is the compiler influenced by GOTO?  (Read 2072 times)

0 Members and 1 Guest are viewing this topic.

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Is the compiler influenced by GOTO?
« on: March 05, 2021, 10:56:50 pm »
So I am messing with EXE files with DAV hex editor and found that

Quote
DIM A AS _UNSIGNED LONG

DIM B AS _UNSIGNED LONG
GOTO LL1

A = 1094795585

LL1:

PRINT A

B = 1094795585

In the EXE file there is no trace of the compiled instruction  for  A = 1094795585
is that normal?

When the GOTO is commented out, then both instructions for A = 1094795585 and B = 1094795585 show up in the EXE

Quote
DIM A AS _UNSIGNED LONG

DIM B AS _UNSIGNED LONG
'GOTO LL1

A = 1094795585

LL1:

PRINT A

B = 1094795585


What about this case. What will the compiler do now?

Quote
DIM A AS _UNSIGNED LONG

DIM B AS _UNSIGNED LONG
DIM r AS SINGLE
r = RND

IF r > .5 AND r < .6 THEN GOTO LL1

A = 1094795585

LL1:

PRINT A

B = 1094795585

« Last Edit: March 05, 2021, 11:10:19 pm by NOVARSEG »

Offline luke

  • Administrator
  • Seasoned Forum Regular
  • Posts: 324
    • View Profile

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Re: Is the compiler influenced by GOTO?
« Reply #2 on: March 06, 2021, 01:07:15 am »
For that last code example



Quote
DIM A AS _UNSIGNED LONG

DIM B AS _UNSIGNED LONG
DIM r AS SINGLE
r = RND

IF r > .5 AND r < .6 THEN GOTO LL1

A = 1094795585

LL1:

PRINT A

B = 1094795585

The compiler will not skip the instruction because the GOTO is conditional