langsmoke/ref_6502

236 lines
3.6 KiB
Plaintext

ADC AND ASL BCC BCS BEQ BIT BMI BNE BPL BRA BRK BVC BVS
CLC CLD CLI CLV CMP CPX CPY DEC DEX DEY EOR INC INX INY
JMP JSR LDA LDX LDY LSR NOP ORA PHA PHP PHX PHY PLA PLP
PLX PLY ROL ROR RTI RTS SBC SEC SED SEI STA STP STX STY
STZ TAX TAY TRB TSB TSX TXA TXS TYA WAI
SET BPL SETZ
LD LDA R0L,X
BK EQU *-1
STA R0L
LDA R0H,X
STA R0H
RTS
ST LDA R0L
STA R0L,X
LDA R0H
STA R0H,X
RTS
STAT LDA R0L
STAT2 STA (R0L,X)
LDY $0
STAT3 STY R14H
INR INC R0L,X
BNE INR2
INC R0H,X
INR2 RTS
LDAT LDA (R0L,X)
STA R0L
LDY $0
STY R0H
BEQ STAT3
POP LDY $0
BEQ POP2
POPD JSR DCR
LDA (R0L,X)
TAY
POP2 JSR DCR
LDA (R0L,X)
STA R0L
STY R0H
POP3 LDY $0
STY R14H
RTS
LDDAT JSR LDAT
LDA (R0L,X)
STA R0H
JMP INR
STDAT JSR STAT
LDA R0H
STA (R0L,X)
JMP INR
STPAT JSR DCR
LDA R0L
STA (R0L,X)
JMP POP3
DCR LDA R0L,X
BNE DCR2
DEC R0H,X
DCR2 DEC R0L,X
RTS
SUB LDY $0
CPR SEC
LDA R0L
SBC R0L,X
STA R0L,Y
LDA R0H
SBC R0H,X
SUB2 STA R0H,Y
TYA
ADC $0
STA R14H
RTS
ADD LDA R0L
ADC R0L,X
STA R0L
LDA R0H
ADC R0H,X
LDY $0
BEQ SUB2
BS LDA R15L
JSR STAT2
LDA R15H
JSR STAT2
BR CLC
BNC BCS BNC2
BR1 LDA (R15L),Y
BPL BR2
DEY
BR2 ADC R15L
STA R15L
TYA
ADC R15H
STA R15H
BNC2 RTS
BC BCS BR
RTS
BP ASL
TAX
LDA R0H,X
BPL BR1
RTS
BM ASL
TAX
LDA R0H,X
BMI BR1
RTS
BZ ASL
TAX
LDA R0L,X
ORA R0H,X
BEQ BR1
RTS
BNZ ASL
TAX
LDA R0L,X
ORA R0H,X
BNE BR1
RTS
BM1 ASL
TAX
LDA R0L,X
AND R0H,X
EOR $FF
BEQ BR1
RTS
BNM1 ASL
TAX
LDA R0L,X
AND R0H,X
EOR $FF
BNE BR1
NUL RTS
RS LDX $18
JSR DCR
LDA (R0L,X)
STA R15H
JSR DCR
LDA (R0L,X)
STA R15L
RTS
RTN JMP RTNZ
.org $f000
init:
lda #$00
sta mtalock
lda #$40
sta acr
lda #$c0
sta ier
ldy #0
lda #0
stinit: sta $100,y
iny
bne stinit
lda #$00
sta mtatask
ldy #maxtask-1
initloop:
lda mtasini,y
sta mtastab,y
tax
lda #$b0
sta $0104,x
tya
asl a
tax
stx mtatemp
lda ent_tab,x
ldx mtastab,y
sta $0105,x
ldx mtatemp
lda ent_tab+1,x
ldx mtastab,y
sta $0106,x
dey
bpl initloop
ldx #$3f
txs
lda #0
sta t1lsl
lda #40
sta t1csh
cli
jmp ent_task0
ent_tab:
.word ent_task0
.word ent_task1
.word ent_task2
.word ent_task3
mtaentry:
php
pha
txa
pha
tya
pha
tsx
inc $105,x
bne mtaent01
inc $106,x
mtaent01:
lda #$00
sta mtalock
jmp mtaswitch
irq:
pha
txa
pha
tya
pha
lda t1csl
lda #$c0
sta ifr
lda mtalock
beq mtaswitch
inc mtalock
jmp irq_ret
mtaswitch:
ldy mtatask
tsx
stx mtastab,y
iny
cpy #maxtask
bcc mtanumok
ldy #0
mtanumok:
sty mtatask
ldx mtastab,y
txs
irq_ret:
pla
tay
pla
tax
pla
rti
.end