Re: Weird BASIC problem

From: (wrong string) äkelä <marko.makela_at_iki.fi>
Date: Thu, 4 Jun 2026 16:03:35 +0300
Message-ID: <aiF3p0x00wJ-WvoZ_at_kehys.lan>
Hi Ruud,

Thu, Jun 04, 2026 at 11:08:21AM +0200, ruud_at_baltissen.org wrote:
[snip]
>Now the, IMHO, weird part. Load BOOT1 again and POKE2059,58. This 
>replaces the first zero with the colon. Type LIST and see what happens: 
>the SYS 2062 appears but also with the colon at the end. But not with 
>the nonsense. And, most important, it still runs!

I think I have an explanation for this. The BASIC interpreter should 
relocate the next-line pointers after loading a program. For example, a 
program saved on a PET or VIC-20 could have a start address of $0401, 
$1001 or $1201. When you load a program to $0801 on the C64, the links 
have to be corrected.

I assume that the code that performs this adjustments is simply looking 
for NUL bytes and then rewriting the next-line pointers. If you have a 
NUL byte somewhere in your machine code, then the 2 addresses following 
it should be corrupted, rewritten as next-line pointers in BASIC. The 
relocator should stop when it finds that the 16-bit next-line pointer 
after a NUL byte is zero.

Did you try saving the memory from the VICE machine language monitor 
after the LOAD statement and then compare it to the original file?

>But what I don't understand at all is that when I load BOOT2, I at 
>least should be able to start the ML part of the program using SYS 
>2062. I only can guess that something has been overwritten but by what 
>and where?

VICE should support memory access watchpoints. Once you have identified 
the address of one unexpectedly changing byte, you can set a watchpoint 
on it and see where exactly the offending access is taking place.  
Watchpoints are something that I use almost daily when debugging on a 
"mainstream" system. While I am not a fan of the 8080 or 8086 legacy, I 
think that Intel got one thing right with the 80386: 
https://en.wikipedia.org/wiki/X86_debug_register

With best regards,

	Marko
Received on 2026-06-04 15:00:02

Archive generated by hypermail 2.4.0.