A peculiar behaviour

Basic and Machine Language

Moderator: Moderators

Commodorianen
Vic 20 Newbie
Posts: 9
Joined: Fri Jun 02, 2017 11:56 am
Location: Sweden

A peculiar behaviour

Postby Commodorianen » Tue Aug 01, 2017 8:18 am

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

User avatar
Boray
Musical Smurf
Posts: 4026
Joined: Mon May 03, 2004 10:47 am

Re: A peculiar behaviour

Postby Boray » Tue Aug 01, 2017 9:49 am

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 Newbie
Posts: 9
Joined: Fri Jun 02, 2017 11:56 am
Location: Sweden

Re: A peculiar behaviour

Postby Commodorianen » Tue Aug 01, 2017 2:06 pm

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: 515
Joined: Wed Oct 05, 2005 11:10 pm

Re: A peculiar behaviour

Postby GreyGhost » Wed Aug 02, 2017 5:10 am

Are you sure? It almost seems like the start of BASIC has been moved to 7680.
Rob

Commodorianen
Vic 20 Newbie
Posts: 9
Joined: Fri Jun 02, 2017 11:56 am
Location: Sweden

Re: A peculiar behaviour

Postby Commodorianen » Wed Aug 02, 2017 6:23 am

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.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 3 guests