[net.micro.cbm] c64 SYS stmt

miller@uiucdcs.UUCP (miller ) (01/26/84)

#N:uiucdcs:36100031:000:1027
uiucdcs!miller    Jan 26 01:05:00 1984


Well, I managed to find a little more free time, so here comes another lesson
in "things that Commodore forgot to tell us".  In the c64 "Programmer's
Reference Guide", the SYS and the USR statements are described as the method by
which we should communicate with assembly language subroutines.  In particular,
the SYS <addr> statement is described as sort of a JSR <addr> instruction.
Well it is, but it does a little bit more that isn't exactly documented, but
which may be useful to you someday.  When a SYS is performed from BASIC, the A,
X, Y, and Processor Status registers are loaded from memory locations 780, 781,
782, and 783 respectively.  Upon execution of a RTS but before control is
returned to BASIC, those four registers are stored back into the same
locations.  This is most helpful in linking BASIC with machine lang (especially
Operating System routines you want to run but can't modify to communicate in a
better fashion).
Coming soon (this weekend): FLOATING POINT on the c64!

A. Ray Miller
Univ Illinois