From: mrdudz Date: Wed, 19 Nov 2014 21:04:32 +0000 (+0100) Subject: starting branch for adding the missing undocumented opcodes X-Git-Tag: V2.15~31^2~8 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=202a2d677b46832513fe95107abf92efa3a53488;p=cc65 starting branch for adding the missing undocumented opcodes --- diff --git a/src/ca65/instr.c b/src/ca65/instr.c index c2482577c..9270f5601 100644 --- a/src/ca65/instr.c +++ b/src/ca65/instr.c @@ -783,7 +783,7 @@ static const InsTable* InsTabs[CPU_COUNT] = { const InsTable* InsTab = (const InsTable*) &InsTab6502; /* Table to build the effective 65xx opcode from a base opcode and an -** addressing mode. +** addressing mode. (The value in the table is ORed with the base opcode) */ static unsigned char EATab[10][AM65I_COUNT] = { { /* Table 0 */ diff --git a/testcode/assembler/.gitignore b/testcode/assembler/.gitignore new file mode 100644 index 000000000..160ca9ba4 --- /dev/null +++ b/testcode/assembler/.gitignore @@ -0,0 +1,2 @@ +chkillegal.bin +chklegal.bin diff --git a/testcode/assembler/Makefile b/testcode/assembler/Makefile new file mode 100644 index 000000000..ae08864f8 --- /dev/null +++ b/testcode/assembler/Makefile @@ -0,0 +1,19 @@ + +all: chklegal.bin chkillegal.bin + @# + +.PHONY: chklegal.bin chkillegal.bin + +chklegal.bin: legal.s + ../../bin/cl65 --target none --cpu 6502X -o chklegal.bin legal.s + diff legal.ref chklegal.bin + +chkillegal.bin: illegal.s + ../../bin/cl65 --target none --cpu 6502X -o chkillegal.bin illegal.s + +ref: legal.s + ../../bin/cl65 --target none --cpu 6502X -o legal.ref legal.s + +clean: + rm -f legal.o chklegal.bin + rm -f illegal.o chkillegal.bin diff --git a/testcode/assembler/all.s b/testcode/assembler/all.s new file mode 100644 index 000000000..5471a2bb1 --- /dev/null +++ b/testcode/assembler/all.s @@ -0,0 +1,255 @@ + brk ; 00 + ora ($12,x) ; 01 12 + jam ; 02 + slo ($12,x) ; 03 12 + noop $12 ; 04 12 + ora $12 ; 05 12 + asl $12 ; 06 12 + slo $12 ; 07 12 + php ; 08 + ora #$12 ; 09 12 + asl a ; 0a + anc #$12 ; 0b 12 + noop $1234 ; 0c 34 12 + ora $1234 ; 0d 34 12 + asl $1234 ; 0e 34 12 + slo $1234 ; 0f 34 12 + bpl $101c ; 10 12 + ora ($12),y ; 11 12 + jam ; 12 + slo ($12),y ; 13 12 + noop $12,x ; 14 12 + ora $12,x ; 15 12 + asl $12,x ; 16 12 + slo $12,x ; 17 12 + clc ; 18 + ora $1234,y ; 19 34 12 + noop ; 1a + slo $1234,y ; 1b 34 12 + noop $1234,x ; 1c 34 12 + ora $1234,x ; 1d 34 12 + asl $1234,x ; 1e 34 12 + slo $1234,x ; 1f 34 12 + jsr $1234 ; 20 34 12 + and ($12,x) ; 21 12 + jam ; 22 + rla ($12,x) ; 23 12 + bit $12 ; 24 12 + and $12 ; 25 12 + rol $12 ; 26 12 + rla $12 ; 27 12 + plp ; 28 + and #$12 ; 29 12 + rol a ; 2a + anc #$12 ; 2b 12 + bit $1234 ; 2c 34 12 + and $1234 ; 2d 34 12 + rol $1234 ; 2e 34 12 + rla $1234 ; 2f 34 12 + bmi $107c ; 30 12 + and ($12),y ; 31 12 + jam ; 32 + rla ($12),y ; 33 12 + noop $12,x ; 34 12 + and $12,x ; 35 12 + rol $12,x ; 36 12 + rla $12,x ; 37 12 + sec ; 38 + and $1234,y ; 39 34 12 + noop ; 3a + rla $1234,y ; 3b 34 12 + noop $1234,x ; 3c 34 12 + and $1234,x ; 3d 34 12 + rol $1234,x ; 3e 34 12 + rla $1234,x ; 3f 34 12 + rti ; 40 + eor ($12,x) ; 41 12 + jam ; 42 + sre ($12,x) ; 43 12 + noop $12 ; 44 12 + eor $12 ; 45 12 + lsr $12 ; 46 12 + sre $12 ; 47 12 + pha ; 48 + eor #$12 ; 49 12 + lsr a ; 4a + asr #$12 ; 4b 12 + jmp $1234 ; 4c 34 12 + eor $1234 ; 4d 34 12 + lsr $1234 ; 4e 34 12 + sre $1234 ; 4f 34 12 + bvc $10dc ; 50 12 + eor ($12),y ; 51 12 + jam ; 52 + sre ($12),y ; 53 12 + noop $12,x ; 54 12 + eor $12,x ; 55 12 + lsr $12,x ; 56 12 + sre $12,x ; 57 12 + cli ; 58 + eor $1234,y ; 59 34 12 + noop ; 5a + sre $1234,y ; 5b 34 12 + noop $1234,x ; 5c 34 12 + eor $1234,x ; 5d 34 12 + lsr $1234,x ; 5e 34 12 + sre $1234,x ; 5f 34 12 + rts ; 60 + adc ($12,x) ; 61 12 + jam ; 62 + rra ($12,x) ; 63 12 + noop $12 ; 64 12 + adc $12 ; 65 12 + ror $12 ; 66 12 + rra $12 ; 67 12 + pla ; 68 + adc #$12 ; 69 12 + ror a ; 6a + arr #$12 ; 6b 12 + jmp ($1234) ; 6c 34 12 + adc $1234 ; 6d 34 12 + ror $1234 ; 6e 34 12 + rra $1234 ; 6f 34 12 + bvs $113c ; 70 12 + adc ($12),y ; 71 12 + jam ; 72 + rra ($12),y ; 73 12 + noop $12,x ; 74 12 + adc $12,x ; 75 12 + ror $12,x ; 76 12 + rra $12,x ; 77 12 + sei ; 78 + adc $1234,y ; 79 34 12 + noop ; 7a + rra $1234,y ; 7b 34 12 + noop $1234,x ; 7c 34 12 + adc $1234,x ; 7d 34 12 + ror $1234,x ; 7e 34 12 + rra $1234,x ; 7f 34 12 + noop #$12 ; 80 12 + sta ($12,x) ; 81 12 + noop #$12 ; 82 12 + sax ($12,x) ; 83 12 + sty $12 ; 84 12 + sta $12 ; 85 12 + stx $12 ; 86 12 + sax $12 ; 87 12 + dey ; 88 + noop #$12 ; 89 12 + txa ; 8a + ane #$12 ; 8b 12 + sty $1234 ; 8c 34 12 + sta $1234 ; 8d 34 12 + stx $1234 ; 8e 34 12 + sax $1234 ; 8f 34 12 + bcc $119c ; 90 12 + sta ($12),y ; 91 12 + jam ; 92 + sha ($12),y ; 93 12 + sty $12,x ; 94 12 + sta $12,x ; 95 12 + stx $12,y ; 96 12 + sax $12,y ; 97 12 + tya ; 98 + sta $1234,y ; 99 34 12 + txs ; 9a + shs $1234,y ; 9b 34 12 + shy $1234,x ; 9c 34 12 + sta $1234,x ; 9d 34 12 + shx $1234,y ; 9e 34 12 + sha $1234,y ; 9f 34 12 + ldy #$12 ; a0 12 + lda ($12,x) ; a1 12 + ldx #$12 ; a2 12 + lax ($12,x) ; a3 12 + ldy $12 ; a4 12 + lda $12 ; a5 12 + ldx $12 ; a6 12 + lax $12 ; a7 12 + tay ; a8 + lda #$12 ; a9 12 + tax ; aa + lxa #$12 ; ab 12 + ldy $1234 ; ac 34 12 + lda $1234 ; ad 34 12 + ldx $1234 ; ae 34 12 + lax $1234 ; af 34 12 + bcs $11fc ; b0 12 + lda ($12),y ; b1 12 + jam ; b2 + lax ($12),y ; b3 12 + ldy $12,x ; b4 12 + lda $12,x ; b5 12 + ldx $12,y ; b6 12 + lax $12,y ; b7 12 + clv ; b8 + lda $1234,y ; b9 34 12 + tsx ; ba + las $1234,y ; bb 34 12 + ldy $1234,x ; bc 34 12 + lda $1234,x ; bd 34 12 + ldx $1234,y ; be 34 12 + lax $1234,y ; bf 34 12 + cpy #$12 ; c0 12 + cmp ($12,x) ; c1 12 + noop #$12 ; c2 12 + dcp ($12,x) ; c3 12 + cpy $12 ; c4 12 + cmp $12 ; c5 12 + dec $12 ; c6 12 + dcp $12 ; c7 12 + iny ; c8 + cmp #$12 ; c9 12 + dex ; ca + sbx #$12 ; cb 12 + cpy $1234 ; cc 34 12 + cmp $1234 ; cd 34 12 + dec $1234 ; ce 34 12 + dcp $1234 ; cf 34 12 + bne $125c ; d0 12 + cmp ($12),y ; d1 12 + jam ; d2 + dcp ($12),y ; d3 12 + noop $12,x ; d4 12 + cmp $12,x ; d5 12 + dec $12,x ; d6 12 + dcp $12,x ; d7 12 + cld ; d8 + cmp $1234,y ; d9 34 12 + noop ; da + dcp $1234,y ; db 34 12 + noop $1234,x ; dc 34 12 + cmp $1234,x ; dd 34 12 + dec $1234,x ; de 34 12 + dcp $1234,x ; df 34 12 + cpx #$12 ; e0 12 + sbc ($12,x) ; e1 12 + noop #$12 ; e2 12 + isb ($12,x) ; e3 12 + cpx $12 ; e4 12 + sbc $12 ; e5 12 + inc $12 ; e6 12 + isb $12 ; e7 12 + inx ; e8 + sbc #$12 ; e9 12 + nop ; ea + usbc #$12 ; eb 12 + cpx $1234 ; ec 34 12 + sbc $1234 ; ed 34 12 + inc $1234 ; ee 34 12 + isb $1234 ; ef 34 12 + beq $12bc ; f0 12 + sbc ($12),y ; f1 12 + jam ; f2 + isb ($12),y ; f3 12 + noop $12,x ; f4 12 + sbc $12,x ; f5 12 + inc $12,x ; f6 12 + isb $12,x ; f7 12 + sed ; f8 + sbc $1234,y ; f9 34 12 + isb $1234,y ; fb 34 12 + noop $1234,x ; fc 34 12 + sbc $1234,x ; fd 34 12 + inc $1234,x ; fe 34 12 + isb $1234,x ; ff 34 12 diff --git a/testcode/assembler/illegal.s b/testcode/assembler/illegal.s index 53b9ec5b0..5145e31e5 100644 --- a/testcode/assembler/illegal.s +++ b/testcode/assembler/illegal.s @@ -1,43 +1,136 @@ .setcpu "6502X" +; first all totally staple undocs: -.macro test opc + slo $12 ; 07 12 + slo $1234 ; 0f 34 12 + slo $1234,x ; 1f 34 12 + slo $1234,y ; 1b 34 12 + slo ($12,x) ; 03 12 + slo $12,x ; 17 12 + slo ($12),y ; 13 12 - opc $00 - opc $00,x - opc ($00,x) - opc ($00),y - opc $1234 - opc $1234,x - opc $1234,y + rla $12 ; 27 12 + rla $1234 ; 2f 34 12 + rla $1234,x ; 3f 34 12 + rla $1234,y ; 3b 34 12 + rla ($12,x) ; 23 12 + rla $12,x ; 37 12 + rla ($12),y ; 33 12 -.endmacro + sre $1234 ; 4f 34 12 + sre $1234,x ; 5f 34 12 + sre $1234,y ; 5b 34 12 + sre $12 ; 47 12 + sre ($12,x) ; 43 12 + sre $12,x ; 57 12 + sre ($12),y ; 53 12 + rra $1234 ; 6f 34 12 + rra $1234,x ; 7f 34 12 + rra $1234,y ; 7b 34 12 + rra $12 ; 67 12 + rra ($12,x) ; 63 12 + rra $12,x ; 77 12 + rra ($12),y ; 73 12 - test slo - test rla - test sre - test rra - test dcp - test isc + dcp $1234 ; cf 34 12 + dcp $1234,x ; df 34 12 + dcp $1234,y ; db 34 12 + dcp $12 ; c7 12 + dcp ($12,x) ; c3 12 + dcp $12,x ; d7 12 + dcp ($12),y ; d3 12 - sax $00 - sax $00,y - sax ($00,x) - sax $1234 + isc $1234 ; ef 34 12 + isc $1234,x ; ff 34 12 + isc $1234,y ; fb 34 12 + isc $12 ; e7 12 + isc ($12,x) ; e3 12 + isc $12,x ; f7 12 + isc ($12),y ; f3 12 - lax $00 - lax $00,y - lax ($00,x) - lax ($00),y - lax $1234 - lax $1234,y + sax $1234 ; 8f 34 12 + sax $12 ; 87 12 + sax ($12,x) ; 83 12 + sax $12,y ; 97 12 - anc #$55 - alr #$55 - arr #$55 - axs #$55 + lax $1234 ; af 34 12 + lax $1234,y ; bf 34 12 + lax $12 ; a7 12 + lax ($12,x) ; a3 12 + lax ($12),y ; b3 12 + lax $12,y ; b7 12 - las $1234,y + + anc #$12 ; 0b 12 + ;anc #$12 ; 2b 12 + + arr #$12 ; 6b 12 + + alr #$12 ; 4b 12 + + axs #$12 ; cb 12 + +; nop $12 ; 04 12 +; nop $1234 ; 0c 34 12 +; nop $1234,x ; 1c 34 12 +; nop $1234,x ; 3c 34 12 +; nop $1234,x ; 5c 34 12 +; nop $1234,x ; 7c 34 12 +; nop $1234,x ; dc 34 12 +; nop $1234,x ; fc 34 12 +; nop $12 ; 44 12 +; nop $12 ; 64 12 +; nop #$12 ; 80 12 +; nop #$12 ; 82 12 +; nop #$12 ; 89 12 +; nop #$12 ; c2 12 +; nop #$12 ; e2 12 +; nop $12,x ; 14 12 +; nop $12,x ; 34 12 +; nop $12,x ; 54 12 +; nop $12,x ; 74 12 +; nop $12,x ; d4 12 +; nop $12,x ; f4 12 +; nop ; 1a +; nop ; 3a +; nop ; 5a +; nop ; 7a +; nop ; da + +; jam ; 02 +; jam ; 12 +; jam ; 22 +; jam ; 32 +; jam ; 42 +; jam ; 52 +; jam ; 62 +; jam ; 72 +; jam ; 92 +; jam ; b2 +; jam ; d2 +; jam ; f2 + + ;sbc #$12 ; eb 12 + +; and the so called "unstable" ones: + + las $1234,y ; bb 34 12 + +; sha $1234,y ; 9f 34 12 +; sha ($12),y ; 93 12 + +; shs $1234,y ; 9b 34 12 + +; shx $1234,y ; 9e 34 12 + +; shy $1234,x ; 9c 34 12 + +; the two "highly unstable" ones: + +; lax #$12 ; ab 12 + +; ane #$12 ; 8b 12 diff --git a/testcode/assembler/legal.ref b/testcode/assembler/legal.ref new file mode 100644 index 000000000..4e9f5c45d Binary files /dev/null and b/testcode/assembler/legal.ref differ diff --git a/testcode/assembler/legal.s b/testcode/assembler/legal.s new file mode 100644 index 000000000..379d6cd3a --- /dev/null +++ b/testcode/assembler/legal.s @@ -0,0 +1,184 @@ + adc $1234 ; 6d 34 12 + adc $1234,x ; 7d 34 12 + adc $1234,y ; 79 34 12 + adc $12 ; 65 12 + adc #$12 ; 69 12 + adc ($12,x) ; 61 12 + adc $12,x ; 75 12 + adc ($12),y ; 71 12 + + and $12 ; 25 12 + and #$12 ; 29 12 + and $1234 ; 2d 34 12 + and $1234,x ; 3d 34 12 + and $1234,y ; 39 34 12 + and ($12,x) ; 21 12 + and $12,x ; 35 12 + and ($12),y ; 31 12 + + asl $12 ; 06 12 + asl $1234 ; 0e 34 12 + asl $1234,x ; 1e 34 12 + asl $12,x ; 16 12 + asl a ; 0a + + bcc *+$12 ; 90 12 + bcs *+$12 ; b0 12 + beq *+$12 ; f0 12 + + bit $12 ; 24 12 + bit $1234 ; 2c 34 12 + + bmi *+$12 ; 30 12 + bne *+$12 ; d0 12 + bpl *+$12 ; 10 12 + + brk ; 00 + + bvc *+$12 ; 50 12 + bvs *+$12 ; 70 12 + + clc ; 18 + cld ; d8 + cli ; 58 + clv ; b8 + + cmp $1234 ; cd 34 12 + cmp $1234,x ; dd 34 12 + cmp $1234,y ; d9 34 12 + cmp $12 ; c5 12 + cmp #$12 ; c9 12 + cmp ($12,x) ; c1 12 + cmp $12,x ; d5 12 + cmp ($12),y ; d1 12 + + cpx $1234 ; ec 34 12 + cpx #$12 ; e0 12 + cpx $12 ; e4 12 + + cpy $1234 ; cc 34 12 + cpy #$12 ; c0 12 + cpy $12 ; c4 12 + + dec $1234 ; ce 34 12 + dec $1234,x ; de 34 12 + dec $12 ; c6 12 + dec $12,x ; d6 12 + + dex ; ca + dey ; 88 + + eor $1234 ; 4d 34 12 + eor $1234,x ; 5d 34 12 + eor $1234,y ; 59 34 12 + eor $12 ; 45 12 + eor #$12 ; 49 12 + eor ($12,x) ; 41 12 + eor $12,x ; 55 12 + eor ($12),y ; 51 12 + + inc $1234 ; ee 34 12 + inc $1234,x ; fe 34 12 + inc $12 ; e6 12 + inc $12,x ; f6 12 + + inx ; e8 + iny ; c8 + + jmp $1234 ; 4c 34 12 + jmp ($1234) ; 6c 34 12 + + jsr $1234 ; 20 34 12 + + lda $1234 ; ad 34 12 + lda $1234,x ; bd 34 12 + lda $1234,y ; b9 34 12 + lda $12 ; a5 12 + lda #$12 ; a9 12 + lda ($12,x) ; a1 12 + lda $12,x ; b5 12 + lda ($12),y ; b1 12 + + ldx $1234 ; ae 34 12 + ldx $1234,y ; be 34 12 + ldx #$12 ; a2 12 + ldx $12 ; a6 12 + ldx $12,y ; b6 12 + + ldy $1234 ; ac 34 12 + ldy $1234,x ; bc 34 12 + ldy #$12 ; a0 12 + ldy $12 ; a4 12 + ldy $12,x ; b4 12 + + lsr $1234 ; 4e 34 12 + lsr $1234,x ; 5e 34 12 + lsr $12 ; 46 12 + lsr $12,x ; 56 12 + lsr a ; 4a + + nop ; ea + + ora $12 ; 05 12 + ora #$12 ; 09 12 + ora $1234 ; 0d 34 12 + ora $1234,x ; 1d 34 12 + ora $1234,y ; 19 34 12 + ora ($12,x) ; 01 12 + ora $12,x ; 15 12 + ora ($12),y ; 11 12 + + pha ; 48 + php ; 08 + pla ; 68 + plp ; 28 + + rol $12 ; 26 12 + rol $1234 ; 2e 34 12 + rol $1234,x ; 3e 34 12 + rol $12,x ; 36 12 + rol a ; 2a + ror $1234 ; 6e 34 12 + ror $1234,x ; 7e 34 12 + ror $12 ; 66 12 + ror $12,x ; 76 12 + ror a ; 6a + + rti ; 40 + rts ; 60 + + sbc $1234 ; ed 34 12 + sbc $1234,x ; fd 34 12 + sbc $1234,y ; f9 34 12 + sbc $12 ; e5 12 + sbc #$12 ; e9 12 + sbc ($12,x) ; e1 12 + sbc $12,x ; f5 12 + sbc ($12),y ; f1 12 + + sec ; 38 + sed ; f8 + sei ; 78 + + sta $1234 ; 8d 34 12 + sta $1234,x ; 9d 34 12 + sta $1234,y ; 99 34 12 + sta $12 ; 85 12 + sta ($12,x) ; 81 12 + sta $12,x ; 95 12 + sta ($12),y ; 91 12 + + stx $1234 ; 8e 34 12 + stx $12 ; 86 12 + stx $12,y ; 96 12 + + sty $1234 ; 8c 34 12 + sty $12 ; 84 12 + sty $12,x ; 94 12 + + tax ; aa + tay ; a8 + tsx ; ba + txa ; 8a + txs ; 9a + tya ; 98