6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Nov 24, 2024 2:18 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Mon Jan 04, 2021 4:57 pm 
Offline

Joined: Sun May 13, 2018 5:49 pm
Posts: 255
I'm actually working on file support and am currently fiddling with SOURCE-ID, but I noticed something about BLK. The ANS-2012 standard is clear that QUIT needs to set SOURCE-ID to zero to reset back to the regular user input device, but it doesn't mention BLK anywhere. My understanding is that BLK is checked first, before SOURCE-ID is consulted, to see if the input source is a block. That would seem to indicate that QUIT should set BLK to zero.

I did a quick test on TaliForth2 to generate an error, and it does not set BLK back to zero on an error in a block.
Code:
blk  ? 0  ok
1 load Interpreting a compile-only word
blk ? 1  ok
The same kind of test on gforth seems to show that gforth does set BLK back to zero, but gforth also has exception handling (meaning that it might not head all the way to QUIT).
Code:
blk ? 0  ok
4 load
* a block*:4: Undefined word
>>>asdfhi<<<
blk ? 0  ok
I understand that blocks are kind of left-overs from a previous era, but I find them very useful for accessing I2C flash memories so I would like to support them. Should I modify QUIT to store a 0 in BLK (or is there any reason not to)?


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 04, 2021 7:20 pm 
Offline

Joined: Sun Apr 26, 2020 3:08 am
Posts: 357
SamCoVT wrote:
I understand that blocks are kind of left-overs from a previous era, but I find them very useful for accessing I2C flash memories so I would like to support them. Should I modify QUIT to store a 0 in BLK (or is there any reason not to)?

I did a disassembly of a couple of different Forths and the only word that might go awry if BLK <> 0 is ?LOADING. And ?LOADING is only used in the word "-->". If an error is in the first block, then "-->" would not get encountered, but if the BLOCK being LOAD'd is error free and the word "-->" is encountered, the calculation to get the next screen block may be off.

I am not willing to break my version of QUIT to trouble shoot this, so this is just a theory. But you can test this by causing an error so BLK <> 0, then try LOAD'ing a screen that uses "-->" at the end, where the screen being LOAD'd does not have any errors.


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 04, 2021 9:37 pm 
Offline

Joined: Fri May 05, 2017 9:27 pm
Posts: 895
SamCoVT wrote:
I'm actually working on file support and am currently fiddling with SOURCE-ID, but I noticed something about BLK. The ANS-2012 standard is clear that QUIT needs to set SOURCE-ID to zero to reset back to the regular user input device, but it doesn't mention BLK anywhere. My understanding is that BLK is checked first, before SOURCE-ID is consulted, to see if the input source is a block. That would seem to indicate that QUIT should set BLK to zero.


First I should point out that I'm no expert in AnsForth since I don't use the Ansi Standard. Having said that, the Ansi Standard seems to indicate that a block should be loaded whenever BLK is not zero. The Ansi Standard also states that QUIT " ... make the user input device the input source ... ", so QUIT , or something it calls, should set BLK to zero.


Top
 Profile  
Reply with quote  
PostPosted: Tue Jan 05, 2021 10:38 pm 
Offline

Joined: Sun May 13, 2018 5:49 pm
Posts: 255
JimBoyd wrote:
First I should point out that I'm no expert in AnsForth since I don't use the Ansi Standard. Having said that, the Ansi Standard seems to indicate that a block should be loaded whenever BLK is not zero. The Ansi Standard also states that QUIT " ... make the user input device the input source ... ", so QUIT , or something it calls, should set BLK to zero.

This was my line of thinking as well. It's just odd that the standard is very specific about SOURCE-ID but doesn't mention BLK directly. It looks like SOURCE-ID was added in DPANS94 (so you can tell the difference between EVALUATEing a string, file input, and normal input). You're supposed to check BLK first, as a historical artifact from older forths, and then use SOURCE-ID if BLK is 0. Because of that, I think I need to have QUIT put a 0 in BLK just so that SOURCE-ID will be checked properly (only when not loading blocks) in other places.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 20 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: