SW - ksherlock/merlin-wiki GitHub Wiki

SW - Enable Sweet 16 opcodes.

       SW

This enables Sweet 16 opcodes. If SW, and similarly for XC, is not selected, then those opcode names can be used for macros. Thus, if you are not using Sweet 16, you can use macros named ADD, SUB, etc.

Compatibility:

  • Only available in 8-bit Apple II versions.

Sweet 16 Opcodes

The assembler accepts all Sweet 16 opcodes with the standard mnemonics. The usual Sweet 16 Registers R0 to R15 do not have to be equated and the "R" is optional. For the SET opcode, either a space or a comma may be used between the register and the data part of the operands; that is, SET R3,LABEL is equivalent to SET R3 LABEL. It should be noted that the NUL opcode is assembled as a one-byte opcode (the same as HEX OD) and not a two-byte skip as this would be interpreted by ROM Sweet 16. This is intentional, and is done for internal reasons.

Instructions

1n       SET  Rn,expr               ; load constant
2n       LD   Rn                    ; load
3n       ST   Rn                    ; store
4n       LD   @Rn                   ; load indirect
5n       ST   @Rn                   ; store indirect
6n       LDD  @Rn                   ; load double indirect
7n       STD  @Rn                   ; store double indirect
8n       POP  @Rn                   ; pop indirect
9n       STP  @Rn                   ; store pop indirect
an       ADD  Rn                    ; add
bn       SUB  Rn                    ; subtract
cn       POPD @Rn                   ; pop double indirect
dn       CPR  Rn                    ; compare
en       INR  Rn                    ; increment
fn       DCR  Rn                    ; decrement
00       RTN                        ; return to 6502
01       BR   ea                    ; branch always
02       BNC  ea                    ; branch if no carry
03       BC   ea                    ; branch if carry
04       BP   ea                    ; branch if plus
05       BM   ea                    ; branch if minus
06       BZ   ea                    ; branch if zero
07       BNZ  ea                    ; branch if not zero
08       BM1  ea                    ; branch if minus 1
09       BNM1 ea                    ; branch if not minus 1
0a       BK                         ; break
0b       RS                         ; return from subroutine
0c       BS   ea                    ; branch to subroutine
0d       ---                        ; unassigned
0e       ---                        ; unassigned
0f       ---                        ; unassigned

Unassigned opcodes ($0d, $0e, and $0f) are treated by Woz's Sweet 16 interpreter as 2-byte NOPs. This is labeled as NUL in the published source code and, as mentioned above, NUL will generate a 1-byte $0x0d.