reading integer give a random number

Just starting out? Need help? Post your questions and find answers here.
User avatar
bfernhout
Enthusiast
Enthusiast
Posts: 130
Joined: Mon Feb 26, 2018 10:41 pm
Location: Netherlands
Contact:

reading integer give a random number

Post by bfernhout »

i use this code:

Code: Select all

Procedure SRivPlop()
  
  Protected X.i,
  Dim SRivMatrix.i(5)
  Restore SRiv
  
  For X = 0 To 5
    Read.i SRivMatrix(x)
  Next
  
  CallDebugger
  
  Sriv:
  DataSection
    Data.i 0, 0, 3, 3, 0, 0 
  EndDataSection
  
EndProcedure

SRivPlop()
This code gives no errors but when the data is readed, the numbers in the array makes no sence.
the number displayed are :

Code: Select all

-1729382256562026680
5818704903870087214
5846490494384949328
5212952597069561856
2948876202223619211
-4286503255484888088
This is not the numers i did write down in de data.
What is wrong here. Or do i have a bug found?
From my first self made computer till now I stil like computers.
User avatar
bfernhout
Enthusiast
Enthusiast
Posts: 130
Joined: Mon Feb 26, 2018 10:41 pm
Location: Netherlands
Contact:

Re: reading integer give a random number

Post by bfernhout »

Forgot to mentiom that i am running on a AMD 64 bit system 3.8 Ghz windows 11 Pro
AMD Ryzen 7 5800X 8 core
Nvidea GF RTX 3060 TI 8 GB
Memory 32 GB

This information may help
From my first self made computer till now I stil like computers.
Starwolf20
User
User
Posts: 25
Joined: Fri Sep 04, 2009 7:08 pm
Location: Corsica

Re: reading integer give a random number

Post by Starwolf20 »

Works if you write the DataSection like that...

DataSection
Sriv:
Data.i 0, 0, 3, 3, 0, 0
EndDataSection
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: reading integer give a random number

Post by Demivec »

To add a little bit more to what Starwolf20 wrote, if the label is not in the DataSection it will instead reference the point in memory where the code is, not the data.

All data in all the DataSections throughout the program are combined together and stored separately from the code. So if the label isn't in the datasection itself it will only work if you are very lucky.
Last edited by Demivec on Sun Apr 30, 2023 3:18 am, edited 1 time in total.
BarryG
Addict
Addict
Posts: 4127
Joined: Thu Apr 18, 2019 8:17 am

Re: reading integer give a random number

Post by BarryG »

Not a bug. The manual says labels used with "Restore" must go inside the DataSection/EndDataSection, and yours is outside it.
User avatar
bfernhout
Enthusiast
Enthusiast
Posts: 130
Joined: Mon Feb 26, 2018 10:41 pm
Location: Netherlands
Contact:

Re: reading integer give a random number

Post by bfernhout »

Thanks for the information. I did not notice it by miself that i did write it wrong.
From my first self made computer till now I stil like computers.
Post Reply