Implement op -0xaf

This commit is contained in:
Takashi Toyoshima 2014-12-07 01:45:07 +09:00
parent 4a3cf30de1
commit f694a16d58

250
6502.S
View File

@ -176,7 +176,6 @@
_ldb _ldb
.endm .endm
.macro _fromZeroIndex reg .macro _fromZeroIndex reg
_fromImmb _fromImmb
add r0, r0, \reg add r0, r0, \reg
@ -190,7 +189,16 @@
_ldw _ldw
mov r1, T0 mov r1, T0
_stb _stb
adds PC, PC, #2 adds PC, PC, #3
.endm
.macro _toAbsoluteIndexed reg
adds r0, PC, #1
_ldw
add r0, r0, \reg
mov r1, T0
_stb
adds PC, PC, #3
.endm .endm
.macro _toAddr .macro _toAddr
@ -201,7 +209,6 @@
.macro _toIndexedIndirect .macro _toIndexedIndirect
adds r0, PC, #1 adds r0, PC, #1
mov r0, PC
_ldb _ldb
mov r1, RX mov r1, RX
adds r0, r0, R1 adds r0, r0, R1
@ -219,15 +226,43 @@
adds PC, PC, #2 adds PC, PC, #2
.endm .endm
.macro _toIndirectIndex
adds r0, PC, #1
_ldb
mov T1, r0
_ldb
mov TZ, r0
adds r0, T1, #1
uxtb r0, r0
_ldb
lsls r0, r0, #8
add r0, r0, TZ
add r0, r0, RY
mov r1, T0
_stb
adds PC, PC, #2
.endm
.macro _toReg reg .macro _toReg reg
mov \reg, T0 mov \reg, T0
.endm .endm
.macro _toZero .macro _toZero
_fromImmb adds r0, PC, #1
_ldb
mov r1, T0 mov r1, T0
_stb _stb
adds PC, PC, #1 adds PC, PC, #2
.endm
.macro _toZeroIndex reg
adds r0, PC, #1
_ldb
add r0, r0, \reg
uxtb r0, r0
mov r1, T0
_stb
adds PC, PC, #2
.endm .endm
.macro __cl flag .macro __cl flag
@ -271,16 +306,16 @@
__cl (FLAG_N | FLAG_Z | FLAG_C) __cl (FLAG_N | FLAG_Z | FLAG_C)
movs r1, #0x80 movs r1, #0x80
tst r0, r1 tst r0, r1
beq 1f beq 1f
bics r0, r0, r1 bics r0, r0, r1
__se FLAG_C __se FLAG_C
1: 1:
lsls r0, r0, #1 lsls r0, r0, #1
bne 1f bne 1f
__se FLAG_Z __se FLAG_Z
1: 1:
tst r0, r1 tst r0, r1
beq 1f beq 1f
__se FLAG_N __se FLAG_N
1: 1:
adds PC, PC, #1 adds PC, PC, #1
@ -290,17 +325,17 @@
__cl (FLAG_N | FLAG_Z | FLAG_V) __cl (FLAG_N | FLAG_Z | FLAG_V)
mov r1, RA mov r1, RA
ands r0, r1, r0 ands r0, r1, r0
bne 1f bne 1f
__se FLAG_Z __se FLAG_Z
1: 1:
movs r1, #0x80 movs r1, #0x80
tst r0, r1 tst r0, r1
beq 1f beq 1f
__se FLAG_N __se FLAG_N
1: 1:
movs r1, #0x40 movs r1, #0x40
tst r0, r1 tst r0, r1
beq 1f beq 1f
__se FLAG_V __se FLAG_V
1: 1:
.endm .endm
@ -341,16 +376,16 @@
__cl (FLAG_N | FLAG_Z | FLAG_C) __cl (FLAG_N | FLAG_Z | FLAG_C)
movs r1, #0x01 movs r1, #0x01
tst r0, r1 tst r0, r1
beq 1f beq 1f
__se FLAG_C __se FLAG_C
1: 1:
lsrs r0, r0, #1 lsrs r0, r0, #1
bne 1f bne 1f
__se FLAG_Z __se FLAG_Z
1: 1:
movs r1, #0x80 movs r1, #0x80
tst r0, r1 tst r0, r1
beq 1f beq 1f
__se FLAG_N __se FLAG_N
1: 1:
adds PC, PC, #1 adds PC, PC, #1
@ -366,17 +401,17 @@
__cl (FLAG_N | FLAG_Z | FLAG_C) __cl (FLAG_N | FLAG_Z | FLAG_C)
movs r1, #0x80 movs r1, #0x80
tst r0, r1 tst r0, r1
beq 1f beq 1f
__se FLAG_C __se FLAG_C
1: 1:
lsls r0, r0, #1 lsls r0, r0, #1
uxtb r0, r0 uxtb r0, r0
adds r0, r0, r2 adds r0, r0, r2
bne 1f bne 1f
__se FLAG_Z __se FLAG_Z
1: 1:
tst r0, r1 tst r0, r1
beq 1f beq 1f
__se FLAG_N __se FLAG_N
1: 1:
adds PC, PC, #1 adds PC, PC, #1
@ -389,17 +424,17 @@
__cl (FLAG_N | FLAG_Z | FLAG_C) __cl (FLAG_N | FLAG_Z | FLAG_C)
movs r1, #0x01 movs r1, #0x01
tst r0, r1 tst r0, r1
beq 1f beq 1f
__se FLAG_C __se FLAG_C
1: 1:
lsrs r0, r0, #1 lsrs r0, r0, #1
adds r0, r0, r2 adds r0, r0, r2
bne 1f bne 1f
__se FLAG_Z __se FLAG_Z
1: 1:
movs r1, #0x80 movs r1, #0x80
tst r0, r1 tst r0, r1
beq 1f beq 1f
__se FLAG_N __se FLAG_N
1: 1:
adds PC, PC, #1 adds PC, PC, #1
@ -522,6 +557,16 @@ op87:
op89: op89:
op8b: op8b:
op8f: op8f:
op93:
op97:
op9b:
op9c:
op9e:
op9f:
opa3:
opa7:
opab:
opaf:
_nop _nop
_decode _decode
@ -582,7 +627,7 @@ op0e: // ASL - Absolute
op10: // BPL (N==0) op10: // BPL (N==0)
movs r0, #FLAG_N movs r0, #FLAG_N
tst SR, r0 tst SR, r0
bne 1f bne 1f
_bxx _bxx
1: 1:
_decode _decode
@ -688,7 +733,7 @@ op2e: // ROL - Absolute
op30: // BMI (N==1) op30: // BMI (N==1)
movs r0, #FLAG_N movs r0, #FLAG_N
tst SR, r0 tst SR, r0
beq 1f beq 1f
_bxx _bxx
1: 1:
_decode _decode
@ -785,7 +830,7 @@ op4e: // LSR - Absolute
op50: // BVC (V==0) op50: // BVC (V==0)
movs r0, #FLAG_V movs r0, #FLAG_V
tst SR, r0 tst SR, r0
bne 1f bne 1f
_bxx _bxx
1: 1:
_decode _decode
@ -886,7 +931,7 @@ op6e: // ROR - Absolute
op70: // BVS (V==1) op70: // BVS (V==1)
movs r0, #FLAG_V movs r0, #FLAG_V
tst SR, r0 tst SR, r0
beq 1f beq 1f
_bxx _bxx
1: 1:
_decode _decode
@ -953,7 +998,7 @@ op88: // DEY
_decode _decode
op8a: // TXA op8a: // TXA
_t RX, RA _t RX, RA
_decode _decode
op8c: // STY - Absolute op8c: // STY - Absolute
@ -971,76 +1016,115 @@ op8e: // STX - Absolute
_toAbsb _toAbsb
_decode _decode
op90: op90: // BCC (C==0)
b quit movs r0, #FLAG_C
op91: tst SR, r0
b quit bne 1f
op92: _bxx
b quit 1:
op93: _decode
b quit
op94: op91: // STA - (Indirect), Y
b quit mov T0, RA
op95: _toIndirectIndex
b quit _decode
op96:
b quit op92: // STA - Zero Page, X
op97: mov T0, RA
b quit _toZeroIndex RX
op98: _decode
b quit
op99: op94: // STY - Zero Page, X
b quit mov T0, RY
op9a: _toZeroIndex RX
b quit _decode
op9b:
b quit op95: // STA - Zero Page, X
op9c: mov T0, RA
b quit _toZeroIndex RX
op9d: _decode
b quit
op9e: op96: // STX - Zero Page, Y
b quit mov T0, RX
op9f: _toZeroIndex RY
b quit _decode
op98: // TYA
_t RY, RA
_decode
op99: // STA - Absolute, Y
mov T0, RA
_toAbsoluteIndexed RY
_decode
op9a: // TXS
_t RX, SR
_decode
op9d: // STA - Absolute, X
mov T0, RA
_toAbsoluteIndexed RX
_decode
opa0: // LDY - Immediate opa0: // LDY - Immediate
_fromImmb _fromImmb
_ld RY _ld RY
_decode _decode
opa1:
b quit opa1: // LDA - (Indirect, X)
_fromIndexedIndirect
_ld RA
_decode
opa2: // LDX - Immediate opa2: // LDX - Immediate
_fromImmb _fromImmb
_ld RX _ld RX
_decode _decode
opa3:
b quit opa4: // LDY - Zero Page
opa4: _fromZero
b quit _ld RY
opa5: _decode
b quit
opa6: opa5: // LDA - Zero Page
b quit _fromZero
opa7: _ld RA
b quit _decode
opa8:
b quit opa6: // LDX - Zero Page
_fromZero
_ld RX
_decode
opa8: // TAY
_t RA, RY
_decode
opa9: // LDA - Immediate opa9: // LDA - Immediate
_fromImmb _fromImmb
_ld RA _ld RA
_decode _decode
opaa:
b quit opaa: // TAX
opab: _t RA, RX
b quit _decode
opac:
b quit opac: // LDY - Absolute
opad: _fromAbsb
b quit _ld RY
opae: _decode
b quit
opaf: opad: // LDA - Absolute
b quit _fromAbsb
_ld RA
_decode
opae: // LDX - Absolute
_fromAbsb
_ld RX
_decode
opb0: opb0:
b quit b quit
opb1: opb1: