ROM location clarifications needed for C65E

Basic and Machine Language

Moderator: Moderators

Post Reply
User avatar
Jeff-20
Denial Founder
Posts: 5759
Joined: Wed Dec 31, 1969 6:00 pm

ROM location clarifications needed for C65E

Post by Jeff-20 »

I was looking at the pinned thread above (ROM calls) compared to from what I saw in printed manuals of the time.

C65E (50782) is the routine for BASIC CLR in one source, but the call is listed as C659 in the thread. What's the difference? Entry point?
High Scores, Links, and Jeff's Basic Games page.
User avatar
srowe
Vic 20 Scientist
Posts: 1340
Joined: Mon Jun 16, 2014 3:19 pm

Re: ROM location clarifications needed for C65E

Post by srowe »

$C659 calls a routine that resets TXTPTR, the address within the CHRGET routine. $C659 in on the execution path of NEW, $C65E is the entrypoint for the actual CLR command.
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: ROM location clarifications needed for C65E

Post by Mike »

I also always refer to $C659 as "CLR, reset TXTPTR", and carlsson also writes in the OP of the pinned thread: "$C659: Reset execution to start of program and perform CLR (set pointers to variables)." which is correctly explained and which is strictly different from just doing a CLR by calling $C65E.

The three calls JSR $C533/JSR $C659/JMP $C7AE are a standard idiom for starting a BASIC program from machine code, for example when it has been loaded into memory by said machine code. It is still important to set the start of variables (a.k.a. "end of program") in $2D/$2E beforehand (STX $2D and STY $2E directly after KERNAL load with JSR $FFD5 do the job). JSR $C533 re-links the BASIC program (which is necessary in case it was saved from another address than it is loaded to), JSR $C659 performs necessary actions to init program execution and JMP $C7AE re-enters the main interpreter loop.

The entry point of RUN at $C871 cannot be used for aforementioned purpose at it assumes it has already been called from within running BASIC code (which is the case even when executed in direct mode!) and it possibly tries to read a line number from the following BASIC text under essentially undefined circumstances - which might result in a ?SYNTAX ERROR instead of (re-)starting the BASIC program.
User avatar
Jeff-20
Denial Founder
Posts: 5759
Joined: Wed Dec 31, 1969 6:00 pm

Re: ROM location clarifications needed for C65E

Post by Jeff-20 »

Great clarification! Thanks, srowe and Mike!
High Scores, Links, and Jeff's Basic Games page.
Post Reply