6 ms·
Porting Sweet 16 (2004)
- ngcc_hk 3y ago“ Direct Page Register One of the things that had made the 6502 so successful, was its extensive use of ‘zero page’, or memory locations 0 to 255. With a very limited number of registers, the 6502 relied on the use of ‘zero page’ to access frequently used values. Access to these values was faster as only a single address byte was needed to specify the address. The 6809 enhanced the use of the zero page by adding a new 8-bit ‘Direct Page’ register which allowed the ‘zero page’ to be moved to anywhere in the 16-bit address space.” From https://thechipletter.substack.com/p/motorolas-6809-the-best-8-bit https://thechipletter.substack.com/p/motorolas-6809-the-best...
- rob74 3y ago"Sweet 16 is not a teen-magazine, nor is it a brand name for candy." (from the article) "It is a song by Billy Idol, but that's not what this article is about" (my addition)
- kevindamm 3y agoIt's funny that we don't say "covering a [program]" but "porting..." when recreating something in the spirit of another's work.
- yjftsjthsd-h 3y agoI'd say porting isn't recreating; that's cloning or reimplementing. But yes, now that you pointed out it's curious that there are different words in different areas of interest.
- flippy_flops 3y ago...It is actually the NCAA regional semifinals, but again - not the topic of this article.
- HarHarVeryFunny 3y agoIt's a somewhat odd instruction set, but achieves the goal of code density by the register instructions being single byte (opcode + 4-bit register), and the odd pre/post-increment/decrement "load/store indirect" instructions which do things like acc = *reg++ useful for copy loops and push/pop operations. It reminds me a bit of the Apollo Guidance Computer (AGC) which also had a specialized decrement counter and loop instruction (CCS), presumably also just motivated by code size. Similar to having SWEET16 to augment the 6502, the AGC also used a virtual machine/interpreter to gain additional code density. https://en.wikipedia.org/wiki/Apollo_Guidance_Computer https://en.wikipedia.org/wiki/Apollo_Guidance_Computer https://borja.medium.com/a-glimpse-into-the-apollo-guidance-computer-8ee06e5e1a5c https://borja.medium.com/a-glimpse-into-the-apollo-guidance-...
- monocasa 3y agoAlso, by providing "registers" the same width as a pointer in contrast to normal 6502 code, you save a lot of shuffling between registers and the zero page just to indirectly access other data.
- howerj 3y agoIt is odd! It really likes it's load/stores and you can branch on anything, but it appears to be missing any of the bitwise operators which seems to be an odd deficiency. Perhaps that's (one of) the reasons this VM never caught on?
- HarHarVeryFunny 3y agoYeah, not clear what Woz really expected it to be used for. Apparently the only thing he used it for himself was a later Apple BASIC renumber utility! Memory and ROM space was so valuable back then, that I wonder if in retrospect he thought that was 300 bytes (size of SWEET16 interpreter) of ROM space wisely used ?!
- kragen 3y agoyes, because it saved more rom space than that
- joezydeco 3y agoI've always been curious if there was any application that used SWEET16. From a cursory look it seems like it was planned to rewrite Integer BASIC with this VM, but time ran out and then Microsoft sold them the floating point BASIC. RENUMBER from Programmer's Aid #1 seems to be the only mainstream thing that used it. Anyone know of anything else?
- dwheeler 3y agoIt was used elsewhere. E.g.: https://www.apple2history.org/museum-a-l/articles/byte8501/ https://www.apple2history.org/museum-a-l/articles/byte8501/ says: > BYTE: Isn’t Sweet-16 still used in Apple DOS and ProDOS editor/assemblers? > WOZNIAK: Yes, it’s used in EDASM , mostly in the editor portion. Randy Wigginton wrote EDASM. He’s worked here since before we even had a company. Lately he’s written the Macintosh word processor – MacWrite. He’s done a lot for the company. and he’s used Sweet-16 in several things he’s done. At least some 6502 assemblers included Sweet-16 opcodes, so I suspect many assembler programs included Sweet-16 in the parts where speed wasn't as pressing (simply because it was easy to invoke).
- ngcc_hk 3y agoOne of the enablers is zero page is really a register page under 6502. That helps a lot I think. Not to mention his thinking out of the box and tool around the issue, trading space vs speed in some scenario. Conceptually it is closed to dock as it provide an api call for some usage without a full blown vm.
- throwaway81523 3y agoI thought the zero page lived in ordinary ram. It was more efficient to access than the rest of ram, just because the instruction encodings were designed such that you could refer to 0 page addresses directly. To reach arbitrary 16-bit addresses, I believe you had to use the HL registers or similar. This style of design was common on memory starved machines of the era, including the PDP-8 which predated most of the 8-bitters.
- kragen 3y agothat is all correct except for the hl registers, which were an 8080 thing, not a 6502 thing
- HarHarVeryFunny 3y agoZero page is just the first "page" (256 bytes) of the address space, which would map to normal RAM. The only thing that is special about zero page is that since the address "page" (high 8 bits of 16bit address) is implied (=0), you only need to use an 8bit (one byte) address to specify any zero page address. The 6502 instruction set takes advantage of this by having additional instructions to load/store values to zero page as well as ones to load/store to generic 16 bit addresses. An instruction accessing zero page memory will be two bytes (op-code + one byte address), while an instruction accessing a generic address will be three bytes (op-code + two-byte address). The zero page access therefore takes less code space, and will run faster (even though the memory access speed is the same) since there are only 2 vs 3 instruction bytes to fetch. Given the 10x speed overhead of the SWEET16 interpreter, it'd really not make much difference if it chose to use non-zero page locations for its 16 registers. It makes more difference in hand written code where you are optimizing for every byte of code space and cycle of instruction timing.
- kragen 3y agoit's probably worth noting that nowadays the standard term for what this article calls a "metaprocessor", "pseudo microprocessor", and a "non-existent 16 bit processor", is "virtual machine" (which strotmann does explain in his introductory paragraph)
- ngcc_hk 3y agoSurprise to learn as not noted over there that pdp-8, z80 and 68000 all have similar arrangement, i.e. it has less code size for accessing the zero page or its equivalent. Is that widely used over these? Not talk as much as zero page when learning retro computing.