A peculiar behaviour

Basic and Machine Language

Moderator: Moderators

Post Reply
Commodorianen
Vic 20 Drifter
Posts: 22
Joined: Fri Jun 02, 2017 11:56 am
Location: Sweden

A peculiar behaviour

Post 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
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Re: A peculiar behaviour

Post 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.
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
Commodorianen
Vic 20 Drifter
Posts: 22
Joined: Fri Jun 02, 2017 11:56 am
Location: Sweden

Re: A peculiar behaviour

Post 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.
User avatar
GreyGhost
Vic 20 Nerd
Posts: 525
Joined: Wed Oct 05, 2005 11:10 pm

Re: A peculiar behaviour

Post by GreyGhost »

Are you sure? It almost seems like the start of BASIC has been moved to 7680.
Rob
Commodorianen
Vic 20 Drifter
Posts: 22
Joined: Fri Jun 02, 2017 11:56 am
Location: Sweden

Re: A peculiar behaviour

Post 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.
Post Reply