[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Sweet 16 Info (Source next article)



All of this information comes from the manual of the Merlin Assembler
published by Southwestern Data Systems (c) 1982. I have tried to be
sure that I have entered everything exactly as it is in the manual while
correcting printing errors. If you find any other errors that might
cause trouble - especially such things as errors in the source code
listed here, It would probably be helpful to post the error to
comp.sys.apple2 so that everyone else who received this text can
benefit.

   Thanks, Sheldon


---------------------------------------------------------------------------


SWEET 16 - INTRODUCTION

by Dick Sedgewick


Sweet 16 is probably the least used and least understood seed
in the Apple ][.

In exactly the same sense that Integer and Applesoft Basics
are languages, SWEET 16 is a language. Compared to the
Basics, however, it would be classed as low level with a
strong likeness to conventional 6502 Assembly language.

To use SWEET 16, you must learn the language - and to quote
"WOZ", "The opcode list is short and uncomplicated". "WOZ"
(Steve Wozniak), of course is Mr. Apple, and the creator of
SWEET 16.

SWEET 16 is ROM based in every Apple ][ from $F689 to $F7FC.
It has it's own set of opcodes and instruction sets, and uses
the SAVE and RESTORE routines from the Apple Monitor to
preserve the 6502 registers when in use, allowing SWEET 16 to
be used as a subroutine.

It uses the first 32 locations on zero page to set up its 16
double byte registers, and is therefore not compatible with
Applesoft Basic without some additional efforts.

The original article, "SWEET 16: The 6502 Dream Machine",
first appeared in Byte Magazine, November 1977 and later in
the original "WOZ PAK". The article is included here and
again as test material to help understand the use and
implementation of SWEET 16.

Examples of the use of SWEET 16 are found in the Programmer's
Aid #1, in the Renumber, Append, and Relocate programs. The
Programmer's Aid Operating Manual contains complete source
assembly listings, indexed on page 65.

The demonstration program is written to be introductory and
simple, consisting of three parts:

     1. Integer Basic Program
     2. Machine Language Subroutine
     3. SWEET 16 Subroutine

The task of the program will be to move data. Parameters of
the move will be entered in the Integer Basic Program.

The "CALL 768" ($300) at line 120, enters a 6502 machine
language subroutine having the single purpose of entering
SWEET 16 and subsequently returning to BASIC (addresses $300,
$301, $302, and $312 respectively). The SWEET 16 subroutine
of course performs the move, and is entered at Hex locations
$303 to $311 (see listing Number 3).

After the move, the screen will display three lines of data,
each 8 bytes long, and await entry of a new set of parameters.
The three lines of data displayed on the screen are as
follows:

     Line 1: The first 8 bytes of data starting at $800, which
             is the fixed source data to be moved (in this
             case, the string A$).

     Line 2: The first 8 bytes of data starting at the hex
             address entered as the destination of the
             move (high order byte only).

     Line 3: The first 8 bytes of data starting at $0000 (the
             first four SWEET 16 registers).

The display of 8 bytes of data was chosen to simplify the
illustration of what goes on.

Integer Basic has its own way of recording the string A$.
Because the name chosen for the string "A$" is stored in 2
bytes, a total of five housekeeping bytes precede the data
entered as A$, leaving only three additional bytes available
for display. Integer Basic also adds a housekeeping byte at
the end of a string, known as the "string terminator".

Consequently, for convenience purposes of the display, and to
see the string terminator as the 8th byte, the string data
entered via the keyboard should be limited to two characters,
and will appear as the 6th and 7th bytes. Additionally,
parameters to be entered include the number of bytes to be
moved. A useful range for this demonstration would be 1-8
inclusive, but of course 1-255 will work.

Finally, the starting address of the destination of the move
must be entered. Again, for simplicity, only the high-order
byte is entered, and the program allows a choice between
Decimal 9 and high-order byte of program pointer 1, to avoid
unnecessary problems (in this demonstration enter a decimal
number between 9 and 144 for a 48K APPLE).

The 8 bytes of data displayed starting at $00 will enable one
to observe the condition of the SWEET 16 registers after a
move has been accomplished, and thereby understand how the
SWEET 16 program works.