langsmoke/ref_6502

236 lines
3.6 KiB
Plaintext
Raw Normal View History

2023-11-12 18:29:17 +00:00
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
2023-11-12 17:29:29 +00:00
SET BPL SETZ
2023-11-12 13:49:57 +00:00
LD LDA R0L,X
BK EQU *-1
STA R0L
2023-11-12 17:29:29 +00:00
LDA R0H,X
2023-11-12 13:49:57 +00:00
STA R0H
RTS
ST LDA R0L
2023-11-12 17:29:29 +00:00
STA R0L,X
2023-11-12 13:49:57 +00:00
LDA R0H
STA R0H,X
RTS
STAT LDA R0L
2023-11-12 17:29:29 +00:00
STAT2 STA (R0L,X)
2023-11-12 13:49:57 +00:00
LDY $0
2023-11-12 17:29:29 +00:00
STAT3 STY R14H
2023-11-12 13:49:57 +00:00
INR INC R0L,X
2023-11-12 17:29:29 +00:00
BNE INR2
2023-11-12 13:49:57 +00:00
INC R0H,X
INR2 RTS
2023-11-12 17:29:29 +00:00
LDAT LDA (R0L,X)
STA R0L
2023-11-12 13:49:57 +00:00
LDY $0
STY R0H
2023-11-12 17:29:29 +00:00
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
2023-11-12 13:49:57 +00:00
STY R14H
RTS
2023-11-12 17:29:29 +00:00
LDDAT JSR LDAT
LDA (R0L,X)
2023-11-12 13:49:57 +00:00
STA R0H
2023-11-12 17:29:29 +00:00
JMP INR
STDAT JSR STAT
LDA R0H
STA (R0L,X)
JMP INR
STPAT JSR DCR
2023-11-12 13:49:57 +00:00
LDA R0L
2023-11-12 17:29:29 +00:00
STA (R0L,X)
JMP POP3
2023-11-12 13:49:57 +00:00
DCR LDA R0L,X
2023-11-12 17:29:29 +00:00
BNE DCR2
2023-11-12 13:49:57 +00:00
DEC R0H,X
DCR2 DEC R0L,X
RTS
2023-11-12 17:29:29 +00:00
SUB LDY $0
CPR SEC
2023-11-12 13:49:57 +00:00
LDA R0L
SBC R0L,X
2023-11-12 17:29:29 +00:00
STA R0L,Y
2023-11-12 13:49:57 +00:00
LDA R0H
SBC R0H,X
SUB2 STA R0H,Y
2023-11-12 17:29:29 +00:00
TYA
ADC $0
2023-11-12 13:49:57 +00:00
STA R14H
RTS
ADD LDA R0L
ADC R0L,X
2023-11-12 17:29:29 +00:00
STA R0L
2023-11-12 13:49:57 +00:00
LDA R0H
ADC R0H,X
2023-11-12 17:29:29 +00:00
LDY $0
BEQ SUB2
BS LDA R15L
JSR STAT2
2023-11-12 13:49:57 +00:00
LDA R15H
2023-11-12 17:29:29 +00:00
JSR STAT2
2023-11-12 13:49:57 +00:00
BR CLC
2023-11-12 17:29:29 +00:00
BNC BCS BNC2
BR1 LDA (R15L),Y
2023-11-12 13:49:57 +00:00
BPL BR2
DEY
2023-11-12 17:29:29 +00:00
BR2 ADC R15L
2023-11-12 13:49:57 +00:00
STA R15L
TYA
ADC R15H
STA R15H
BNC2 RTS
BC BCS BR
RTS
2023-11-12 17:29:29 +00:00
BP ASL
TAX
LDA R0H,X
BPL BR1
2023-11-12 13:49:57 +00:00
RTS
2023-11-12 17:29:29 +00:00
BM ASL
2023-11-12 13:49:57 +00:00
TAX
2023-11-12 17:29:29 +00:00
LDA R0H,X
2023-11-12 13:49:57 +00:00
BMI BR1
RTS
2023-11-12 17:29:29 +00:00
BZ ASL
2023-11-12 13:49:57 +00:00
TAX
2023-11-12 17:29:29 +00:00
LDA R0L,X
ORA R0H,X
BEQ BR1
2023-11-12 13:49:57 +00:00
RTS
2023-11-12 17:29:29 +00:00
BNZ ASL
2023-11-12 13:49:57 +00:00
TAX
2023-11-12 17:29:29 +00:00
LDA R0L,X
ORA R0H,X
BNE BR1
2023-11-12 13:49:57 +00:00
RTS
2023-11-12 17:29:29 +00:00
BM1 ASL
2023-11-12 13:49:57 +00:00
TAX
2023-11-12 17:29:29 +00:00
LDA R0L,X
AND R0H,X
2023-11-12 13:49:57 +00:00
EOR $FF
2023-11-12 17:29:29 +00:00
BEQ BR1
2023-11-12 13:49:57 +00:00
RTS
2023-11-12 17:29:29 +00:00
BNM1 ASL
2023-11-12 13:49:57 +00:00
TAX
LDA R0L,X
2023-11-12 17:29:29 +00:00
AND R0H,X
2023-11-12 13:49:57 +00:00
EOR $FF
2023-11-12 17:29:29 +00:00
BNE BR1
2023-11-12 13:49:57 +00:00
NUL RTS
2023-11-12 17:29:29 +00:00
RS LDX $18
JSR DCR
LDA (R0L,X)
2023-11-12 13:49:57 +00:00
STA R15H
2023-11-12 17:29:29 +00:00
JSR DCR
2023-11-12 13:49:57 +00:00
LDA (R0L,X)
STA R15L
RTS
RTN JMP RTNZ
.org $f000
init:
2023-11-12 17:29:29 +00:00
lda #$00
sta mtalock
lda #$40
2023-11-12 13:49:57 +00:00
sta acr
2023-11-12 17:29:29 +00:00
lda #$c0
2023-11-12 13:49:57 +00:00
sta ier
ldy #0
lda #0
2023-11-12 17:29:29 +00:00
stinit: sta $100,y
2023-11-12 13:49:57 +00:00
iny
bne stinit
2023-11-12 17:29:29 +00:00
lda #$00
2023-11-12 13:49:57 +00:00
sta mtatask
2023-11-12 17:29:29 +00:00
ldy #maxtask-1
2023-11-12 13:49:57 +00:00
initloop:
2023-11-12 17:29:29 +00:00
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
2023-11-12 13:49:57 +00:00
dey
2023-11-12 17:29:29 +00:00
bpl initloop
ldx #$3f
2023-11-12 13:49:57 +00:00
txs
2023-11-12 17:29:29 +00:00
lda #0
2023-11-12 13:49:57 +00:00
sta t1lsl
2023-11-12 17:29:29 +00:00
lda #40
2023-11-12 13:49:57 +00:00
sta t1csh
2023-11-12 17:29:29 +00:00
cli
jmp ent_task0
2023-11-12 13:49:57 +00:00
ent_tab:
.word ent_task0
.word ent_task1
.word ent_task2
.word ent_task3
mtaentry:
2023-11-12 17:29:29 +00:00
php
pha
2023-11-12 13:49:57 +00:00
txa
pha
tya
pha
tsx
2023-11-12 17:29:29 +00:00
inc $105,x
bne mtaent01
2023-11-12 13:49:57 +00:00
inc $106,x
mtaent01:
2023-11-12 17:29:29 +00:00
lda #$00
2023-11-12 13:49:57 +00:00
sta mtalock
2023-11-12 17:29:29 +00:00
jmp mtaswitch
2023-11-12 13:49:57 +00:00
irq:
2023-11-12 17:29:29 +00:00
pha
2023-11-12 13:49:57 +00:00
txa
pha
tya
pha
2023-11-12 17:29:29 +00:00
lda t1csl
lda #$c0
2023-11-12 13:49:57 +00:00
sta ifr
2023-11-12 17:29:29 +00:00
lda mtalock
beq mtaswitch
inc mtalock
jmp irq_ret
mtaswitch:
ldy mtatask
tsx
stx mtastab,y
iny
cpy #maxtask
bcc mtanumok
ldy #0
2023-11-12 13:49:57 +00:00
mtanumok:
2023-11-12 17:29:29 +00:00
sty mtatask
ldx mtastab,y
txs
2023-11-12 13:49:57 +00:00
irq_ret:
2023-11-12 17:29:29 +00:00
pla
2023-11-12 13:49:57 +00:00
tay
pla
tax
pla
2023-11-12 17:29:29 +00:00
rti
2023-11-12 13:49:57 +00:00
.end