Jump to content

SWEET16

From Wikipedia, the free encyclopedia

Template:Short description {{#invoke:other uses|otheruses}} SWEET16 is an interpreted byte-code instruction set invented by Steve Wozniak and implemented as part of the Integer BASIC ROM in the Apple II computers. It was created because Wozniak needed to manipulate 16-bit pointer data, and the Apple II was an 8-bit computer.[1]

SWEET16 was not used by the core BASIC code, but was later used to implement several utilities. Notable among these was the line renumbering routine, which was included in the Programmer's Aid #1 ROM, added to later Apple II models and available for user installation on earlier examples.[2]

SWEET16 code is executed as if it were running on a 16-bit processor with sixteen internal 16-bit little-endian registers, named Template:Mono through Template:Mono. Some registers have well-defined functions:[1]

The 16 virtual registers, 32 bytes in total, are located in the zero page of the Apple II's real, physical memory map (at Template:Mono–Template:Mono), with values stored as low byte followed by high byte.[1] The SWEET16 interpreter itself is located from Template:Mono to Template:Mono 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 at about one-tenth the speed of the equivalent native 6502 code; however it shaved around 20% off the size of Integer BASIC.[3]

Operations

Register Ops Nonregister Ops
00 Template:Mono Return to 6502 mode
1n Template:Mono Constant set 01 Template:Mono Branch always
2n Template:Mono Load 02 Template:Mono Branch if No Carry
3n Template:Mono Store 03 Template:Mono Branch if Carry
4n Template:Mono Load indirect 04 Template:Mono Branch if Plus
5n Template:Mono Store indirect 05 Template:Mono Branch if Minus
6n Template:Mono Load double-byte indirect 06 Template:Mono Branch if Zero
7n Template:Mono Store double-byte indirect 07 Template:Mono Branch if NonZero
8n Template:Mono Pop indirect 08 Template:Mono Branch if Minus 1
9n Template:Mono Store Pop indirect 09 Template:Mono Branch if Not Minus 1
An Template:Mono Add 0A Template:Mono Break
Bn Template:Mono Subtract 0B Template:Mono Return from Subroutine
Cn Template:Mono Pop double-byte indirect 0C Template:Mono Branch to Subroutine
Dn Template:Mono Compare 0D colspan=2 Template:N/a
En Template:Mono Increment 0E colspan=2 Template:N/a
Fn Template:Mono Decrement 0F colspan=2 Template:N/a

References

Template:Reflist

|CitationClass=web }}