F689

:
F68C:
F68D:
F68F:
F690:
F692:
F695:
F698:
F69A:
F69C:
F69E:
F6A0:
F6A1:
F6A3:
F6A5:
F6A7:
F6A8:
F6A9:
F6AA:
F6AC:
F6AE:
F6B0:
F6B1:
F6B2:
F6B3:
F6B4:
F6B7:
F6B8:
F6B9:
F6BB:
F6BD:
F6BF:
F6C2:
F6C3:
F6C5:
F6C6:

20
68
85
68
85
20
4C
E6
D0
E6
A9
48
A0
B1
29
0A
AA
4A
51
F0
86
4A
4A
4A
A8
B9
48
60
E6
D0
E6
BD
48
A5
4A
60

4A FF
1E
1F
98 F6
92 F6
1E
02
1F
F7
00
1E
0F

1E
0B
1D

E1 F6
1E
02
1F
E4 F6
1D

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58

***********************
*
*
*
APPLE-II PSEUDO
*
* MACHINE INTERPRETER *
*
*
*
COPYRIGHT 1977
*
* APPLE COMPUTER INC *
*
*
* ALL RIGHTS RESERVED *
*
S. WOZNIAK
*
*
*
***********************
R0L
R0H
R14H
R15L
R15H
SW16PAG
SAVE
RESTORE
SW16

SW16B
SW16C
SW16D

TOBR
TOBR2

EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
ORG
JSR
PLA
STA
PLA
STA
JSR
JMP
INC
BNE
INC
LDA
PHA
LDY
LDA
AND
ASL
TAX
LSR
EOR
BEQ
STX
LSR
LSR
LSR
TAY
LDA
PHA
RTS
INC
BNE
INC
LDA
PHA
LDA
LSR
RTS

$0
$1
$1D
$1E
$1F
$F7
$FF4A
$FF3F
$F689
SAVE
R15L
R15H
SW16C
SW16B
R15L
SW16D
R15H
#SW16PAG
#$0
(R15L),Y
#$F

(R15L),Y
TOBR
R14H

; TITLE "SWEET16 INTERPRETER"

;PRESERVE 6502 REG CONTENTS
;INIT SWEET16 PC
;FROM RETURN
; ADDRESS
;INTERPRET AND EXECUTE
;ONE SWEET16 INSTR.
;INCR SWEET16 PC FOR FETCH
;PUSH ON STACK FOR RTS
;FETCH INSTR
;MASK REG SPECIFICATION
;DOUBLE FOR TWO BYTE REGISTERS
;TO X REG FOR INDEXING
;NOW HAVE OPCODE
;IF ZERO THEN NON-REG OP
;INDICATE'PRIOR RESULT REG'
;OPCODE*2 TO LSB'S

OPTBL-2,Y
R15L
TOBR2
R15H
BRTBL,X
R14H

;TO Y REG FOR INDEXING
;LOW ORDER ADR BYTE
;ONTO STACK
;GOTO REG-OP ROUTINE
;INCR PC
;LOW ORDER ADR BYTE
;ONTO STACK FOR NON-REG OP
;'PRIOR RESULT REG' INDEX
;PREPARE CARRY FOR BC, BNC.
;GOTO NON-REG OP ROUTINE

F6C7:
F6C8:
F6C9:
F6CC:
F6CF:
F6D1:
F6D3:
F6D4:
F6D6:
F6D8:
F6D9:
F6DA:
F6DC:
F6DE:
F6E0:
F6E2:
F6E3:
F6E4:
F6E5:
F6E6:
F6E7:
F6E8:
F6E9:
F6EA:
F6EB:
F6EC:
F6ED:
F6EE:
F6EF:
F6F0:
F6F1:
F6F2:
F6F3:
F6F4:
F6F5:
F6F6:
F6F7:
F6F8:
F6F9:
F6FA:
F6FB:
F6FC:
F6FD:
F6FE:
F6FF:
F700:
F701:
F702:
F703:
F705:

68
68
20
6C
B1
95
88
B1
95
98
38
65
85
90
E6
60
02
F9
04
9D
0D
9E
25
AF
16
B2
47
B9
51
C0
2F
C9
5B
D2
85
DD
6E
05
33
E8
70
93
1E
E7
65
E7
E7
E7
10
B5

F707:
F709:
F70B:
F70D:
F70E:
F710:
F712:

85
B5
85
60
A5
95
A5

3F FF
1E 00
1E
01
1E
00
1E
1E
02
1F

CA
00
00
01
01
00
00
01

59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116

RTNZ

SETZ

SET2
OPTBL
BRTBL

SET
LD
BK

ST

PLA
PLA
JSR
JMP
LDA
STA
DEY
LDA
STA
TYA
SEC
ADC
STA
BCC
INC
RTS
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
DFB
BPL
LDA
EQU
STA
LDA
STA
RTS
LDA
STA
LDA

;POP RETURN ADDRESS
RESTORE
(R15L)
(R15L),Y
R0H,X

;RESTORE 6502 REG CONTENTS
;RETURN TO 6502 CODE VIA PC
;HIGH-ORDER BYTE OF CONSTANT

(R15L),Y
R0L,X

;LOW-ORDER BYTE OF CONSTANT
;Y-REG CONTAINS 1

R15L
R15L
SET2
R15H

;ADD 2 TO PC

SET-1
RTN-1
LD-1
BR-1
ST-1
BNC-1
LDAT-1
BC-1
STAT-1
BP-1
LDDAT-1
BM-1
STDAT-1
BZ-1
POP-1
BNZ-1
STPAT-1
BM1-1
ADD-1
BNM1-1
SUB-1
BK-1
POPD-1
RS-1
CPR-1
BS-1
INR-1
NUL-1
DCR-1
NUL-1
NUL-1
NUL-1
SETZ
R0L,X
*-1
R0L
R0H,X
R0H

;1X
;0
;2X
;1
;3X
;2
;4X
;3
;5X
;4
;6X
;5
;7X
;6
;8X
;7
;9X
;8
;AX
;9
;BX
;A
;CX
;B
;DX
;C
;EX
;D
;FX
;E
;UNUSED
;F
;ALWAYS TAKEN

R0L
R0L,X
R0H

;MOVE RX TO R0

;MOVE R0 TO RX

F714:
F716:
F717:
F719:
F71B:
F71D:
F71F:
F721:
F723:
F725:
F726:
F728:
F72A:
F72C:
F72E:
F730:
F732:
F734:
F737:
F739:
F73A:
F73D:
F73F:
F741:
F743:
F745:
F747:
F748:
F74B:
F74D:
F74F:
F752:
F755:
F757:
F759:
F75C:
F75F:
F761:
F763:
F766:
F768:
F76A:
F76C:
F76E:
F76F:
F771:
F772:
F774:
F776:
F779:
F77B:
F77D:
F780:
F781:
F783:
F785:
F786:
F788:

95
60
A5
81
A0
84
F6
D0
F6
60
A1
85
A0
84
F0
A0
F0
20
A1
A8
20
A1
85
84
A0
84
60
20
A1
85
4C
20
A5
81
4C
20
A5
81
4C
B5
D0
D6
D6
60
A0
38
A5
F5
99
A5
F5
99
98
69
85
60
A5
75

01
00
00
00
1D
00
02
01
00
00
00
01
ED
00
06
66 F7
00
66 F7
00
00
01
00
1D
26
00
01
1F
17
01
00
1F
66
00
00
43
00
02
01
00

F7
F7
F7
F7
F7
F7

00
00
00
00 00
01
01
01 00
00
1D
00
00

117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174

STAT
STAT2
STAT3
INR
INR2
LDAT

POP
POPD
POP2

POP3
LDDAT

STDAT

STPAT

DCR
DCR2
SUB
CPR

SUB2

ADD

STA
RTS
LDA
STA
LDY
STY
INC
BNE
INC
RTS
LDA
STA
LDY
STY
BEQ
LDY
BEQ
JSR
LDA
TAY
JSR
LDA
STA
STY
LDY
STY
RTS
JSR
LDA
STA
JMP
JSR
LDA
STA
JMP
JSR
LDA
STA
JMP
LDA
BNE
DEC
DEC
RTS
LDY
SEC
LDA
SBC
STA
LDA
SBC
STA
TYA
ADC
STA
RTS
LDA
ADC

R0H,X
R0L
(R0L,X)
#$0
R14H
R0L,X
INR2
R0H,X
(R0L,X)
R0L
#$0
R0H
STAT3
#$0
POP2
DCR
(R0L,X)
DCR
(R0L,X)
R0L
R0H
#$0
R14H

;STORE BYTE INDIRECT
;INDICATE R0 IS RESULT NEG
;INCR RX
;LOAD INDIRECT (RX)
;TO R0
;ZERO HIGH-ORDER R0 BYTE
;ALWAYS TAKEN
;HIGH ORDER BYTE = 0
;ALWAYS TAKEN
;DECR RX
;POP HIGH ORDER BYTE @RX
;SAVE IN Y-REG
;DECR RX
;LOW-ORDER BYTE
;TO R0
;INDICATE R0 AS LAST RESULT REG

LDAT
(R0L,X)
R0H
INR
STAT
R0H
(R0L,X)
INR
DCR
R0L
(R0L,X)
POP3
R0L,X
DCR2
R0H,X
R0L,X

;LOW-ORDER BYTE TO R0, INCR RX
;HIGH-ORDER BYTE TO R0

#$0

;RESULT TO R0
;NOTE Y-REG = 13*2 FOR CPR

R0L
R0L,X
R0L,Y
R0H
R0H,X
R0H,Y
#$0
R14H
R0L
R0L,X

;INCR RX
;STORE INDIRECT LOW-ORDER
;BYTE AND INCR RX. THEN
;STORE HIGH-ORDER BYTE.
;INCR RX AND RETURN
;DECR RX
;STORE R0 LOW BYTE @RX
;INDICATE R0 AS LAST RSLT REG
;DECR RX

;R0-RX TO RY

;LAST RESULT REG*2
;CARRY TO LSB

F78A:
F78C:
F78E:
F790:
F792:
F794:
F796:
F799:
F79B:
F79E:
F79F:
F7A1:
F7A3:
F7A5:
F7A6:
F7A8:
F7AA:
F7AB:
F7AD:
F7AF:
F7B0:
F7B2:
F7B3:
F7B4:
F7B5:
F7B7:
F7B9:
F7BA:
F7BB:
F7BC:
F7BE:
F7C0:
F7C1:
F7C2:
F7C3:
F7C5:
F7C7:
F7C9:
F7CA:
F7CB:
F7CC:
F7CE:
F7D0:
F7D2:
F7D3:
F7D4:
F7D5:
F7D7:
F7D9:
F7DB:
F7DD:
F7DE:
F7DF:
F7E0:
F7E2:
F7E4:
F7E6:
F7E8:

85
A5
75
A0
F0
A5
20
A5
20
18
B0
B1
10
88
65
85
98
65
85
60
B0
60
0A
AA
B5
10
60
0A
AA
B5
30
60
0A
AA
B5
15
F0
60
0A
AA
B5
15
D0
60
0A
AA
B5
35
49
F0
60
0A
AA
B5
35
49
D0
60

00
01
01
00
E9
1E
19 F7
1F
19 F7
0E
1E
01
1E
1E
1F
1F
EC

01
E8

01
E1

00
01
D8

00
01
CF

00
01
FF
C4

00
01
FF
B9

175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232

BS

BR
BNC
BR1
BR2

BNC2
BC
BP

BM

BZ

BNZ

BM1

BNM1

NUL

STA
LDA
ADC
LDY
BEQ
LDA
JSR
LDA
JSR
CLC
BCS
LDA
BPL
DEY
ADC
STA
TYA
ADC
STA
RTS
BCS
RTS
ASL
TAX
LDA
BPL
RTS
ASL
TAX
LDA
BMI
RTS
ASL
TAX
LDA
ORA
BEQ
RTS
ASL
TAX
LDA
ORA
BNE
RTS
ASL
TAX
LDA
AND
EOR
BEQ
RTS
ASL
TAX
LDA
AND
EOR
BNE
RTS

R0L
R0H
R0H,X
#$0
SUB2
R15L
STAT2
R15H
STAT2

;R0+RX TO R0

BNC2
(R15L),Y
BR2

;NO CARRY TEST
;DISPLACEMENT BYTE

R15L
R15L

;ADD TO PC

;R0 FOR RESULT
;FINISH ADD
;NOTE X-REG IS 12*2!
;PUSH LOW PC BYTE VIA R12
;PUSH HIGH-ORDER PC BYTE

R15H
R15H
BR

R0H,X
BR1

;DOUBLE RESULT-REG INDEX
;TO X REG FOR INDEXING
;TEST FOR PLUS
;BRANCH IF SO
;DOUBLE RESULT-REG INDEX

R0H,X
BR1

;TEST FOR MINUS
;DOUBLE RESULT-REG INDEX

R0L,X
R0H,X
BR1

;TEST FOR ZERO
;(BOTH BYTES)
;BRANCH IF SO
;DOUBLE RESULT-REG INDEX

R0L,X
R0H,X
BR1

;TEST FOR NON-ZERO
;(BOTH BYTES)
;BRANCH IF SO
;DOUBLE RESULT-REG INDEX

R0L,X
R0H,X
#$FF
BR1

;CHECK BOTH BYTES
;FOR $FF (MINUS 1)
;BRANCH IF SO
;DOUBLE RESULT-REG INDEX

R0L,X
R0H,X
#$FF
BR1

;CHECK BOTH BYTES FOR NO $FF
;BRANCH IF NOT MINUS 1

F7E9:
F7EB:
F7EE:
F7F0:
F7F2:
F7F5:
F7F7:
F7F9:
F7FA:

A2
20
A1
85
20
A1
85
60
4C

18
66 F7
00
1F
66 F7
00
1E
C7 F6

233
234
235
236
237
238
239
240
241

RS

RTN

LDX
JSR
LDA
STA
JSR
LDA
STA
RTS
JMP

#$18
DCR
(R0L,X)
R15H
DCR
(R0L,X)
R15L
RTNZ

;12*2 FOR R12 AS STACK POINTER
;DECR STACK POINTER
;POP HIGH RETURN ADDRESS TO PC
;SAME FOR LOW-ORDER BYTE

Master your semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master your semester with Scribd & The New York Times

Cancel anytime.