Wozniak's early inspirations came from his father Jerry who was a Lockheed engineer, and from a fictional wonder-boy: Tom Swift. Jsr SW16 Continue executing Sweet 16 code Negate jsr SW16 Execute following Sweet 16 code Getting the two's complement of a number by using Sweet 16 to load the value, then returning to 6502 code to call a routine to one's complement the value, then finally going back to Sweet 16 to add one to the value. word $0000 The result of the multiplication MulNums jsr SW16 Execute following Sweet 16 code DST = $02BC Destination for memory copyĬopyHello jsr SW16 Execute following Sweet 16 code ![]() Memory Region CopyĬopying a string to a new location with Sweet 16. ![]() Example Codeīelow are a few examples to show what Sweet 16 looks like in use. Full instructions for patching, assembling and running the code are provided in the README. I have uploaded the patch and test program to github: sweet16_vic20. This will stop Basic programs from working, unless you save and restore those locations when needed, but does allow the Basic SYS command to still execute machine code. Sweet16 needs 32 bytes in zero page for the registers, so I chose locations $2B-$4A. I can't claim too much credit for porting it as beyond deciding on a suitable location for the registers in the zero page and aligning the code so that part of it fits into a single page, the majority of the work was converting the code to assemble using the XA assembler. However, despite this and the fact that the code is widely available, it is still probably under copyright and therefore the port relies on patching the original source code rather than supplying a complete version. In this article Steve Wozniak encourages users to modify Sweet 16 and even to port it to other processors, so hopefully he won't mind its being ported to the Vic. The original Sweet 16 source code has been published a number of times including in Byte Magazine Volume 02 Number 11 - November 1977. For a full description of the instructions take a look at the Byte Magazine Volume 02 Number 11 - November 1977 article. The instruction set is well thought out with the ability to use 8-bit bytes or 16-bit words and helpfully instructions like the indirect instructions increment/decrement the register being used before/after use as appropriate. There is an implicit Accumulator argument for most of the Register Operations and the Branch instructions all use relative addressing. The code is pretty compact and only takes around 300 bytes, it could have been made a little more compact and faster but it had to reside in ROM and therefore couldn't use self-modifying code. To execute Sweet 16 code you JSR to an address within it which will save the registers and status then execute the following bytes in memory as Sweet 16 code until it reaches the Sweet 16 RTN instruction which will restore the registers and status and continue executing the native 6502 that follows it. The pseudo-machine has sixteen 16-bit registers with five of them having a defined function. Sweet 16 is described as a pseudo-machine interpreter, which is probably a better description than a virtual machine because it shares native memory for storage and is designed to switch back and forth between itself and native 6502 code. I have ported this to the Commodore VIC-20 so that we can play with it on the Vic. He wrote it around 1977 and referred to it in an article as The 6502 Dream Machine. Sweet 16 was created by Steve Wozniak to reduce code size and make it easier to handle 16-bit pointers and arithmetic for his Apple Integer BASIC.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |