Silly Questions
Re: Silly Questions
Thank you XavSnap, it was the missing "then".
Our music sent up to God.
Partituræ Immortales | Ghost Label records | Spotify Playlist Curators | Artists' Database
Partituræ Immortales | Ghost Label records | Spotify Playlist Curators | Artists' Database
Re: Silly Questions
When we execute "run" in basic, where does it jump to? At which memory location the "run" command starts at? It's always the same address, isn't it?
Our music sent up to God.
Partituræ Immortales | Ghost Label records | Spotify Playlist Curators | Artists' Database
Partituræ Immortales | Ghost Label records | Spotify Playlist Curators | Artists' Database
- 1024MAK
- Posts: 5171
- Joined: Mon Sep 26, 2011 10:56 am
- Location: Looking forward to summer in Somerset, UK...
Re: Silly Questions
RUN with no parameters always starts executing from the first line of the program. The address in memory is 16509.
In some BASICs, like the BASIC in a ZX81, a line number can be specified:
RUN 100
This starts execution of the program starting at line 100.
In ZX81 BASIC, if line 100 does not exist, it’s the next line after where execution starts.
Mark
In some BASICs, like the BASIC in a ZX81, a line number can be specified:
RUN 100
This starts execution of the program starting at line 100.
In ZX81 BASIC, if line 100 does not exist, it’s the next line after where execution starts.
Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Amp
Standby alert
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer being good this year.
ZX81 Chip Pin-outs
ZX81 Video Transistor Amp
Standby alert
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer being good this year.
Re: Silly Questions
ok then. So...
We make a "new" program and we type in basic
10 CLS
which is in assembly
call $0a02
which is in machine language
cd 2a 0a
which is in decimal
205 42 10
So PRINT PEEK 16509 should return 205
PRINT PEEK 16510 should return 42
and PRINT PEEK 16511 should return 10.
And yet, PRINT PEEK 16509 returns 0
PRINT PEEK 16510 returns 10
and PRINT PEEK 16511 returns 2.
What am I missing here.
We make a "new" program and we type in basic
10 CLS
which is in assembly
call $0a02
which is in machine language
cd 2a 0a
which is in decimal
205 42 10
So PRINT PEEK 16509 should return 205
PRINT PEEK 16510 should return 42
and PRINT PEEK 16511 should return 10.
And yet, PRINT PEEK 16509 returns 0
PRINT PEEK 16510 returns 10
and PRINT PEEK 16511 returns 2.
What am I missing here.
Our music sent up to God.
Partituræ Immortales | Ghost Label records | Spotify Playlist Curators | Artists' Database
Partituræ Immortales | Ghost Label records | Spotify Playlist Curators | Artists' Database
Re: Silly Questions
BASIC is interpreted on-the-fly, not compiled, so you won’t ever see the actual assembly call in the listing.
For more details look at chapter 27 in the ZX81 manual
For more details look at chapter 27 in the ZX81 manual
Re: Silly Questions
Not the assembly but I will see the machine code instructions.
When you type "list" the program gets from somewhere and lists the code. Where from ?
When you type "list" the program gets from somewhere and lists the code. Where from ?
Our music sent up to God.
Partituræ Immortales | Ghost Label records | Spotify Playlist Curators | Artists' Database
Partituræ Immortales | Ghost Label records | Spotify Playlist Curators | Artists' Database
Re: Silly Questions
No, you won’t. LIST will show the BASIC program as it is in memory. For example, the first two bytes you give in your example - 0, 10 - is the line number “10”. The machine code instructions are never stored anywhere, the BASIC is interpreted line by-line as the program is ran. This is completely different to a compiler.
Re: Silly Questions
Seem to be a CHAT GPT tread ! (LLM, a CrayonLike tread!)
Don't do that....Don't do that....
ZX81 BASIC is based on tokens !
Line 10And yet, PRINT PEEK 16509 returns 0
PRINT PEEK 16510 returns 10
BASIC len string...and PRINT PEEK 16511 returns 2.
Zx BASIC is a "script" to the BASIC ROM MONITOR.
Don't try to read a BASIC code like an ASM compiled program.
If you had to compile it, use MCODER or MGT compiler.
Last edited by XavSnap on Fri Mar 24, 2023 12:36 am, edited 1 time in total.
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Re: Silly Questions
This is exactly the same mistake I made 40 odd years ago thinking the machine code could just be magically pointed to in some kind of location, not realising that as you say it is interpreted line at a time rather than compiled and stored.bobs wrote: ↑Wed Mar 22, 2023 12:41 pm No, you won’t. LIST will show the BASIC program as it is in memory. For example, the first two bytes you give in your example - 0, 10 - is the line number “10”. The machine code instructions are never stored anywhere, the BASIC is interpreted line by-line as the program is ran. This is completely different to a compiler.
- 1024MAK
- Posts: 5171
- Joined: Mon Sep 26, 2011 10:56 am
- Location: Looking forward to summer in Somerset, UK...
Re: Silly Questions
The BASIC interpreter takes each command one at a time, along with it’s parameters. It then works out what class of command it is. If a numeric expression is found, BASIC’s internal calculator routine is used to evaluate the expression. The result is then passed to the part of the ROM that actually carries out the command.
In order to fit as much functionality in only 8K bytes of ROM, the ROM code is designed to be space efficient. Hence the way that the ROM code works, is rather convoluted.
At no point will you see any machine code stored in RAM during the execution of a purely BASIC program.
Mark
In order to fit as much functionality in only 8K bytes of ROM, the ROM code is designed to be space efficient. Hence the way that the ROM code works, is rather convoluted.
At no point will you see any machine code stored in RAM during the execution of a purely BASIC program.
Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Amp
Standby alert
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer being good this year.
ZX81 Chip Pin-outs
ZX81 Video Transistor Amp
Standby alert
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Looking forward to summer being good this year.