6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu Nov 21, 2024 12:01 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Tue Jul 02, 2019 7:35 pm 
Offline

Joined: Fri May 05, 2017 9:27 pm
Posts: 895
I'd like to start this thread off with a bug and fix for an old favorite, Blazin' Forth.
The C64 has a vector for the system IRQ at address $314-$315 so software can "patch in" it's own IRQ.
Blazin' Forth uses this for sound and music words. It saves the old address in a variable named SYSIRQ. The new IRQ performs an indirect jump to the old IRQ through SYSIRQ. Blazin' Forth, like any decent ITC Forth for the C64, checks if the code field of a new name will cross a page boundary. If it will, the dictionary is padded with one byte prior to creating the header. Scott Ballantyne included the source for the system loader so someone could modify it ( after making a backup ), forget THRU, and reload the system.
Although no word will have a code field that crosses a page boundary, it is possible for part of the parameter field to cross a page boundary. In an ITC Forth, this is harmless unless the parameter field is used for an indirect jump address.
This is where the bug comes in. If the system is altered and rebuilt, there is a possibility that the one cell parameter field of SYSIRQ will cross a page boundary.
For the bug fix there is a word in Blazin' Forth, " , that will create a counted string in the PAD. It can be used to avoid this bug.
Replace
Code:
HEX
VARIABLE SYSIRQ

with this
Code:
HEX
// BUG FIX
" SYSIRQ" C@ HERE + 1+
2+ 2+         // SIZE OF LINK
              // & CODE FIELDS
0FF AND 0FF = // WILL PFA BE ON
              // PAGE BOUNDARY?
ABS ALLOT     // IF SO BUMP IT PAST
VARIABLE SYSIRQ

Note that VIEW? , the variable that determines if a view field is created, is off during the loading of the system.


Top
 Profile  
Reply with quote  
PostPosted: Sun Jul 07, 2024 8:06 pm 
Offline

Joined: Fri May 05, 2017 9:27 pm
Posts: 895

When I started this thread the intent was for it to be a place where obscure bugs in Forth implementations and the bug fixes could be mentioned. Looking back, I think the original title may have given the impression I wanted to point out Flaws in Forth the language. That is not the case and I've updated the title of this thread to reflect that. There are still Forth implementations for older computers, such as 64Forth and Blazin' Forth for the Commodore 64, still used by hobbyists.
Although the bug mentioned at the headpost seems rare, I mentioned it because back then I wanted to see if some of Blazin' Forth's utilities would work with my Forth. This bug actually bit me. The parameter field of the variable SYSIRQ straddled a page boundary. When I tried to use Blazin' Forth's sound words with my Forth, the Commodore 64 locked up due to the indirect jump bug.
The latest version of my Forth would not be affected by this bug because the first four cells of the parameter field, as well as the code field, do not straddle a page boundary; nevertheless, I still feel it is important to point out such potential bugs. Although a Forth on a CMOS 6502 (65C02) would not be affected, some of us are still using NMOS processors (or simulating them) because we are running or simulating older hardware.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 15 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: