SWEET16
From Wikipedia, the free encyclopedia
SWEET16 is an interpreted "byte-code" language invented by Steve Wozniak and implemented as part of the Integer BASIC ROM in the Apple II computer. It was created because Wozniak needed to manipulate 16-bit pointer data in his implementation of BASIC, and the Apple II was an 8-bit computer.
SWEET16 code is executed as if it were running on a (non-existent) 16-bit processor with sixteen internal 16-bit little-endian registers, named R0 through R15. Some registers have well-defined functions:
- R0 is the accumulator.
- R14 is the status register.
- R13 stores the result of all comparison operations for branch testing.
- R15 is the program counter.
The 16 virtual registers, 32 bytes in total, are located in the zero page of the Apple II's real, physical memory map (at $00-$1F). The SWEET16 interpreter itself is located from $F689 to $F7FC in the Integer BASIC ROM.
According to Wozniak, the SWEET16 implementation is a model of frugal coding, taking up only about 300 bytes in memory. SWEET16 runs about 10 times slower than the equivalent native 6502 code.
Contents |
[edit] The source code
In the very beginning of personal computing, copyrighted source codes were generally published (exception: Applesoft BASIC created by Bill Gates). Here are the first few lines of SWEET16's source code written by Wozniak. The starting address of SWEET16 is $F689 and the virtual 16-bit registers are little-endian.
********************************
* *
* APPLE-II PSEUDO MACHINE *
* INTERPRETER *
* *
* COPYRIGHT (C) 1977 *
* APPLE COMPUTER, INC *
* *
* ALL RIGHTS RESERVED *
* *
* S. WOZNIAK *
* *
********************************
* *
* TITLE: SWEET 16 INTERPRETER *
* *
********************************
R0L EQU $0
R0H EQU $1
R14H EQU $1D
R15L EQU $1E
R15H EQU $1F
SAVE EQU $FF4A
RESTORE EQU $FF3F
ORG $F689
[edit] See also
[edit] References
- Wozniak, Steve. "SWEET16: The 6502 Dream Machine". BYTE. November 1977. [1]

