BASIC input buffer $0200 - $0258

Basic and Machine Language

Moderator: Moderators

Post Reply
Victim_RLSH
Vic 20 Drifter
Posts: 34
Joined: Thu Jul 15, 2021 10:50 pm
Location: Rapid City, SD
Occupation: Machine Shop Lackey

BASIC input buffer $0200 - $0258

Post by Victim_RLSH »

This seems a fairly decent amount of space, could I use this in an ML program that was started with a BASIC stub without screwing anything up?
Works in Progress: Gravity Ball, a breakout variant in assembly for the unexpanded vic-20
User avatar
srowe
Vic 20 Scientist
Posts: 1340
Joined: Mon Jun 16, 2014 3:19 pm

Re: BASIC input buffer $0200 - $0258

Post by srowe »

As long as you don't call any BASIC routines related to input from your program you should be fine.
User avatar
Mike
Herr VC
Posts: 4842
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: BASIC input buffer $0200 - $0258

Post by Mike »

Yes, the buffer is fair game as long as your ML program runs and you started it with a BASIC stub + RUN. Note though, that if you started the ML program with a SYS in direct mode, TXTPTR still points into the input buffer and this might lead to ?SYNTAX errors or similar upon return from the ML program as the interpreter then continues behind the SYS command.
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: BASIC input buffer $0200 - $0258

Post by chysn »

If you store machine code in BASIC memory and use the null-terminated string print routine ($cb1e) to print a string in Page 2, your code in BASIC memory may get overwritten by the string you've printed (see VIC-20 disassembly at http://www.fox-ts.co.uk/shared/vic20ker ... l#LAB_D4B5). I'm passing this along because it drove me mad for a while before I tracked it down.
VIC-20 Projects: wAx Assembler, TRBo: Turtle RescueBot, Helix Colony, Sub Med, Trolley Problem, Dungeon of Dance, ZEPTOPOLIS, MIDI KERNAL, The Archivist, Ed for Prophet-5

WIP: MIDIcast BASIC extension

he/him/his
Victim_RLSH
Vic 20 Drifter
Posts: 34
Joined: Thu Jul 15, 2021 10:50 pm
Location: Rapid City, SD
Occupation: Machine Shop Lackey

Re: BASIC input buffer $0200 - $0258

Post by Victim_RLSH »

Thanks for the warning, I am actually doing just that!
Works in Progress: Gravity Ball, a breakout variant in assembly for the unexpanded vic-20
User avatar
Mike
Herr VC
Posts: 4842
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: BASIC input buffer $0200 - $0258

Post by Mike »

My main concern would be that if the program ever was to return to direct mode (either normally or in case of an error), the BASIC input line will thrash whatever is in that buffer, making debugging (with simple PRINTPEEK(...) statements, for example) unnecessarily difficult.

Under normal circumstances I'd regard that buffer only as a last resort measure, and only in the case the program does not need to hold permanent state there.

My own ML monitor happens to use that buffer for its own command line, but the line is shortened to 64 characters. That keeps 25 bytes of the buffer as workspace for the currently executed monitor command. The monitor does not call any routines in the BASIC interpreter (except on exit to BASIC), so the buffer is save in that regard. And with the first two points noted above, I think the use of $0200..$0258 by my monitor is unlikely to tread on anyone else's shoes. :mrgreen:
Post Reply