Implement all ops, except for macros, _adc, _cp, _inc, _sbc

This commit is contained in:
Takashi Toyoshima 2014-12-07 02:13:45 +09:00
parent 8301b1e97e
commit b86a32323e

179
6502.S
View File

@ -358,6 +358,10 @@
adds PC, PC, #1 adds PC, PC, #1
.endm .endm
.macro _inc
// TODO
.endm
.macro _jmp .macro _jmp
mov PC, r0 mov PC, r0
.endm .endm
@ -451,6 +455,10 @@
mov PC, r0 mov PC, r0
.endm .endm
.macro _sbc
// TODO
.endm
.macro _t a b .macro _t a b
mov r0, \a mov r0, \a
mov \a, \b mov \a, \b
@ -589,6 +597,20 @@ opda:
opdb: opdb:
opdc: opdc:
opdf: opdf:
ope2:
ope3:
ope7:
opea:
opeb:
opef:
opf2:
opf3:
opf4:
opf7:
opfa:
opfb:
opfc:
opff:
_nop _nop
_decode _decode
@ -1231,7 +1253,7 @@ opc6: // DEC - Zero Page
opc8: // INY opc8: // INY
_fromReg RY _fromReg RY
_dec _inc
_toReg RY _toReg RY
_decode _decode
@ -1306,71 +1328,102 @@ opde: // DEC - Absolute, X
_toAddr _toAddr
_decode _decode
ope0: ope0: // CPX - Immediate
b quit _fromImmb
ope1: _cp RX
b quit _decode
ope2:
b quit ope1: // SBC - (Indirect, X)
ope3: _fromIndexedIndirect
b quit _sbc
ope4: _decode
b quit
ope5: ope4: // CPX - Zero Page
b quit _fromZero
ope6: _cp RX
b quit _decode
ope7:
b quit ope5: // SBC - Zero Page
ope8: _fromZero
b quit _sbc
ope9: _decode
b quit
opea: ope6: // INC - Zero Page
b quit _fromZero
opeb: _inc
b quit _toAddr
opec: _decode
b quit
oped: ope8: // INX
b quit _fromReg RX
opee: _inc
b quit _toAddr
opef: _decode
b quit
opf0: ope9: // SBC - Immediate
b quit _fromImmb
opf1: _sbc
b quit _decode
opf2:
b quit opec: // CPX - Absolute
opf3: _fromAbsb
b quit _cp RX
opf4: _decode
b quit
opf5: oped: // SBC - Absolute
b quit _fromAbsb
opf6: _sbc
b quit _decode
opf7:
b quit opee: // INC - Absolute
_fromAbsb
_inc
_toAddr
_decode
opf0: // BEQ (Z==1)
movs r0, #FLAG_Z
tst SR, r0
beq 1f
_bxx
1:
_decode
opf1: // SBC - (Indirect), Y
_fromIndirectIndex
_sbc
_decode
opf5: // SBC - Zero Page, X
_fromZeroIndex RX
_sbc
_decode
opf6: // INC - Zero Page, X
_fromZeroIndex RX
_inc
_toAddr
_decode
opf8: // SED opf8: // SED
_sex FLAG_D _sex FLAG_D
_decode _decode
opf9:
b quit opf9: // SBC - Absolute, Y
opfa: _fromAbsoluteIndexed RY
b quit _sbc
opfb: _decode
b quit
opfc: opfd: // SBC - Absolute, X
b quit _fromAbsoluteIndexed RX
opfd: _sbc
b quit _decode
opfe:
b quit opfe: // INC - Absolute, X
opff: _fromAbsoluteIndexed RX
b quit _inc
_toAddr
_decode
.global cpu6502_reset .global cpu6502_reset
.type cpu6502_reset, %function .type cpu6502_reset, %function