SamCoVT / TaliForth2

A Subroutine Threaded Code (STC) ANSI-like Forth for the 65c02
Other
29 stars 5 forks source link

Rewrite I/O redirection words used to test ED #58

Closed SamCoVT closed 5 months ago

SamCoVT commented 5 months ago

The test suite saves tmp1 in the I/O redirection word because it is modified by at least one of the forth words used in that word. The solution is to completely rewrite that word in assembly to eliminate the use of tmp1.

This needs to wait for PR #54 as it will replace the band-aid there with a complete solution.

SamCoVT commented 5 months ago

+! is the culprit using tmp1, so just that word needs to be rewritten in assembly. Tali doesn't use the upper half of zero page, so we'll just use a location there during the tests.

SamCoVT commented 5 months ago

While +! can't be used because it uses a tmp variable, @, +1, and ! are fine to use, so I just rewrote in Forth using those words.

I did write a fully assembly version first - shoutout to @patricksurry for adding the calculated branch addresses to the disassembler because I had to count bytes to determine a forward branch and it was nice to use see on the resulting word and verify the branch went exactly where I wanted it to.

I ultimately decided to do this mostly in Forth, as it will be easier for others to understand and modify if ever needed.

patricksurry commented 5 months ago

Excellent.