Page 1 of 1

A peculiar behaviour

Posted: Tue Aug 01, 2017 8:18 am
by Commodorianen
I just got a new VIC-20. I found that the sine curve and circle examples in the VIC-20 Programmer's Reference Guide displayed some garbage in the lower right part of the graphics area. I managed to isolate the issue to the following program where line 10 prints the value 147. At first, I thought there was something wrong with my new VIC-20 but then I tried the same little program with my old VIC-20 (where disk drive connection doesn't work) and it gave the same result so apparently it is not an error with my new VIC-20.

1 REM RUN THIS PROGRAM WITH UNEXPANDED VIC-20
5 POKE7679,0:REM SET HIGHEST POSITION IN BASIC RAM AREA TO 0
7 PRINTCHR$(147):REM CLEAR SCREEN
10 PRINTPEEK(7679):REM I WOULD EXPECT THIS TO PRINT 0 BUT IT PRINTS 147

Re: A peculiar behaviour

Posted: Tue Aug 01, 2017 9:49 am
by Boray
The basic interpreter stores variables at the end of the basic memory I think. When using chr$, a temporary variable is probably made and stored there by the interpreter. Try to change chr$(147) to another value and you will see. Works exactly the same on the c64.

Re: A peculiar behaviour

Posted: Tue Aug 01, 2017 2:06 pm
by Commodorianen
Boray wrote:The basic interpreter stores variables at the end of the basic memory I think. When using chr$, a temporary variable is probably made and stored there by the interpreter. Try to change chr$(147) to another value and you will see. Works exactly the same on the c64.
Yes, I think you're right. String storage starts at the end of BASIC memory and goes downward so probably CHR$(147) is interpreted as a string that is put at the end of BASIC memory. I guess you would need to lower the end of BASIC memory to be able to write to 7679 without it being overwritten by BASIC.

Re: A peculiar behaviour

Posted: Wed Aug 02, 2017 5:10 am
by GreyGhost
Are you sure? It almost seems like the start of BASIC has been moved to 7680.

Re: A peculiar behaviour

Posted: Wed Aug 02, 2017 6:23 am
by Commodorianen
GreyGhost wrote:Are you sure? It almost seems like the start of BASIC has been moved to 7680.
No, I haven't changed the start of BASIC when running my short code example.