CBM Program Studio.

Basic and Machine Language

Moderator: Moderators

Post Reply
mysecretgarden
Vic 20 Newbie
Posts: 16
Joined: Thu Sep 18, 2008 2:10 pm

CBM Program Studio.

Post by mysecretgarden »

Hi! I've downloaded for test, the CMB Program Studio.
I've tried to compile a simple ASM program for the Vic20 (unexpanded).
The program should print an 'A' char into the screen, but don't work where is my mistake?

the version of Cbm program studio is 2.6.0.


*=$1001
LDA #$01
STA $1E00
BRK


from basic
sys 4097


Bye!!!
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Unless a custom handler has been installed in the vector of BRK (at $0316), the BRK instruction causes a warm restart of BASIC. This inits I/O and clears the screen (also your 'A' character), leaving you at the READY prompt. You should use RTS instead to return to BASIC from your ML program - and, BTW, you should also init the value for the corresponding colour RAM position. Colour RAM defaults to 1 (i.e. white), regardless of pre-set background colour.

In any case, this has nothing to do with CBM Program Studio. If anything, it's a bad idea to put ML code directly at the BASIC start, as the BASIC re-linker will choke on the non-BASIC code you load. You should use a BASIC stub instead, which also allows to run the program with RUN, without the necessity to remember the SYS address.
mysecretgarden
Vic 20 Newbie
Posts: 16
Joined: Thu Sep 18, 2008 2:10 pm

Post by mysecretgarden »

Thank you for your reply! but I have another question, there is a good locations address to locate the ML program?
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

For small ML routines, the range of 673 .. 767 is a good choice. These locations are not used in any way by BASIC.

For slightly bigger routines, the tape buffer from 828 .. 1023 is also quite usable. It's however overwritten as soon as a tape operation is done, so it's more useful for floppy users.

You can change the limits of the RAM available to the BASIC interpreter, either 55/56 ('roof', top of RAM) or 43/44 ('base', bottom of RAM). The blocked memory ranges can then be used for own code, data and graphics (but see the remark to VIC below), without any concern they might be overwritten by BASIC because of the program, variable or string storage. It's quite easy to do the first method at the start of a BASIC program, provided other pointers are also reset, like in:

Code: Select all

POKE55,0:POKE56,28:CLR
... which sets the top of RAM to 7168, exclusive. Changing the bottom of RAM is slightly more difficult, and there is no easy method to do it as soon as there's already a BASIC program loaded (even more so, when it's already running and variables have been allocated), as this would require to shift the program in memory and adjust a lot of pointers within the tokenized program text and to the variable data. Rather one uses a boot loader, which first sets the new BASIC start and then loads the main BASIC program that runs from this position.

As a rough guide, lowering the roof is mostly done on an unexpanded VIC-20 or with +3K RAM. Raising the BASIC start is usually preferable as soon as there's a +8K or a bigger RAM expansion required for the program.

When you use a BASIC stub, you're more or less free to arrange code and data as you wish. You should keep in mind though that besides the character ROM, VIC can only access the internal RAM ($0000 .. $03FF and $1000 .. $1FFF) for the text screen and user defined graphics.

For more information, please consult the VIC-20 Programmer's Reference Guide.
Post Reply