SNIPPET TO DISPLAY VARIABLE LOCATIONS

bbc/electron apps, languages, utils, educational progs, demos + more
Post Reply
User avatar
Gelpack
Posts: 713
Joined: Tue Mar 01, 2022 7:05 pm
Location: Reading, UK
Contact:

SNIPPET TO DISPLAY VARIABLE LOCATIONS

Post by Gelpack »

Does anyone have a bit of BBC BASIC code handy to map out the locations and names etc of all known INTEGERS, REAL's and String Variables.

So Ii' thinking something like this.

Variable Name Value or Excerpt &Start &End

A% &FFFFFFFF &NNNN &NNNN
A &FFFFFFFFFF .. ..
A$ or ?? &AAAAAAAAA... .. ..


I could probably do it myself, but why re-invent the wheel ?


Cheers
Software Engineer, Acorn BBC/Retro & Electronics Hobbyist
wiggy
Posts: 507
Joined: Fri Feb 12, 2021 12:19 pm
Contact:

Re: SNIPPET TO DISPLAY VARIABLE LOCATIONS

Post by wiggy »

Try the program in chapter three of this book (BASIC ROM User Guide, by Mark Plumbley)
viewtopic.php?t=13861

It's probably at least half-way there, anyhow. The book's well worth a read even if not!
User avatar
ChrisB
Posts: 546
Joined: Wed Oct 05, 2011 10:37 pm
Location: Surrey
Contact:

Re: SNIPPET TO DISPLAY VARIABLE LOCATIONS

Post by ChrisB »

If you're looking to access these from assembler then the CALL function allows you to pass variables which BASIC builds a table of the locations of. E.g.
https://bbcmic.ro/#%7B%22v%22%3A1%2C%22 ... %20'%22%7D

If you just need a list *XREF from the toolkit+ ROM lists them. Remember that variables won't be assigned until the program is run.
Castle Defender, Untitled Dungeon Game, Night Ninja, Wordle, Waffle, Acorn Island, Beebchase, Ghostbusters
User avatar
jgharston
Posts: 5319
Joined: Thu Sep 24, 2009 12:22 pm
Location: Whitby/Sheffield
Contact:

Re: SNIPPET TO DISPLAY VARIABLE LOCATIONS

Post by jgharston »

If you just need a list of variables and their values, then *VLIST on BASIC Utilities:
https://mdfs.net/Mirror/Archive/JGH/

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.45
(C) Copyright J.G.Harston 1989,2005-2024
>_
User avatar
BeebMaster
Posts: 7379
Joined: Sun Aug 02, 2009 5:59 pm
Location: Lost in the BeebVault!
Contact:

Re: SNIPPET TO DISPLAY VARIABLE LOCATIONS

Post by BeebMaster »

Also in ARM BASIC, which should run any BBC BASIC program as long as it doesn't use any 6502 assembler (and even then there is a build which replaces the ARM assembler with a 6502 assembler) there is the LVAR keyword which lists the integer variables and their current values, and all declared variables and their values, plus it lists all defined procedures and functions.

The only thing it doesn't do is give the actual memory location of variables, unless they have been declared with DIM.
Image
User avatar
Gelpack
Posts: 713
Joined: Tue Mar 01, 2022 7:05 pm
Location: Reading, UK
Contact:

Re: SNIPPET TO DISPLAY VARIABLE LOCATIONS

Post by Gelpack »

Yeah, thanks guys.

I did try it out on an emulator and it works for the beeb. But I was hoping it would work on the Agon Light, but it looks like they moved the inbuilt Integers @%-Z% so the addresses didnt work. But will have a look at later this week when I get time.

I Appreciate ALL your post related to it.
Software Engineer, Acorn BBC/Retro & Electronics Hobbyist
User avatar
jgharston
Posts: 5319
Joined: Thu Sep 24, 2009 12:22 pm
Location: Whitby/Sheffield
Contact:

Re: SNIPPET TO DISPLAY VARIABLE LOCATIONS

Post by jgharston »

Gelpack wrote: Wed Apr 17, 2024 8:45 pm I did try it out on an emulator and it works for the beeb. But I was hoping it would work on the Agon Light, but it looks like they moved the inbuilt Integers @%-Z% so the addresses didn't work. But will have a look at later this week when I get time.
Isn't the Agon Light a Z80, so anything that looks for the internal structure of 6502 BASIC is not going to work with the internal structure of Z80 BASIC.

On Z80 BASIC the integer variables are either at PAGE-&100 or at HIMEM+&200 if PAGE/HIMEM haven't been moved. The simplest check to find out which immediately after a program starts is IF !(PAGE-&100)=@% THEN intvars are at PAGE-&100 ELSE IF !(HIMEM+&200)=@% THEN intvars are at HIMEM+&200.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.45
(C) Copyright J.G.Harston 1989,2005-2024
>_
User avatar
Gelpack
Posts: 713
Joined: Tue Mar 01, 2022 7:05 pm
Location: Reading, UK
Contact:

Re: SNIPPET TO DISPLAY VARIABLE LOCATIONS

Post by Gelpack »

jgharston wrote: Thu Apr 18, 2024 1:40 am On Z80 BASIC the integer variables are either at PAGE-&100 or at HIMEM+&200 if PAGE/HIMEM haven't been moved.
Yes you are right. The Statics are not & their original position.

I have gotten around the issue now. But thank you for the reply :D
Software Engineer, Acorn BBC/Retro & Electronics Hobbyist
User avatar
jgharston
Posts: 5319
Joined: Thu Sep 24, 2009 12:22 pm
Location: Whitby/Sheffield
Contact:

Re: SNIPPET TO DISPLAY VARIABLE LOCATIONS

Post by jgharston »

Gelpack wrote: Fri Apr 19, 2024 7:41 pm
jgharston wrote: Thu Apr 18, 2024 1:40 am On Z80 BASIC the integer variables are either at PAGE-&100 or at HIMEM+&200 if PAGE/HIMEM haven't been moved.
Yes you are right. The Statics are not & their original position.
They *are* in their original postsion - for a Z80.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.45
(C) Copyright J.G.Harston 1989,2005-2024
>_
User avatar
Gelpack
Posts: 713
Joined: Tue Mar 01, 2022 7:05 pm
Location: Reading, UK
Contact:

Re: SNIPPET TO DISPLAY VARIABLE LOCATIONS

Post by Gelpack »

jgharston wrote: Fri Apr 19, 2024 9:55 pm
Gelpack wrote: Fri Apr 19, 2024 7:41 pm
jgharston wrote: Thu Apr 18, 2024 1:40 am On Z80 BASIC the integer variables are either at PAGE-&100 or at HIMEM+&200 if PAGE/HIMEM haven't been moved.
Yes you are right. The Statics are not & their original position.
They *are* in their original postsion - for a Z80.
Correct they are for the z80, when I said original, I mean the old 'Original' location for the BEEB.

I'm fine with this now, so no more dialogue needed.
Software Engineer, Acorn BBC/Retro & Electronics Hobbyist
Post Reply

Return to “8-bit acorn software: other”