In article , Deacon Blue wrote: >> Deacon Blue wrote: >> What is this "Sweet 16" thing? Is it Wozniak's "The 6502 Dream >> Machine" in some new incarnation? Or is it something else - if so, >> what? > > --> The "Sweet16" emulator is basically a BeOS port of the "Bernie II" > emulator available for Mac PPC-systems. It lack many of the features in > Bernie, but is undergoing development. > > --> Generally what most of the GS-emulators lack is the true emulation of > all features in the GS "Control Panel" especially on multilingual keyboard > support. > > As your located in Sweden (myself in Norway) you probably would want to use > a Swedish-style keyboard, if using the emulator to do other things than just > playing games. > > These options is toggled within the "Control Panel" on the real IIGS. > > --> The 8-bit A2 emulator Oasis on the other hand enables you to adjust the > keyboard-bitmap, and allows you to produce the necessary national > characters. > > I'm afraid I've never heard of "The 6502 Dream Machine", would you elaborate > a little further on this! Interesting ... you've never heard of "my" Sweet-16, and I've never heard of "yours". Anyway, Wozniak's Sweet-16 was an interpreter, written in 6502 assembly language by Woz, which emulated a virtual 16-bit machine named "Sweet-16" by Woz. It resided in the Integer Basic ROM's, and was removed when Applesoft replaced Integer Basic. However, tose who have Integer Basic available through some other means (in a ROM card, or loaded into a Language Card) also have Sweet-16. Some references: Steve Wozniak: SWEET-16, The 6502 Dream Machine. Byte, Nov 1977, p 150-159 Richard C. Vile: SWEET-16 Programming Using Macros. Micro, Jan 1980, p 25-29. Best of Micro, Vol 3, p 166-170 Charles F. Taylor: SWEET-16 Revisited Micro, Jan 1982, p 25-42 The text below is from the manual of the S-C MAcro Assembler, ver 1.0, and gives a good overview of Wozniak's Sweet-16. Remember that this was written back in the early 1980's. ----------------------------------------------------------------------- SWEET-16 is a powerful programming tool developed by Steve Wozniak in the early days of Apple. Chances are that you do have this tool, whether you know it or not. The standard version is hidden away inside the Integer BASIC system. If you have Integer BASIC on your mother board, or in a firmware card, or in a 16K RAM card, then you have SWEET-16. I have included a commented source file of SWEET-16 on your S-C MACRO ASSEMBLER II disk, so you can assemble your own copy if you wish. SWEET-16 is really a language, just like 6502 machine language, BASIC, Pascal, FORTRAN. It looks a lot like a machine language for a computer that does not really exist, so "Woz" has called it his "dream machine". You can read all about it in an old issue of BYTE Magazine (November, 1977, pages 150-159): "SWEET-16 -- The 6502 Dream Machine". Another article you may want to find is "SWEET-16 Revisited", by Charles F. Taylor. in MICRO--The 6502/6809 Journal. January, 1982, pages 25-42. The beauty of SWEET-16 is in its ability to perform 16-bit arithmetic and data moves using automatically updated address pointers. And to add icing to the cake, most of the instructions are only one byte long! You can write extremely compact code, if you are willing to pay the price of slower execution. (A typical program will take half as many bytes, but ten times longer to execute.) Does anyone really use SWEET-16? Yes, in a big way. I used it in several places inside the early versions of S-C Assembler II. The TED/ASM assembler, and all its descendants (including DOS Tool Kit, TED 11+, Big Mac, Merlin, and others) use SWEET-16 heavily. Several of the programs in the Apple Programmer's Aid ROM use SWEET-16. including the Integer BASIC Renumber/Append program. The standard version of SWEET-16 is invoked by the 6502 instruction "JSR $F689"; the bytes immediately following contain opcodes for SWEET-16 to process. SWEET-16 opcodes will be executed until the "RTN" opcode, which returns to 6502 mode. Programming Model The SWEET-16 "machine" has sixteen 16-bit registers (R0-R15). R0 is actually the two memory bytes at $0000 and $0001. The next two bytes are called R1; R15 is stored in $001E and $001F. Several of the registers have special functions: R0 is used as an accumulator (like the 6502's A-register); R12 is the subroutine return stack pointer; R13 receives the results of comparisons; R14 is a status register; R15 is the program address counter. SWEET-16 REGISTERS Register 6502 Address Purpose 0 $00,01 Accumulator 1 $02,03 General 2 $04,05 General . . . . . . . . . 11 $16,17 General 12 $18,19 Subroutine Stack Pointer 13 $1A,1B Difference of comparands 14 $1C,1D Status 15 $1E,1F Program address There are two general types of opoodes recognized by SWEET-16: register and non-register opcodes. The non-register opcodes all have the form "0x", where x is a hexadecimal digit from 0 through C. (Opcodes 0D, 0E, and 0F are not used.) These opcodes are used for relative branches, subroutine call and return, and to leave SWEET-16. The register opcodes have the format "xR", where x is a hexadecimal digit from 0 through F, and R is a register number (0-F). SWEET-16 OPCODES Non-Register Opcodes: RTN, BK, and RS are one byte opcodes. The rest have a second byte which is a relative address, similar to the relative branch addresses used in 6502 opcodes. The conditional branches use status bits found in R14. 00 RTN Return to 6502 code. 0l ea BR addr Unconditional Branch. 02 ea BNC addr Branch if Carry=0. 03 ea BC addr Branch if Carry=1. 04 ea BP addr Branch if last result positive. 0S ea BM addr Branch if last result negative. 06 ea BZ addr Branch if last result zero. 07 ea BNZ addr Branch if last result non-zero. 08 ea BM1 addr Branch if last result = -1. 09 ea BNM1 addr Branch if last result not -1. 0A BK Execute 6502 BRK instruction. 0B RS Return from SWEET-16 subroutine. 0C ea BS addr Call SWEET-16 subroutine. Register Opcodes: The SET opcode uses three bytes, to load a 16-bit immediate value into a register. All the rest of the register opcodes only use one byte. ("MA" = memory address) 1n lo hi SET n,value Rn <-- value. 2n LD n R0 <-- (Rn). 3n ST n Rn <-- (R0). 4n LD @n MA = (Rn), ROL <-- (MA), Rn <-- MA+1, R0H <-- 0. 5n ST @n MA = (Rn), MA <-- (R0L), Rn <-- MA+1. 6n LDD @n MA = (Rn), R0 <-- (MA, MA+1), Rn <-- MA+2. 7n STD @n MA = (Rn), MA,MA+l <-- (R0), Rn <-- MA+2. 8n POP @n MA = (Rn)-1, R0L <-- (MA), R0H <-- 0, Rn <-- MA. 9n STP @n MA <-- (Rn)-1, (MA) <-- R0L, Rn <-- MA. An ADD n R0 <-- (R0) + (Rn). Bn SUB n R0 <-- (R0) - (Rn). Cn POPD @n MA = (Rn)-2, MA,MA+l <-- R0, Rn <-- MA. Dn CPR n R13 <-- (R0) - (Rn), R14 <-- status flags. En INR n Rn <-- (Rn) + 1. Fn DCR n Rn <-- (Rn) - 1. The S-C Assembler II includes all of the SWEET-16 opcodes, in the formats shown above. You can write programs which mix both 6502 code and SWEET-16 together in any combination. Here are a few examples which illustrate programming in SWEET-16. 1000 *------------------------------------- 1010 * CLEAR A BLOCK OF MEMORY 1020 *------------------------------------- F689- 1030 SWEET.16 .EQ $F689 0A00- 1040 BLOCK .EQ $A00 0234- 1050 N .EQ $234 1060 *------------------------------------- 0800- 20 89 F6 1070 CLEAR JSR SWEET.16 0803- 10 00 00 1080 SET 0,0 0 FOR CLEARING WITH 0806- 11 00 0A 1090 SET 1,BLOCK ADDRESS OF BLOCK 0809- 12 34 02 1100 SET 2,N # BYTES TO CLEAR 080C- 51 1110 .1 ST @1 STORE IN BLOCK 080D- F2 1120 DCR 2 080E- 07 FC 1130 BNZ .1 NOT FINISHED YET 0810- 00 1140 RTN SYMBOL TABLE 0A00- BLOCK 0800- CLEAR .1=080C 0234- N F689- SWEET.16 0000 ERRORS IN ASSEMBLY 1000 *---------------------------- 1010 * MOVE A BLOCK OF MEMORY 1020 *---------------------------- F689- 1030 SWEET.16 .EQ $F689 0A00- 1040 SOURCE .EQ $A00 0A80- 1050 DESTIN .EQ $A80 0023- 1060 N .EQ $23 1070 *---------------------------- 0800- 20 89 F6 1080 MOVE JSR SWEET.16 0803- 11 00 0A 1090 SET 1,SOURCE ADDRESS OF SOURCE BLOCK 0806- 12 80 0A 1100 SET 2,DESTIN ADDRESS OF DESTINATION BLOCK 0809- 13 23 00 1110 SET 3,N # BYTES TO MOVE 080C- 41 1120 .1 LD @1 GET BYTE FROM SOURCE 080D- 52 1130 ST @2 STORE IN DESTINATION 080E- F3 1140 DCR 3 080F- 07 FB 1150 BNZ .1 NOT FINISHED YET 0811- 00 1160 RTN SYMBOL TABLE 0A80- DESTIN 0800- MOVE .01=08CC 0023- N 0A00- SOURCE F689- SWEET.16 0000 ERRORS IN ASSEMBLY 1000 *------------------------------- 1010 * RENUMBER S-C ASSEMBLER SOURCE CODE 1020 *------------------------------- F689- 1030 SWEET.16 .EQ $F689 004C- 1040 HIMEM .EQ $4C,4D 00CA- 1050 PP .EQ $CA,CB 1060 *------------------------------- 1070 RENUMBER 0800- 20 89 F6 1080 JSR SWEET.16 0803- 11 CA 00 1090 SET 1,PP PP HAS ADDRESS OF SOURCE CODE 0806- 61 1100 LDD @1 GET ADDRESS OF SOURCE CODE 0807- 31 1110 ST 1 ...IN R1 0808- 12 0A 00 1120 SET 2,10 INCREMENT = 10 080B- 13 4C 00 1130 SET 3,HIMEM HIMEM HAS ADDR OF END OF SOURCE 080E- 63 1140 LDD @3 GET ADDRESS IN HIMEM 080F- 33 1150 ST 3 ...IN R3 0810- 14 DE 03 1160 SET 4,990 START=990 (1ST LINE WILL BE 1000) 0813- 21 1170 .1 LD 1 TEST IF FINISHED 0814- D3 1180 CPR 3 0815- 03 0E 1190 BC .2 YES 0817- 41 1200 LD @1 GET # BYTES IN THIS SOURCE LINE 0818- 35 1210 ST 5 ... INTO R5 0819- 24 1220 LD 4 GET SEQUENCE NUMBER 081A- A2 1230 ADD 2 ADD INCREMENT 081B- 34 1240 ST 4 ... INTO R4 AGAIN 081C- 71 1250 STD @1 ... AND ALSO INTO SOURCE LINE 081D- F1 1260 DCR 1 BACK UP POINTER 081E- F1 1270 DCR 1 081F- F1 1280 DCR 1 0820- 21 1290 LD 1 ADD LENGTH OF LINE TO POINTER 0821- A5 1300 ADD 5 0822- 31 1310 ST 1 POINT AT NEXT SOURCE LINE 0823- 01 EE 1320 BR .1 0825- 00 1330 .2 RTN 0826- 60 1340 RTS SYMBOL TABLE 004C- HIHEM 00CA- PP 0800- RENUMBER .01-0813, .02-0825 F689- SWEET.16 0000 ERRORS IN ASSEMBLY -- ---------------------------------------------------------------- Paul Schlyter, Swedish Amateur Astronomer's Society (SAAF) Grev Turegatan 40, S-114 38 Stockholm, SWEDEN e-mail: pausch at saaf dot se or paul.schlyter at ausys dot se WWW: http://hotel04.ausys.se/pausch http://welcome.to/pausch