Hi... I believe I have figured out how the EXEC statement works .... BUT :
Ummm
The example in DOCs gives us an example where it tokenize's it... But I show you what I get ~!*
The 2 PEEKS look like a "Little Indian" address being poked....
(I'm not too sure, If I should understand what this does? But....
The example in DOC's is this :
But it does not tokenize it....
I'm still trying to figure out what i'm doing wrong.... or its it my definition of thats wrong... but what that says in docs does not work for me...
Now; I have used BASLOAD... so I know what "Tokenize" is.. is it my definition thats wrong ?
Just trying to learn and understand from examples lol....
Ummm A .BAS file is similar to a .BASL file for BASLOAD isn't it ???
Ummm.... I'm still Brain-Farting over Voidstar's example.....viewtopic.php?t=7998
But I want to understand this first...
EXEC Statement
Re: EXEC Statement
So I think I might answer my own question here...
line 20 Null terminates it, "IF" it ever gets to the end of the bank....
And "Tokenize"... just runs it if it "was" a BASIC program... but just with the commands ..?
line 20 Null terminates it, "IF" it ever gets to the end of the bank....
And "Tokenize"... just runs it if it "was" a BASIC program... but just with the commands ..?
Re: EXEC Statement
So.... by "plain text" that is generally meaning "standard ASCII." But for example, suppose your code has the PI symbol in it, which CBM supports. I think that's $FF (or maybe $DE?), or in any case it's different than the IBM extended ASCII PI of 227. So really in this context, "plain text" is more the CBM character set convention (which just luckily has a lot of overlap with ASCII, just with a few exceptions that typically don't get in the way of things-- until you want to do CBM-style things like moving the cursor around or changing text color using PETSCII codes, or use the PI symbol shortcut).
And you're right, the tech ref here might be a tad incomplete. BLOAD is just going to load that "plain text" straight into BANK'd RAM (each bank being 8KB, it will use multiple banks as necessary). BLOAD itself doesn't know or care if it is plain text, it's just a raw data sequence to it. It also does say this "across bank" behavior is only when a high-ram address is used (so if you know it is a small file, some other address could be used- but if it's a "larger than 8KB" file, then $a000 is good unless you're using bank RAM for something else at the time).
So in the case of using high RAM, I *think* BLOAD is going to return the address offset into the last bank used (not a total linear offset) -- with 8KB bank, that offset can certainly be longer than 255 bytes, so yes two bytes is needed. The BANK will be set to where BLOAD left off (I don't think it auto-returns to the bank you were on when you invoked BLOAD), though generally (unless you have a ton of comments) the plain-text BASIC won't be over 8KB. That means the example of writing the end-null should work as intended. For purposes of "tokenizing" it is always going to look for that ending null (0x00, $00). If you remove that line 20, it could still coincidentally still work by tokenizing some trash and running into some other null.
I've not looked through the ROM code behind EXEC, but effectively: when your program ends, I think it checks some flag on if any content was buffered by EXEC. If so, that triggers processing the address used by EXEC to start "typing the plain text content" (maybe piping it to the keyboard input, which is why you SEE the code being typed, similar to how it would appear if you had pasted the code using the emulator). It is during that moment that the code is being tokenized (At $801, or maybe $80D?). It's not so much EXEC itself doing the tokenizing, but it is inducing the tokenization by virtue of "forcing the typing of buffered plain-text content." This is also why "piping to null" might not work at hiding this text (TBD based on Mark's notes).
So the plain text "FOR I = 1 TO BLAH" stored somewhere around $A000, then gets tokenized into whatever BASIC's code for FOR is, and the other operands of that instruction (over into the $801 region that BASIC uses to hold tokenized code). That tokenization doesn't happen immediately during the call to EXEC - it happens "after the fact" when the program halts (from STOP or END or running out of line numbers).
EXEC keeps going until it runs into a $00 in RAM, since (luckily) $00 is not a valid plain-text entry into BASIC.
There's no real "official" standard of filename conventions. A tokenized BASIC could be .BAS or .PRG
On the SD card I tried to have the following convention:
.BASL.TXT plain-text BASIC without line numbers, intended for BASLOAD (I use .TXT since that makes it easier to just double-click and start editing it under Windows, since .txt is associated with Notepad by default; but some folks will just use .BASL)
.BAS tokenized CBM BASIC
.PRG BASIC SYS header, but otherwise a 6502 compatible instruction sequence
Hopefully I haven't grossly misspoken here, but that's my understanding of things so far.
And you're right, the tech ref here might be a tad incomplete. BLOAD is just going to load that "plain text" straight into BANK'd RAM (each bank being 8KB, it will use multiple banks as necessary). BLOAD itself doesn't know or care if it is plain text, it's just a raw data sequence to it. It also does say this "across bank" behavior is only when a high-ram address is used (so if you know it is a small file, some other address could be used- but if it's a "larger than 8KB" file, then $a000 is good unless you're using bank RAM for something else at the time).
So in the case of using high RAM, I *think* BLOAD is going to return the address offset into the last bank used (not a total linear offset) -- with 8KB bank, that offset can certainly be longer than 255 bytes, so yes two bytes is needed. The BANK will be set to where BLOAD left off (I don't think it auto-returns to the bank you were on when you invoked BLOAD), though generally (unless you have a ton of comments) the plain-text BASIC won't be over 8KB. That means the example of writing the end-null should work as intended. For purposes of "tokenizing" it is always going to look for that ending null (0x00, $00). If you remove that line 20, it could still coincidentally still work by tokenizing some trash and running into some other null.
I've not looked through the ROM code behind EXEC, but effectively: when your program ends, I think it checks some flag on if any content was buffered by EXEC. If so, that triggers processing the address used by EXEC to start "typing the plain text content" (maybe piping it to the keyboard input, which is why you SEE the code being typed, similar to how it would appear if you had pasted the code using the emulator). It is during that moment that the code is being tokenized (At $801, or maybe $80D?). It's not so much EXEC itself doing the tokenizing, but it is inducing the tokenization by virtue of "forcing the typing of buffered plain-text content." This is also why "piping to null" might not work at hiding this text (TBD based on Mark's notes).
So the plain text "FOR I = 1 TO BLAH" stored somewhere around $A000, then gets tokenized into whatever BASIC's code for FOR is, and the other operands of that instruction (over into the $801 region that BASIC uses to hold tokenized code). That tokenization doesn't happen immediately during the call to EXEC - it happens "after the fact" when the program halts (from STOP or END or running out of line numbers).
EXEC keeps going until it runs into a $00 in RAM, since (luckily) $00 is not a valid plain-text entry into BASIC.
There's no real "official" standard of filename conventions. A tokenized BASIC could be .BAS or .PRG
On the SD card I tried to have the following convention:
.BASL.TXT plain-text BASIC without line numbers, intended for BASLOAD (I use .TXT since that makes it easier to just double-click and start editing it under Windows, since .txt is associated with Notepad by default; but some folks will just use .BASL)
.BAS tokenized CBM BASIC
.PRG BASIC SYS header, but otherwise a 6502 compatible instruction sequence
Hopefully I haven't grossly misspoken here, but that's my understanding of things so far.
- ahenry3068
- Posts: 1134
- Joined: Tue Apr 04, 2023 9:57 pm
Re: EXEC Statement
voidstar wrote: ↑Tue Oct 15, 2024 3:35 pm So.... by "plain text" that is generally meaning "standard ASCII." But for example, suppose your code has the PI symbol in it, which CBM supports. I think that's $FF (or maybe $DE?), or in any case it's different than the IBM extended ASCII PI of 227. So really in this context, "plain text" is more the CBM character set convention (which just luckily has a lot of overlap with ASCII, just with a few exceptions that typically don't get in the way of things-- until you want to do CBM-style things like moving the cursor around or changing text color using PETSCII codes, or use the PI symbol shortcut).
And you're right, the tech ref here might be a tad incomplete. BLOAD is just going to load that "plain text" straight into BANK'd RAM (each bank being 8KB, it will use multiple banks as necessary). BLOAD itself doesn't know or care if it is plain text, it's just a raw data sequence to it. It also does say this "across bank" behavior is only when a high-ram address is used (so if you know it is a small file, some other address could be used- but if it's a "larger than 8KB" file, then $a000 is good unless you're using bank RAM for something else at the time).
So in the case of using high RAM, I *think* BLOAD is going to return the address offset into the last bank used (not a total linear offset) -- with 8KB bank, that offset can certainly be longer than 255 bytes, so yes two bytes is needed. The BANK will be set to where BLOAD left off (I don't think it auto-returns to the bank you were on when you invoked BLOAD), though generally (unless you have a ton of comments) the plain-text BASIC won't be over 8KB. That means the example of writing the end-null should work as intended. For purposes of "tokenizing" it is always going to look for that ending null (0x00, $00). If you remove that line 20, it could still coincidentally still work by tokenizing some trash and running into some other null.
I've not looked through the ROM code behind EXEC, but effectively: when your program ends, I think it checks some flag on if any content was buffered by EXEC. If so, that triggers processing the address used by EXEC to start "typing the plain text content" (maybe piping it to the keyboard input, which is why you SEE the code being typed, similar to how it would appear if you had pasted the code using the emulator). It is during that moment that the code is being tokenized (At $801, or maybe $80D?). It's not so much EXEC itself doing the tokenizing, but it is inducing the tokenization by virtue of "forcing the typing of buffered plain-text content." This is also why "piping to null" might not work at hiding this text (TBD based on Mark's notes).
So the plain text "FOR I = 1 TO BLAH" stored somewhere around $A000, then gets tokenized into whatever BASIC's code for FOR is, and the other operands of that instruction (over into the $801 region that BASIC uses to hold tokenized code). That tokenization doesn't happen immediately during the call to EXEC - it happens "after the fact" when the program halts (from STOP or END or running out of line numbers).
EXEC keeps going until it runs into a $00 in RAM, since (luckily) $00 is not a valid plain-text entry into BASIC.
There's no real "official" standard of filename conventions. A tokenized BASIC could be .BAS or .PRG
On the SD card I tried to have the following convention:
.BASL.TXT plain-text BASIC without line numbers, intended for BASLOAD (I use .TXT since that makes it easier to just double-click and start editing it under Windows, since .txt is associated with Notepad by default; but some folks will just use .BASL)
.BAS tokenized CBM BASIC
.PRG BASIC SYS header, but otherwise a 6502 compatible instruction sequence
Hopefully I haven't grossly misspoken here, but that's my understanding of things so far.
You've got it pretty correct here. And after BLOAD bank is set to the "ending bank" not restored.
Two points. EXEC content can have both line numbered and "Immediate content" (Just like when your typing). That means you can do "Immediate" LOCATE commands to keep from scrolling off screen. I find the simplest way to hide output is the simple expedient of COLOR 6,6 Blue text on a Blue Background is pretty invisible....
Re: EXEC Statement
OK I've a better understanding how this works.... It's a pretty neat feature...
Line 20 is used to find the end null... although I haven't found $30E or $30D to know what they do...
(I do know its in----> KERNAL and BASIC variables, vectors) I don't know if I should have to know...to only backwork that out.
I know I can use a list of Basic statements, or a numbered BASIC program; in the "FILE.BAS"
and your example of "CAVEMADNESS" is making more sense now~
And your right.. I could just about use any 3 characters at the end of a file & it would work...
So I do try & use .PRG .BAS .BASL.txt for the correct use.... and it can make life easier.
ohh & COLOR 6,6 Blue text on a Blue Background Will work too !
Thanks for your reply Voidstar & ahenry, for helping.
Best regards
Shaun
Re: EXEC Statement
$30E/$30D are described in the BASIC reference for the SYS call. They are addresses used as a pass-thru of CPU register values during SYS calls. Sometimes they are inputs set before the SYS, or sometimes they are outputs/results of a SYS call.
In this case we're calling a utility (BLOAD) and want the two-byte address result (as described in the BLOAD notes).
https://github.com/X16Community/x16-doc ... C.md#bload
You have to use or copy those values before doing another SYS call that might stomp over them.
The file extensions are all just conventions for us humans They aren't required. There is a file AUTOBOOT.X16, and I've wondered if maybe we should have continued to use the .X16 extension for "X16-BASIC programs" as a convention (as opposed to VIC-20, C64, or other BASIC's). Since otherwise some don't realize you can LOAD that .X16 file and LIST it, like a regular tokenized BASIC program.
In this case we're calling a utility (BLOAD) and want the two-byte address result (as described in the BLOAD notes).
https://github.com/X16Community/x16-doc ... C.md#bload
You have to use or copy those values before doing another SYS call that might stomp over them.
The file extensions are all just conventions for us humans They aren't required. There is a file AUTOBOOT.X16, and I've wondered if maybe we should have continued to use the .X16 extension for "X16-BASIC programs" as a convention (as opposed to VIC-20, C64, or other BASIC's). Since otherwise some don't realize you can LOAD that .X16 file and LIST it, like a regular tokenized BASIC program.
Re: EXEC Statement
I would have come across those addresses...($030C,$030D,$030E,$030E) (never realized)
I have VS Code & Retroassembler installed...
Ive made a few very small programs that would use like... BSOUT (FFD2) and the such...
I have Training wheels on with assembly lol... and will have to find time playing with the kernal API functions...
I can follow small examples in assembly, and try and to make sense of it..
I did want to learn assembly as a kid, with a C64.. But without today's tech, with just the C64, and being just a kid, having limited resources... I never got there...
Best Regards
Shaun
I have VS Code & Retroassembler installed...
Ive made a few very small programs that would use like... BSOUT (FFD2) and the such...
I have Training wheels on with assembly lol... and will have to find time playing with the kernal API functions...
I can follow small examples in assembly, and try and to make sense of it..
I did want to learn assembly as a kid, with a C64.. But without today's tech, with just the C64, and being just a kid, having limited resources... I never got there...
Best Regards
Shaun