]> git.sur5r.net Git - cc65/commitdiff
Merge pull request #402 from IrgendwerA8/runtime_improvements
authorOliver Schmidt <ol.sc@web.de>
Mon, 20 Mar 2017 10:34:06 +0000 (11:34 +0100)
committerGitHub <noreply@github.com>
Mon, 20 Mar 2017 10:34:06 +0000 (11:34 +0100)
few 6502 and some 65SC02 runtime optimizations

105 files changed:
.gitattributes [new file with mode: 0644]
.travis.yml
asminc/creativision.inc
asminc/opcodes.inc
asminc/smc.inc
asminc/telestrat.inc
cfg/creativision.cfg
doc/cc65.sgml
doc/telestrat.sgml
include/osic1p.h
include/zlib.h
libsrc/Makefile
libsrc/c64/emd/c64-65816.s
libsrc/creativision/clrscr.s
libsrc/creativision/cputc.s
libsrc/creativision/crt0.s
libsrc/creativision/joy/creativision-stdjoy.s
libsrc/creativision/mainargs.s [deleted file]
libsrc/osic1p/cgetc.s
libsrc/osic1p/osic1p.inc
libsrc/osic1p/osiscreen.inc
libsrc/telestrat/clrscr.s [new file with mode: 0644]
libsrc/telestrat/gotox.s [new file with mode: 0644]
libsrc/telestrat/gotoxy.s [new file with mode: 0644]
libsrc/telestrat/gotoy.s [new file with mode: 0644]
libsrc/telestrat/wherex.s [new file with mode: 0644]
libsrc/telestrat/wherey.s [new file with mode: 0644]
samples/Makefile
src/cc65/compile.c
src/cc65/datatype.c
src/cc65/declare.c
src/cc65/symtab.c
src/sim65/6502.c
test/Makefile
test/asm/4510-cpudetect.ref [new file with mode: 0644]
test/asm/4510-opcodes.ref [new file with mode: 0644]
test/asm/4510-opcodes.s [new file with mode: 0644]
test/asm/6502-cpudetect.ref [new file with mode: 0644]
test/asm/6502-opcodes.ref [new file with mode: 0644]
test/asm/6502-opcodes.s [new file with mode: 0644]
test/asm/6502x-cpudetect.ref [new file with mode: 0644]
test/asm/6502x-opcodes.ref [new file with mode: 0644]
test/asm/6502x-opcodes.s [new file with mode: 0644]
test/asm/65816-cpudetect.ref [new file with mode: 0644]
test/asm/65c02-cpudetect.ref [new file with mode: 0644]
test/asm/65c02-opcodes.ref [new file with mode: 0644]
test/asm/65c02-opcodes.s [new file with mode: 0644]
test/asm/65sc02-cpudetect.ref [new file with mode: 0644]
test/asm/65sc02-opcodes.ref [new file with mode: 0644]
test/asm/65sc02-opcodes.s [new file with mode: 0644]
test/asm/Makefile [new file with mode: 0644]
test/asm/README [new file with mode: 0644]
test/asm/cpudetect.s [new file with mode: 0644]
test/asm/huc6280-cpudetect.ref [new file with mode: 0644]
test/asm/huc6280-opcodes.ref [new file with mode: 0644]
test/asm/huc6280-opcodes.s [new file with mode: 0644]
test/asm/m740-opcodes.s [new file with mode: 0644]
test/assembler/.gitignore [deleted file]
test/assembler/4510-cpudetect.ref [deleted file]
test/assembler/4510-opcodes.ref [deleted file]
test/assembler/4510-opcodes.s [deleted file]
test/assembler/6502-cpudetect.ref [deleted file]
test/assembler/6502-opcodes.ref [deleted file]
test/assembler/6502-opcodes.s [deleted file]
test/assembler/6502x-cpudetect.ref [deleted file]
test/assembler/6502x-opcodes.ref [deleted file]
test/assembler/6502x-opcodes.s [deleted file]
test/assembler/65816-cpudetect.ref [deleted file]
test/assembler/65c02-cpudetect.ref [deleted file]
test/assembler/65c02-opcodes.ref [deleted file]
test/assembler/65c02-opcodes.s [deleted file]
test/assembler/65sc02-cpudetect.ref [deleted file]
test/assembler/65sc02-opcodes.ref [deleted file]
test/assembler/65sc02-opcodes.s [deleted file]
test/assembler/Makefile [deleted file]
test/assembler/README [deleted file]
test/assembler/cpudetect.s [deleted file]
test/assembler/huc6280-cpudetect.ref [deleted file]
test/assembler/huc6280-opcodes.ref [deleted file]
test/assembler/huc6280-opcodes.s [deleted file]
test/assembler/m740-opcodes.s [deleted file]
test/dasm/4510-disass.s [new file with mode: 0644]
test/dasm/Makefile [new file with mode: 0644]
test/disassembler/4510-disass.s [deleted file]
test/disassembler/Makefile [deleted file]
test/err/Makefile
test/err/duplicate-global-static.c [new file with mode: 0644]
test/err/duplicate-global.c [new file with mode: 0644]
test/err/duplicate-static-global.c [new file with mode: 0644]
test/err/duplicate-static.c [new file with mode: 0644]
test/err/void-empty.c [new file with mode: 0644]
test/err/void-size2.c [new file with mode: 0644]
test/misc/Makefile
test/ref/Makefile
test/ref/divmod.c
test/ref/init.c
test/ref/pointer2.c
test/ref/switch2.c
test/ref/varargs.c
test/ref/yacc.c
test/val/Makefile
test/val/static-fwd-decl.c [new file with mode: 0644]
test/val/void-size1.c [new file with mode: 0644]
testcode/lib/atari/displaylist.c
testcode/lib/mul-test.c

diff --git a/.gitattributes b/.gitattributes
new file mode 100644 (file)
index 0000000..176a458
--- /dev/null
@@ -0,0 +1 @@
+* text=auto
index 10ea789cf3fbf9616a33db124139758c4643348c..fd2672887a527e682be8fb40e485a989f5a86e0e 100644 (file)
@@ -6,7 +6,7 @@ install:
 script:
   - make bin USER_CFLAGS=-Werror
   - make lib QUIET=1
-  - make -C test
+  - make -C test QUIET=1
   - make -C src clean
   - make bin USER_CFLAGS=-Werror CROSS_COMPILE=i686-w64-mingw32-
   - make doc zip
index 59b26101bbfcf9ce89b3aed80ad7a314aa930b00..49d55a3425362572563cda823af5d728bffa9d8c 100644 (file)
@@ -10,10 +10,10 @@ CURSOR_X                = $3C
 CURSOR_Y                = $3D
 
 ;** VDP
-VDP_CONTROL_W           = $3001
-VDP_DATA_W              = $3000
-VDP_STATUS_R            = $2001
 VDP_DATA_R              = $2000
+VDP_STATUS_R            = $2001
+VDP_DATA_W              = $3000
+VDP_CONTROL_W           = $3001
 
 ;** PIA
 PIA0_DATA               = $1000
@@ -36,7 +36,26 @@ ZP_JOY1_DIR             = $13
 ZP_JOY0_BUTTONS         = $16
 ZP_JOY1_BUTTONS         = $17
 
+;** Joystick direction values (ZP_JOY0_DIR/ZP_JOY1_DIR)
+JOY_N                   = $49
+JOY_NNE                 = $48
+JOY_NE                  = $47
+JOY_ENE                 = $46
+JOY_E                   = $45
+JOY_ESE                 = $44
+JOY_SE                  = $43
+JOY_SSE                 = $42
+JOY_S                   = $41
+JOY_SSW                 = $40
+JOY_SW                  = $4F
+JOY_WSW                 = $4E
+JOY_W                   = $4D
+JOY_WNW                 = $4C
+JOY_NW                  = $4B
+JOY_NNW                 = $4A
+
 ;** BIOS
 BIOS_IRQ1_ADDR          = $FF3F
 BIOS_IRQ2_ADDR          = $FF52
 BIOS_NMI_RESET_ADDR     = $F808
+BIOS_WRITE_VDP_REG      = $FE1F
index 7c52871d2afbb01cc06b5910361c22286a0ead26..96cdefb65e2e99f640fa69bf743d27b4a01381aa 100644 (file)
-; opcodes.inc\r
-; ca65 6502 - opcode definitions, mainly for self modifying code\r
-;\r
-; Christian Krüger, latest change: 18-Sep-2010\r
-;\r
-; This software is provided 'as-is', without any expressed or implied      \r
-; warranty.  In no event will the authors be held liable for any damages   \r
-; arising from the use of this software.                                   \r
-;                                                                          \r
-; Permission is granted to anyone to use this software for any purpose,    \r
-; including commercial applications, and to alter it and redistribute it   \r
-; freely, subject to the following restrictions:                           \r
-;                                                                          \r
-; 1. The origin of this software must not be misrepresented; you must not  \r
-;    claim that you wrote the original software. If you use this software  \r
-;    in a product, an acknowledgment in the product documentation would be \r
-;    appreciated but is not required.                                      \r
-; 2. Altered source versions must be plainly marked as such, and must not  \r
-;    be misrepresented as being the original software.                     \r
-; 3. This notice may not be removed or altered from any source             \r
-;    distribution.                                                         \r
-;                                                                          \r
-\r
-; Opcode-Table\r
-; ------------\r
-; Post fix explanation:\r
-; imm = #$00\r
-; zp = $00\r
-; zpx = $00,X\r
-; zpy = $00,Y\r
-; izp = ($00)\r
-; izx = ($00,X)\r
-; izy = ($00),Y\r
-; abs = $0000\r
-; abx = $0000,X\r
-; aby = $0000,Y\r
-; ind = ($0000)\r
-; iax = ($0000,X)\r
-; rel = $0000 (PC-relative) (supressed here)\r
-\r
-.macpack        cpu\r
-\r
-OPC_BRK     = $00\r
-OPC_ORA_izx = $01\r
-OPC_ORA_zp  = $05\r
-OPC_ASL_zp  = $06\r
-OPC_PHP     = $08\r
-OPC_ORA_imm = $09\r
-OPC_ASL     = $0A\r
-OPC_ORA_abs = $0D\r
-OPC_ASL_abs = $0E\r
-\r
-OPC_BPL     = $10\r
-OPC_ORA_izy = $11\r
-OPC_ORA_zpx = $15\r
-OPC_ASL_zpx = $16\r
-OPC_CLC     = $18\r
-OPC_ORA_aby = $19\r
-OPC_ORA_abx = $1D\r
-OPC_ASL_abx = $1E\r
-\r
-OPC_JSR_abs = $20\r
-OPC_AND_izx = $21\r
-OPC_BIT_zp  = $24\r
-OPC_AND_zp  = $25\r
-OPC_ROL_zp  = $26\r
-OPC_PLP     = $28\r
-OPC_AND_imm = $29\r
-OPC_ROL     = $2A\r
-OPC_BIT_abs = $2C\r
-OPC_AND_abs = $2D\r
-OPC_ROL_abs = $2E\r
-\r
-OPC_BMI     = $30\r
-OPC_AND_izy = $31\r
-OPC_AND_zpx = $35\r
-OPC_ROL_zpx = $36\r
-OPC_SEC     = $38\r
-OPC_AND_aby = $39\r
-OPC_AND_abx = $3D\r
-OPC_ROL_abx = $3E\r
-\r
-\r
-OPC_RTI     = $40\r
-OPC_EOR_izx = $41\r
-OPC_EOR_zp  = $45\r
-OPC_LSR_zp  = $46\r
-OPC_PHA     = $48\r
-OPC_EOR_imm = $49\r
-OPC_LSR     = $4A\r
-OPC_JMP_abs = $4C\r
-OPC_EOR_abs = $4D\r
-OPC_LSR_abs = $4E\r
-\r
-OPC_BVC     = $50\r
-OPC_EOR_izy = $51\r
-OPC_EOR_zpx = $55\r
-OPC_LSR_zpx = $56\r
-OPC_CLI     = $58\r
-OPC_EOR_aby = $59\r
-OPC_EOR_abx = $5D\r
-OPC_LSR_abx = $5E\r
-\r
-OPC_RTS     = $60\r
-OPC_ADC_izx = $61\r
-OPC_ADC_zp  = $65\r
-OPC_ROR_zp  = $66\r
-OPC_PLA     = $68\r
-OPC_ADC_imm = $69\r
-OPC_ROR     = $6A\r
-OPC_JMP_ind = $6C\r
-OPC_ADC_abs = $6D\r
-OPC_ROR_abs = $6E\r
-\r
-OPC_BVS     = $70\r
-OPC_ADC_izy = $71\r
-OPC_ADC_zpx = $75\r
-OPC_ROR_zpx = $76\r
-OPC_SEI     = $78\r
-OPC_ADC_aby = $79\r
-OPC_ADC_abx = $7D\r
-OPC_ROR_abx = $7E\r
-\r
-OPC_STA_izx = $81\r
-OPC_STY_zp  = $84\r
-OPC_STA_zp  = $85\r
-OPC_STX_zp  = $86\r
-OPC_DEY     = $88\r
-OPC_TXA     = $8A\r
-OPC_STY_abs = $8C\r
-OPC_STA_abs = $8D\r
-OPC_STX_abs = $8E\r
-\r
-OPC_BCC     = $90\r
-OPC_STA_izy = $91\r
-OPC_STY_zpx = $94\r
-OPC_STA_zpx = $95\r
-OPC_STX_zpy = $96\r
-OPC_TYA     = $98\r
-OPC_STA_aby = $99\r
-OPC_TXS     = $9A\r
-OPC_STA_abx = $9D\r
-\r
-OPC_LDY_imm = $A0\r
-OPC_LDA_izx = $A1\r
-OPC_LDX_imm = $A2\r
-OPC_LDY_zp  = $A4\r
-OPC_LDA_zp  = $A5\r
-OPC_LDX_zp  = $A6\r
-OPC_TAY     = $A8\r
-OPC_LDA_imm = $A9\r
-OPC_TAX     = $AA\r
-OPC_LDY_abs = $AC\r
-OPC_LDA_abs = $AD\r
-OPC_LDX_abs = $AE\r
-\r
-OPC_BCS     = $B0\r
-OPC_LDA_izy = $B1\r
-OPC_LDY_zpx = $B4\r
-OPC_LDA_zpx = $B5\r
-OPC_LDX_zpy = $B6\r
-OPC_CLV     = $B8\r
-OPC_LDA_aby = $B9\r
-OPC_TSX     = $BA\r
-OPC_LDY_abx = $BC\r
-OPC_LDA_abx = $BD\r
-OPC_LDX_aby = $BE\r
-\r
-OPC_CPY_imm = $C0\r
-OPC_CMP_izx = $C1\r
-OPC_CPY_zp  = $C4\r
-OPC_CMP_zp  = $C5\r
-OPC_DEC_zp  = $C6\r
-OPC_INY     = $C8\r
-OPC_CMP_imm = $C9\r
-OPC_DEX     = $CA\r
-OPC_CPY_abs = $CC\r
-OPC_CMP_abs = $CD\r
-OPC_DEC_abs = $CE\r
-\r
-OPC_BNE     = $D0\r
-OPC_CMP_izy = $D1\r
-OPC_CMP_zpx = $D5\r
-OPC_DEC_zpx = $D6\r
-OPC_CLD     = $D8\r
-OPC_CMP_aby = $D9\r
-OPC_CMP_abx = $DD\r
-OPC_DEC_abx = $DE\r
-\r
-OPC_CPX_imm = $E0\r
-OPC_SBC_izx = $E1\r
-OPC_CPX_zp  = $E4\r
-OPC_SBC_zp  = $E5\r
-OPC_INC_zp  = $E6\r
-OPC_INX     = $E8\r
-OPC_SBC_imm = $E9\r
-OPC_NOP     = $EA\r
-OPC_CPX_abs = $EC\r
-OPC_SBC_abs = $ED\r
-OPC_INC_abs = $EE\r
-\r
-\r
-OPC_BEQ     = $F0\r
-OPC_SBC_izy = $F1\r
-OPC_SBC_zpx = $F5\r
-OPC_INC_zpx = $F6\r
-OPC_SED     = $F8\r
-OPC_SBC_aby = $F9\r
-OPC_SBC_abx = $FD\r
-OPC_INC_abx = $FE\r
-\r
-\r
-.if (.cpu .bitand ::CPU_ISET_65SC02)\r
-\r
-; OPC_NOP   = $02               ; doublet\r
-; OPC_NOP   = $03               ; doublet\r
-OPC_TSB_zp  = $04\r
-; OPC_NOP   = $0B               ; doublet\r
-OPC_TSB_abs = $0C\r
-\r
-OPC_ORA_izp = $12\r
-; OPC_NOP   = $13               ; doublet\r
-OPC_TRB_zp  = $14\r
-OPC_INC     = $1A\r
-; OPC_NOP   = $1B               ; doublet\r
-OPC_TRB_abs = $1C\r
-\r
-; OPC_NOP   = $22               ; doublet\r
-; OPC_NOP   = $23               ; doublet\r
-; OPC_NOP   = $2B               ; doublet\r
-\r
-OPC_AND_izp = $32\r
-; OPC_NOP   = $33               ; doublet\r
-OPC_BIT_zpx = $34\r
-OPC_DEC     = $3A\r
-; OPC_NOP   = $3B               ; doublet\r
-OPC_BIT_abx = $3C\r
-\r
-; OPC_NOP   = $42               ; doublet\r
-; OPC_NOP   = $43               ; doublet\r
-; OPC_NOP   = $44               ; doublet\r
-; OPC_NOP   = $4B               ; doublet\r
-\r
-OPC_EOR_izp = $52               \r
-; OPC_NOP   = $53               ; doublet\r
-; OPC_NOP   = $54               ; doublet\r
-; OPC_NOP   = $5A               ; doublet\r
-; OPC_NOP   = $5B               ; doublet\r
-OPC_EOR_abx = $5C\r
-\r
-; OPC_NOP   = $62               ; doublet\r
-; OPC_NOP   = $63               ; doublet\r
-OPC_STZ_zp  = $64\r
-; OPC_NOP   = $6B               ; doublet\r
-\r
-OPC_ADC_izp = $72\r
-; OPC_NOP   = $73               ; doublet\r
-OPC_STZ_zpx = $74\r
-OPC_PLY     = $7A\r
-; OPC_NOP   = $7B               ; doublet\r
-OPC_JMP_iax = $7C\r
-\r
-OPC_BRA     = $80\r
-; OPC_NOP   = $82               ; doublet\r
-; OPC_NOP   = $83               ; doublet\r
-OPC_BIT_imm = $89\r
-; OPC_NOP   = $8B               ; doublet\r
-\r
-OPC_STA_izp = $92\r
-; OPC_NOP   = $93               ; doublet\r
-; OPC_NOP   = $9B               ; doublet\r
-OPC_STZ_abs = $9C\r
-OPC_STZ_abx = $9E\r
-\r
-; OPC_NOP   = $A3               ; doublet\r
-; OPC_NOP   = $AB               ; doublet\r
-\r
-OPC_LDA_izp = $B2\r
-; OPC_NOP   = $B3               ; doublet\r
-; OPC_NOP   = $BB               ; doublet\r
-\r
-; OPC_NOP   = $C2               ; doublet\r
-; OPC_NOP   = $C3               ; doublet\r
-; OPC_NOP   = $CB               ; doublet\r
-\r
-OPC_CMP_izp = $D2\r
-; OPC_NOP   = $D3               ; doublet\r
-; OPC_NOP   = $D4               ; doublet\r
-OPC_PHX     = $DA\r
-; OPC_NOP   = $DB               ; doublet\r
-; OPC_NOP   = $DC               ; doublet\r
-\r
-; OPC_NOP   = $E2               ; doublet\r
-; OPC_NOP   = $E3               ; doublet\r
-; OPC_NOP   = $EB               ; doublet\r
-\r
-OPC_SBC_izp = $F2\r
-; OPC_NOP   = $F3               ; doublet\r
-; OPC_NOP   = $F4               ; doublet\r
-OPC_PLX     = $FA\r
-; OPC_NOP   = $FB               ; doublet\r
-; OPC_NOP   = $FC               ; doublet\r
-\r
-\r
-.if (.cpu .bitand ::CPU_ISET_65C02)\r
-\r
-; bit instructions for 65C02\r
-\r
-OPC_RMB0    = $07\r
-OPC_RMB1    = $17\r
-OPC_RMB2    = $27\r
-OPC_RMB3    = $37\r
-OPC_RMB4    = $47\r
-OPC_RMB5    = $57\r
-OPC_RMB6    = $67\r
-OPC_RMB7    = $77\r
-\r
-OPC_SMB0    = $87\r
-OPC_SMB1    = $97\r
-OPC_SMB2    = $A7\r
-OPC_SMB3    = $B7\r
-OPC_SMB4    = $C7\r
-OPC_SMB5    = $D7\r
-OPC_SMB6    = $E7\r
-OPC_SMB7    = $F7\r
-\r
-OPC_BBR0    = $0F\r
-OPC_BBR1    = $1F\r
-OPC_BBR2    = $2F\r
-OPC_BBR3    = $3F\r
-OPC_BBR4    = $4F\r
-OPC_BBR5    = $5F\r
-OPC_BBR6    = $6F\r
-OPC_BBR7    = $7F\r
-\r
-OPC_BBS0    = $8F\r
-OPC_BBS1    = $9F\r
-OPC_BBS2    = $AF\r
-OPC_BBS3    = $BF\r
-OPC_BBS4    = $CF\r
-OPC_BBS5    = $DF\r
-OPC_BBS6    = $EF\r
-OPC_BBS7    = $FF\r
-\r
-.else\r
-\r
-; no bit instructions for 65SC02\r
-\r
-; OPC_NOP   = $07               ; doublet\r
-; OPC_NOP   = $17               ; doublet\r
-; OPC_NOP   = $27               ; doublet\r
-; OPC_NOP   = $37               ; doublet\r
-; OPC_NOP   = $47               ; doublet\r
-; OPC_NOP   = $57               ; doublet\r
-; OPC_NOP   = $67               ; doublet\r
-; OPC_NOP   = $77               ; doublet\r
-; OPC_NOP   = $87               ; doublet\r
-; OPC_NOP   = $97               ; doublet\r
-; OPC_NOP   = $A7               ; doublet\r
-; OPC_NOP   = $B7               ; doublet\r
-; OPC_NOP   = $C7               ; doublet\r
-; OPC_NOP   = $D7               ; doublet\r
-; OPC_NOP   = $E7               ; doublet\r
-; OPC_NOP   = $F7               ; doublet\r
-; OPC_NOP   = $0F               ; doublet\r
-; OPC_NOP   = $1F               ; doublet\r
-; OPC_NOP   = $2F               ; doublet\r
-; OPC_NOP   = $3F               ; doublet\r
-; OPC_NOP   = $4F               ; doublet\r
-; OPC_NOP   = $5F               ; doublet\r
-; OPC_NOP   = $6F               ; doublet\r
-; OPC_NOP   = $7F               ; doublet\r
-; OPC_NOP   = $8F               ; doublet\r
-; OPC_NOP   = $9F               ; doublet\r
-; OPC_NOP   = $AF               ; doublet\r
-; OPC_NOP   = $BF               ; doublet\r
-; OPC_NOP   = $CF               ; doublet\r
-; OPC_NOP   = $DF               ; doublet\r
-; OPC_NOP   = $EF               ; doublet\r
-; OPC_NOP   = $FF               ; doublet\r
-\r
-.endif\r
-\r
-.elseif (.cpu .bitand ::CPU_ISET_6502X)\r
-\r
-; stable, undocumented opcodes\r
-\r
-; OPC_KIL   = $02               ; unstable\r
-OPC_SLO_izx = $03\r
-OPC_NOP_zp  = $04\r
-OPC_SLO_zp  = $07\r
-OPC_ANC_imm = $0B\r
-OPC_NOP_abs = $0C\r
-OPC_SLO_abs = $0F\r
-\r
-; OPC_KIL   = $12               ; unstable\r
-OPC_SLO_izy = $13\r
-OPC_NOP_zpx = $14\r
-OPC_SLO_zpx = $17\r
-;OPC_NOP    = $1A\r
-OPC_SLO_aby = $1B\r
-OPC_NOP_abx = $1C\r
-OPC_SLO_abx = $1F\r
-\r
-; OPC_KIL   = $22               ; unstable\r
-OPC_RLA_izx = $23\r
-OPC_RLA_zp  = $27\r
-OPC_ANC_imm = $2B\r
-OPC_RLA_abs = $2F\r
-\r
-; OPC_KIL   = $32               ; unstable\r
-OPC_RLA_izy = $33\r
-OPC_NOP_zpx = $34\r
-OPC_RLA_zpx = $37\r
-; OPC_NOP   = $3A               ; doublet\r
-OPC_RLA_aby = $3B\r
-OPC_NOP_abx = $3C\r
-OPC_RLA_abx = $3F\r
-\r
-; OPC_KIL   = $42               ; unstable\r
-OPC_SRE_izx = $43\r
-OPC_NOP_zp  = $44\r
-OPC_SRE_zp  = $47\r
-OPC_ALR_imm = $4B\r
-OPC_SRE_abs = $4F\r
-\r
-; OPC_KIL   = $52               ; unstable\r
-OPC_SRE_izy = $53\r
-OPC_NOP_zpx = $54\r
-OPC_SRE_zpx = $57\r
-; OPC_NOP   = $5A               ; doublet\r
-OPC_SRE_aby = $5B\r
-OPC_NOP_abx = $5C\r
-OPC_SRE_abx = $5F\r
-\r
-; OPC_KIL   = $62\r
-OPC_RRA_izx = $63\r
-OPC_NOP_zp  = $64\r
-OPC_RRA_zp  = $67\r
-OPC_ARR_imm = $6B\r
-OPC_RRA_abs = $6F\r
-\r
-; OPC_KIL   = $72\r
-OPC_RRA_izy = $73\r
-OPC_NOP_zpx = $74\r
-OPC_RRA_zpx = $77\r
-; OPC_NOP   = $7A               ; doublet\r
-OPC_RRA_aby = $7B\r
-OPC_NOP_abx = $7C\r
-OPC_RRA_abx = $7F\r
-\r
-OPC_NOP_imm = $80\r
-; OPC_NOP_imm = $82             ; doublet\r
-OPC_SAX_izx = $83\r
-OPC_SAX_zp  = $87\r
-; OPC_NOP_imm = $89             ; doublet\r
-; OPC_XAA = $8B                 ; unstable\r
-OPC_SAX_abs = $8F\r
-\r
-; OPC_KIL   = $92               ; unstable\r
-; OPC_AHX_izy = $93             ; unstable\r
-OPC_SAX_zpy = $97\r
-; OPC_TAS_aby = $9B             ; unstable\r
-; OPC_SHY_abx = $9C             ; unstable\r
-; OPC_SHX_aby = $9E             ; unstable\r
-; OPC_AHX_aby = $9F             ; unstable\r
-\r
-OPC_LAX_izx = $A3\r
-OPC_LAX_zp  = $A7\r
-; OPC_LAX_imm = $AB             ; unstable\r
-OPC_LAX_abs = $AF\r
-\r
-; OPC_KIL   = $B2               ; unstable\r
-OPC_LAX_izy = $B3\r
-OPC_LAX_zpy = $B7\r
-OPC_LAS_aby = $BB\r
-OPC_LAX_aby = $BF\r
-\r
-; OPC_NOP_imm = $C2             ; doublet\r
-OPC_DCP_izx = $C3\r
-OPC_DCP_zp  = $C7\r
-OPC_AXS_imm = $CB\r
-OPC_DCP_abs = $CF\r
-\r
-; OPC_KIL   = $D2               ; unstable\r
-OPC_DCP_izy = $D3\r
-OPC_NOP_zpx = $D4\r
-OPC_DCP_zpx = $D7\r
-OPC_NOP_DA  = $DA\r
-OPC_DCP_aby = $DB\r
-OPC_NOP_abx = $DC\r
-OPC_DCP_abx = $DF\r
-\r
-; OPC_NOP_imm = $E2             ; doublet\r
-OPC_ISC_izx = $E3\r
-OPC_ISC_zp  = $E7\r
-; OPC_SBC_imm = $EB             ; doublet\r
-OPC_ISC_abs = $EF\r
-\r
-; OPC_KIL   = $F2               ; unstable\r
-OPC_ISC_izy = $F3\r
-OPC_NOP_zpx = $F4\r
-OPC_ISC_zpx = $F7\r
-OPC_NOP_FA  = $FA\r
-OPC_ISC_aby = $FB\r
-OPC_NOP_abx = $FC\r
-OPC_ISC_abx = $FF\r
-\r
-.endif\r
+; opcodes.inc
+; ca65 6502 - opcode definitions, mainly for self modifying code
+;
+; Christian Krüger, latest change: 18-Sep-2010
+;
+; This software is provided 'as-is', without any expressed or implied      
+; warranty.  In no event will the authors be held liable for any damages   
+; arising from the use of this software.                                   
+;                                                                          
+; Permission is granted to anyone to use this software for any purpose,    
+; including commercial applications, and to alter it and redistribute it   
+; freely, subject to the following restrictions:                           
+;                                                                          
+; 1. The origin of this software must not be misrepresented; you must not  
+;    claim that you wrote the original software. If you use this software  
+;    in a product, an acknowledgment in the product documentation would be 
+;    appreciated but is not required.                                      
+; 2. Altered source versions must be plainly marked as such, and must not  
+;    be misrepresented as being the original software.                     
+; 3. This notice may not be removed or altered from any source             
+;    distribution.                                                         
+;                                                                          
+
+; Opcode-Table
+; ------------
+; Post fix explanation:
+; imm = #$00
+; zp = $00
+; zpx = $00,X
+; zpy = $00,Y
+; izp = ($00)
+; izx = ($00,X)
+; izy = ($00),Y
+; abs = $0000
+; abx = $0000,X
+; aby = $0000,Y
+; ind = ($0000)
+; iax = ($0000,X)
+; rel = $0000 (PC-relative) (supressed here)
+
+.macpack        cpu
+
+OPC_BRK     = $00
+OPC_ORA_izx = $01
+OPC_ORA_zp  = $05
+OPC_ASL_zp  = $06
+OPC_PHP     = $08
+OPC_ORA_imm = $09
+OPC_ASL     = $0A
+OPC_ORA_abs = $0D
+OPC_ASL_abs = $0E
+
+OPC_BPL     = $10
+OPC_ORA_izy = $11
+OPC_ORA_zpx = $15
+OPC_ASL_zpx = $16
+OPC_CLC     = $18
+OPC_ORA_aby = $19
+OPC_ORA_abx = $1D
+OPC_ASL_abx = $1E
+
+OPC_JSR_abs = $20
+OPC_AND_izx = $21
+OPC_BIT_zp  = $24
+OPC_AND_zp  = $25
+OPC_ROL_zp  = $26
+OPC_PLP     = $28
+OPC_AND_imm = $29
+OPC_ROL     = $2A
+OPC_BIT_abs = $2C
+OPC_AND_abs = $2D
+OPC_ROL_abs = $2E
+
+OPC_BMI     = $30
+OPC_AND_izy = $31
+OPC_AND_zpx = $35
+OPC_ROL_zpx = $36
+OPC_SEC     = $38
+OPC_AND_aby = $39
+OPC_AND_abx = $3D
+OPC_ROL_abx = $3E
+
+
+OPC_RTI     = $40
+OPC_EOR_izx = $41
+OPC_EOR_zp  = $45
+OPC_LSR_zp  = $46
+OPC_PHA     = $48
+OPC_EOR_imm = $49
+OPC_LSR     = $4A
+OPC_JMP_abs = $4C
+OPC_EOR_abs = $4D
+OPC_LSR_abs = $4E
+
+OPC_BVC     = $50
+OPC_EOR_izy = $51
+OPC_EOR_zpx = $55
+OPC_LSR_zpx = $56
+OPC_CLI     = $58
+OPC_EOR_aby = $59
+OPC_EOR_abx = $5D
+OPC_LSR_abx = $5E
+
+OPC_RTS     = $60
+OPC_ADC_izx = $61
+OPC_ADC_zp  = $65
+OPC_ROR_zp  = $66
+OPC_PLA     = $68
+OPC_ADC_imm = $69
+OPC_ROR     = $6A
+OPC_JMP_ind = $6C
+OPC_ADC_abs = $6D
+OPC_ROR_abs = $6E
+
+OPC_BVS     = $70
+OPC_ADC_izy = $71
+OPC_ADC_zpx = $75
+OPC_ROR_zpx = $76
+OPC_SEI     = $78
+OPC_ADC_aby = $79
+OPC_ADC_abx = $7D
+OPC_ROR_abx = $7E
+
+OPC_STA_izx = $81
+OPC_STY_zp  = $84
+OPC_STA_zp  = $85
+OPC_STX_zp  = $86
+OPC_DEY     = $88
+OPC_TXA     = $8A
+OPC_STY_abs = $8C
+OPC_STA_abs = $8D
+OPC_STX_abs = $8E
+
+OPC_BCC     = $90
+OPC_STA_izy = $91
+OPC_STY_zpx = $94
+OPC_STA_zpx = $95
+OPC_STX_zpy = $96
+OPC_TYA     = $98
+OPC_STA_aby = $99
+OPC_TXS     = $9A
+OPC_STA_abx = $9D
+
+OPC_LDY_imm = $A0
+OPC_LDA_izx = $A1
+OPC_LDX_imm = $A2
+OPC_LDY_zp  = $A4
+OPC_LDA_zp  = $A5
+OPC_LDX_zp  = $A6
+OPC_TAY     = $A8
+OPC_LDA_imm = $A9
+OPC_TAX     = $AA
+OPC_LDY_abs = $AC
+OPC_LDA_abs = $AD
+OPC_LDX_abs = $AE
+
+OPC_BCS     = $B0
+OPC_LDA_izy = $B1
+OPC_LDY_zpx = $B4
+OPC_LDA_zpx = $B5
+OPC_LDX_zpy = $B6
+OPC_CLV     = $B8
+OPC_LDA_aby = $B9
+OPC_TSX     = $BA
+OPC_LDY_abx = $BC
+OPC_LDA_abx = $BD
+OPC_LDX_aby = $BE
+
+OPC_CPY_imm = $C0
+OPC_CMP_izx = $C1
+OPC_CPY_zp  = $C4
+OPC_CMP_zp  = $C5
+OPC_DEC_zp  = $C6
+OPC_INY     = $C8
+OPC_CMP_imm = $C9
+OPC_DEX     = $CA
+OPC_CPY_abs = $CC
+OPC_CMP_abs = $CD
+OPC_DEC_abs = $CE
+
+OPC_BNE     = $D0
+OPC_CMP_izy = $D1
+OPC_CMP_zpx = $D5
+OPC_DEC_zpx = $D6
+OPC_CLD     = $D8
+OPC_CMP_aby = $D9
+OPC_CMP_abx = $DD
+OPC_DEC_abx = $DE
+
+OPC_CPX_imm = $E0
+OPC_SBC_izx = $E1
+OPC_CPX_zp  = $E4
+OPC_SBC_zp  = $E5
+OPC_INC_zp  = $E6
+OPC_INX     = $E8
+OPC_SBC_imm = $E9
+OPC_NOP     = $EA
+OPC_CPX_abs = $EC
+OPC_SBC_abs = $ED
+OPC_INC_abs = $EE
+
+
+OPC_BEQ     = $F0
+OPC_SBC_izy = $F1
+OPC_SBC_zpx = $F5
+OPC_INC_zpx = $F6
+OPC_SED     = $F8
+OPC_SBC_aby = $F9
+OPC_SBC_abx = $FD
+OPC_INC_abx = $FE
+
+
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+
+; OPC_NOP   = $02               ; doublet
+; OPC_NOP   = $03               ; doublet
+OPC_TSB_zp  = $04
+; OPC_NOP   = $0B               ; doublet
+OPC_TSB_abs = $0C
+
+OPC_ORA_izp = $12
+; OPC_NOP   = $13               ; doublet
+OPC_TRB_zp  = $14
+OPC_INC     = $1A
+; OPC_NOP   = $1B               ; doublet
+OPC_TRB_abs = $1C
+
+; OPC_NOP   = $22               ; doublet
+; OPC_NOP   = $23               ; doublet
+; OPC_NOP   = $2B               ; doublet
+
+OPC_AND_izp = $32
+; OPC_NOP   = $33               ; doublet
+OPC_BIT_zpx = $34
+OPC_DEC     = $3A
+; OPC_NOP   = $3B               ; doublet
+OPC_BIT_abx = $3C
+
+; OPC_NOP   = $42               ; doublet
+; OPC_NOP   = $43               ; doublet
+; OPC_NOP   = $44               ; doublet
+; OPC_NOP   = $4B               ; doublet
+
+OPC_EOR_izp = $52               
+; OPC_NOP   = $53               ; doublet
+; OPC_NOP   = $54               ; doublet
+; OPC_NOP   = $5A               ; doublet
+; OPC_NOP   = $5B               ; doublet
+OPC_EOR_abx = $5C
+
+; OPC_NOP   = $62               ; doublet
+; OPC_NOP   = $63               ; doublet
+OPC_STZ_zp  = $64
+; OPC_NOP   = $6B               ; doublet
+
+OPC_ADC_izp = $72
+; OPC_NOP   = $73               ; doublet
+OPC_STZ_zpx = $74
+OPC_PLY     = $7A
+; OPC_NOP   = $7B               ; doublet
+OPC_JMP_iax = $7C
+
+OPC_BRA     = $80
+; OPC_NOP   = $82               ; doublet
+; OPC_NOP   = $83               ; doublet
+OPC_BIT_imm = $89
+; OPC_NOP   = $8B               ; doublet
+
+OPC_STA_izp = $92
+; OPC_NOP   = $93               ; doublet
+; OPC_NOP   = $9B               ; doublet
+OPC_STZ_abs = $9C
+OPC_STZ_abx = $9E
+
+; OPC_NOP   = $A3               ; doublet
+; OPC_NOP   = $AB               ; doublet
+
+OPC_LDA_izp = $B2
+; OPC_NOP   = $B3               ; doublet
+; OPC_NOP   = $BB               ; doublet
+
+; OPC_NOP   = $C2               ; doublet
+; OPC_NOP   = $C3               ; doublet
+; OPC_NOP   = $CB               ; doublet
+
+OPC_CMP_izp = $D2
+; OPC_NOP   = $D3               ; doublet
+; OPC_NOP   = $D4               ; doublet
+OPC_PHX     = $DA
+; OPC_NOP   = $DB               ; doublet
+; OPC_NOP   = $DC               ; doublet
+
+; OPC_NOP   = $E2               ; doublet
+; OPC_NOP   = $E3               ; doublet
+; OPC_NOP   = $EB               ; doublet
+
+OPC_SBC_izp = $F2
+; OPC_NOP   = $F3               ; doublet
+; OPC_NOP   = $F4               ; doublet
+OPC_PLX     = $FA
+; OPC_NOP   = $FB               ; doublet
+; OPC_NOP   = $FC               ; doublet
+
+
+.if (.cpu .bitand ::CPU_ISET_65C02)
+
+; bit instructions for 65C02
+
+OPC_RMB0    = $07
+OPC_RMB1    = $17
+OPC_RMB2    = $27
+OPC_RMB3    = $37
+OPC_RMB4    = $47
+OPC_RMB5    = $57
+OPC_RMB6    = $67
+OPC_RMB7    = $77
+
+OPC_SMB0    = $87
+OPC_SMB1    = $97
+OPC_SMB2    = $A7
+OPC_SMB3    = $B7
+OPC_SMB4    = $C7
+OPC_SMB5    = $D7
+OPC_SMB6    = $E7
+OPC_SMB7    = $F7
+
+OPC_BBR0    = $0F
+OPC_BBR1    = $1F
+OPC_BBR2    = $2F
+OPC_BBR3    = $3F
+OPC_BBR4    = $4F
+OPC_BBR5    = $5F
+OPC_BBR6    = $6F
+OPC_BBR7    = $7F
+
+OPC_BBS0    = $8F
+OPC_BBS1    = $9F
+OPC_BBS2    = $AF
+OPC_BBS3    = $BF
+OPC_BBS4    = $CF
+OPC_BBS5    = $DF
+OPC_BBS6    = $EF
+OPC_BBS7    = $FF
+
+.else
+
+; no bit instructions for 65SC02
+
+; OPC_NOP   = $07               ; doublet
+; OPC_NOP   = $17               ; doublet
+; OPC_NOP   = $27               ; doublet
+; OPC_NOP   = $37               ; doublet
+; OPC_NOP   = $47               ; doublet
+; OPC_NOP   = $57               ; doublet
+; OPC_NOP   = $67               ; doublet
+; OPC_NOP   = $77               ; doublet
+; OPC_NOP   = $87               ; doublet
+; OPC_NOP   = $97               ; doublet
+; OPC_NOP   = $A7               ; doublet
+; OPC_NOP   = $B7               ; doublet
+; OPC_NOP   = $C7               ; doublet
+; OPC_NOP   = $D7               ; doublet
+; OPC_NOP   = $E7               ; doublet
+; OPC_NOP   = $F7               ; doublet
+; OPC_NOP   = $0F               ; doublet
+; OPC_NOP   = $1F               ; doublet
+; OPC_NOP   = $2F               ; doublet
+; OPC_NOP   = $3F               ; doublet
+; OPC_NOP   = $4F               ; doublet
+; OPC_NOP   = $5F               ; doublet
+; OPC_NOP   = $6F               ; doublet
+; OPC_NOP   = $7F               ; doublet
+; OPC_NOP   = $8F               ; doublet
+; OPC_NOP   = $9F               ; doublet
+; OPC_NOP   = $AF               ; doublet
+; OPC_NOP   = $BF               ; doublet
+; OPC_NOP   = $CF               ; doublet
+; OPC_NOP   = $DF               ; doublet
+; OPC_NOP   = $EF               ; doublet
+; OPC_NOP   = $FF               ; doublet
+
+.endif
+
+.elseif (.cpu .bitand ::CPU_ISET_6502X)
+
+; stable, undocumented opcodes
+
+; OPC_KIL   = $02               ; unstable
+OPC_SLO_izx = $03
+OPC_NOP_zp  = $04
+OPC_SLO_zp  = $07
+OPC_ANC_imm = $0B
+OPC_NOP_abs = $0C
+OPC_SLO_abs = $0F
+
+; OPC_KIL   = $12               ; unstable
+OPC_SLO_izy = $13
+OPC_NOP_zpx = $14
+OPC_SLO_zpx = $17
+;OPC_NOP    = $1A
+OPC_SLO_aby = $1B
+OPC_NOP_abx = $1C
+OPC_SLO_abx = $1F
+
+; OPC_KIL   = $22               ; unstable
+OPC_RLA_izx = $23
+OPC_RLA_zp  = $27
+OPC_ANC_imm = $2B
+OPC_RLA_abs = $2F
+
+; OPC_KIL   = $32               ; unstable
+OPC_RLA_izy = $33
+OPC_NOP_zpx = $34
+OPC_RLA_zpx = $37
+; OPC_NOP   = $3A               ; doublet
+OPC_RLA_aby = $3B
+OPC_NOP_abx = $3C
+OPC_RLA_abx = $3F
+
+; OPC_KIL   = $42               ; unstable
+OPC_SRE_izx = $43
+OPC_NOP_zp  = $44
+OPC_SRE_zp  = $47
+OPC_ALR_imm = $4B
+OPC_SRE_abs = $4F
+
+; OPC_KIL   = $52               ; unstable
+OPC_SRE_izy = $53
+OPC_NOP_zpx = $54
+OPC_SRE_zpx = $57
+; OPC_NOP   = $5A               ; doublet
+OPC_SRE_aby = $5B
+OPC_NOP_abx = $5C
+OPC_SRE_abx = $5F
+
+; OPC_KIL   = $62
+OPC_RRA_izx = $63
+OPC_NOP_zp  = $64
+OPC_RRA_zp  = $67
+OPC_ARR_imm = $6B
+OPC_RRA_abs = $6F
+
+; OPC_KIL   = $72
+OPC_RRA_izy = $73
+OPC_NOP_zpx = $74
+OPC_RRA_zpx = $77
+; OPC_NOP   = $7A               ; doublet
+OPC_RRA_aby = $7B
+OPC_NOP_abx = $7C
+OPC_RRA_abx = $7F
+
+OPC_NOP_imm = $80
+; OPC_NOP_imm = $82             ; doublet
+OPC_SAX_izx = $83
+OPC_SAX_zp  = $87
+; OPC_NOP_imm = $89             ; doublet
+; OPC_XAA = $8B                 ; unstable
+OPC_SAX_abs = $8F
+
+; OPC_KIL   = $92               ; unstable
+; OPC_AHX_izy = $93             ; unstable
+OPC_SAX_zpy = $97
+; OPC_TAS_aby = $9B             ; unstable
+; OPC_SHY_abx = $9C             ; unstable
+; OPC_SHX_aby = $9E             ; unstable
+; OPC_AHX_aby = $9F             ; unstable
+
+OPC_LAX_izx = $A3
+OPC_LAX_zp  = $A7
+; OPC_LAX_imm = $AB             ; unstable
+OPC_LAX_abs = $AF
+
+; OPC_KIL   = $B2               ; unstable
+OPC_LAX_izy = $B3
+OPC_LAX_zpy = $B7
+OPC_LAS_aby = $BB
+OPC_LAX_aby = $BF
+
+; OPC_NOP_imm = $C2             ; doublet
+OPC_DCP_izx = $C3
+OPC_DCP_zp  = $C7
+OPC_AXS_imm = $CB
+OPC_DCP_abs = $CF
+
+; OPC_KIL   = $D2               ; unstable
+OPC_DCP_izy = $D3
+OPC_NOP_zpx = $D4
+OPC_DCP_zpx = $D7
+OPC_NOP_DA  = $DA
+OPC_DCP_aby = $DB
+OPC_NOP_abx = $DC
+OPC_DCP_abx = $DF
+
+; OPC_NOP_imm = $E2             ; doublet
+OPC_ISC_izx = $E3
+OPC_ISC_zp  = $E7
+; OPC_SBC_imm = $EB             ; doublet
+OPC_ISC_abs = $EF
+
+; OPC_KIL   = $F2               ; unstable
+OPC_ISC_izy = $F3
+OPC_NOP_zpx = $F4
+OPC_ISC_zpx = $F7
+OPC_NOP_FA  = $FA
+OPC_ISC_aby = $FB
+OPC_NOP_abx = $FC
+OPC_ISC_abx = $FF
+
+.endif
index d5752a5f5cb17ed1211d63b47ec85114005f93c7..0583f79e0ba97a3eea7e0e7b2cf9b033fedb1a70 100644 (file)
-; smc.mac\r
-; ca65 Macro-Pack for Self Modifying Code (SMC)\r
-;\r
-; (c) Christian Krüger, latest change: 17-Jul-2016\r
-;\r
-; This software is provided 'as-is', without any expressed or implied\r
-; warranty.  In no event will the authors be held liable for any damages\r
-; arising from the use of this software.\r
-;\r
-; Permission is granted to anyone to use this software for any purpose,\r
-; including commercial applications, and to alter it and redistribute it\r
-; freely, subject to the following restrictions:\r
-;\r
-; 1. The origin of this software must not be misrepresented; you must not\r
-;    claim that you wrote the original software. If you use this software\r
-;    in a product, an acknowledgment in the product documentation would be\r
-;    appreciated but is not required.\r
-; 2. Altered source versions must be plainly marked as such, and must not\r
-;    be misrepresented as being the original software.\r
-; 3. This notice may not be removed or altered from any source\r
-;    distribution.\r
-;\r
-\r
-.define _SMCDesignator  .mid(0, .tcount(label) - 1, label) .ident(.concat(.string(.right(1, label)), "_SMC"))\r
-.define _SMCAlias       .mid(0, .tcount(alias) - 1, alias) .ident(.concat(.string(.right(1, alias)), "_SMC"))\r
-.define SMC_AbsAdr      $FADE\r
-.define SMC_ZpAdr       $00\r
-.define SMC_Opcode      nop\r
-.define SMC_Value       $42\r
-\r
-.macro SMC_OperateOnValue opcode, label\r
-        opcode _SMCDesignator+1\r
-.endmacro\r
-\r
-.macro SMC_OperateOnLowByte opcode, label\r
-        SMC_OperateOnValue opcode, label\r
-.endmacro\r
-\r
-.macro SMC_OperateOnHighByte opcode, label\r
-        opcode _SMCDesignator + 2\r
-.endmacro\r
-\r
-.macro SMC_Import alias\r
-.import _SMCAlias\r
-.endmacro\r
-\r
-.macro SMC_Export alias, label\r
-.export _SMCAlias := _SMCDesignator\r
-.endmacro\r
-\r
-.macro  SMC     label, statement\r
-_SMCDesignator: statement\r
-.endmacro\r
-\r
-.macro SMC_TransferOpcode       label, opcode, register\r
-.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, )\r
-        lda #opcode\r
-        sta _SMCDesignator\r
-.elseif .match ({register}, x)\r
-        ldx #opcode\r
-        stx _SMCDesignator\r
-.elseif .match ({register}, y)\r
-        ldy #opcode\r
-        sty _SMCDesignator\r
-.else\r
-       .error "Invalid usage of macro 'SMC_TransferOpcode'"\r
-.endif\r
-.endmacro\r
-\r
-.macro SMC_LoadOpcode   label, register\r
-.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )\r
-        lda _SMCDesignator\r
-.elseif .match ({register}, x)\r
-        ldx _SMCDesignator\r
-.elseif .match ({register}, y)\r
-        ldy _SMCDesignator\r
-.else\r
-       .error "Invalid usage of macro 'SMC_LoadOpcode'"\r
-.endif\r
-.endmacro\r
-\r
-.macro SMC_StoreOpcode  label, register\r
-.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )\r
-        sta _SMCDesignator\r
-.elseif .match ({register}, x)\r
-        stx _SMCDesignator\r
-.elseif .match ({register}, y)\r
-        sty _SMCDesignator\r
-.else\r
-       .error "Invalid usage of macro 'SMC_StoreOpcode'"\r
-.endif\r
-.endmacro\r
-\r
-.macro SMC_ChangeBranch         label, destination, register\r
-.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, )\r
-        lda #(<(destination - _SMCDesignator -2))\r
-        sta _SMCDesignator+1\r
-.elseif .match ({register}, x)\r
-        ldx #(<(destination - _SMCDesignator - 2))\r
-        stx _SMCDesignator+1\r
-.elseif .match ({register}, y)\r
-        ldy #(<(destination - _SMCDesignator - 2))\r
-        sty _SMCDesignator+1\r
-.else\r
-       .error "Invalid usage of macro 'SMC_ChangeBranch'"\r
-.endif\r
-.endmacro\r
-\r
-.macro SMC_TransferValue        label, value, register\r
-.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, )\r
-        lda value\r
-        sta _SMCDesignator+1\r
-.elseif .match ({register}, x)\r
-        ldx value\r
-        stx _SMCDesignator+1\r
-.elseif .match ({register}, y)\r
-        ldy value\r
-        sty _SMCDesignator+1\r
-.else\r
-       .error "Invalid usage of macro 'SMC_TransferValue'"\r
-.endif\r
-.endmacro\r
-\r
-.macro SMC_LoadValue    label, register\r
-.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )\r
-        lda _SMCDesignator+1\r
-.elseif .match ({register}, x)\r
-        ldx _SMCDesignator+1\r
-.elseif .match ({register}, y)\r
-        ldy _SMCDesignator+1\r
-.else\r
-       .error "Invalid usage of macro 'SMC_LoadValue'"\r
-.endif\r
-.endmacro\r
-\r
-.macro SMC_StoreValue   label, register\r
-.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )\r
-        sta _SMCDesignator+1\r
-.elseif .match ({register}, x)\r
-        stx _SMCDesignator+1\r
-.elseif .match ({register}, y)\r
-        sty _SMCDesignator+1\r
-.else\r
-       .error "Invalid usage of macro 'SMC_StoreValue'"\r
-.endif\r
-.endmacro\r
-\r
-\r
-.macro SMC_TransferLowByte      label, value, register\r
-SMC_TransferValue label, value, register\r
-.endmacro\r
-\r
-.macro SMC_LoadLowByte  label, register\r
-SMC_LoadValue label, register\r
-.endmacro\r
-\r
-.macro SMC_StoreLowByte label, register\r
-SMC_StoreValue label, register\r
-.endmacro\r
-\r
-.macro SMC_TransferHighByte     label, value, register\r
-.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, )\r
-        lda value\r
-        sta _SMCDesignator+2\r
-.elseif .match ({register}, x)\r
-        ldx value\r
-        stx _SMCDesignator+2\r
-.elseif .match ({register}, y)\r
-        ldy value\r
-        sty _SMCDesignator+2\r
-.else\r
-       .error "Invalid usage of macro 'SMC_TransferHighByte'"\r
-.endif\r
-.endmacro\r
-\r
-.macro SMC_LoadHighByte label, register\r
-.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )\r
-        lda _SMCDesignator+2\r
-.elseif .match ({register}, x)\r
-        ldx _SMCDesignator+2\r
-.elseif .match ({register}, y)\r
-        ldy _SMCDesignator+2\r
-.else\r
-       .error "Invalid usage of macro 'SMC_LoadHighByte'"\r
-.endif\r
-.endmacro\r
-\r
-.macro SMC_StoreHighByte        label, register\r
-.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )\r
-        sta _SMCDesignator+2\r
-.elseif .match ({register}, x)\r
-        stx _SMCDesignator+2\r
-.elseif .match ({register}, y)\r
-        sty _SMCDesignator+2\r
-.else\r
-       .error "Invalid usage of macro 'SMC_StoreHighByte'"\r
-.endif\r
-.endmacro\r
-\r
-.macro SMC_TransferAddressSingle        label, address, register\r
-.if .paramcount = 2 .or .match ((register), a) .or .match ({register}, )\r
-        .if (.match (.left (1, {address}), #))\r
-                ; immediate mode\r
-                lda #<(.right (.tcount ({address})-1, {address}))\r
-                sta _SMCDesignator+1\r
-                lda #>(.right (.tcount ({address})-1, {address}))\r
-                sta _SMCDesignator+2\r
-        .else\r
-                ; assume absolute or zero page\r
-                lda address\r
-                sta _SMCDesignator+1\r
-                lda 1+(address)\r
-                sta _SMCDesignator+2\r
-        .endif\r
-.elseif .match ((register), x)\r
-        .if (.match (.left (1, {address}), #))\r
-                ; immediate mode\r
-                ldx #<(.right (.tcount ({address})-1, {address}))\r
-                stx _SMCDesignator+1\r
-                ldx #>(.right (.tcount ({address})-1, {address}))\r
-                stx _SMCDesignator+2\r
-        .else\r
-                ; assume absolute or zero page\r
-                ldx address\r
-                stx _SMCDesignator+1\r
-                ldx 1+(address)\r
-                stx _SMCDesignator+2\r
-        .endif\r
-.elseif .match ((register), y)\r
-        .if (.match (.left (1, {address}), #))\r
-                ; immediate mode\r
-                ldy #<(.right (.tcount ({address})-1, {address}))\r
-                sty _SMCDesignator+1\r
-                ldy #>(.right (.tcount ({address})-1, {address}))\r
-                sty _SMCDesignator+2\r
-        .else\r
-                ; assume absolute or zero page\r
-                ldy address\r
-                sty _SMCDesignator+1\r
-                ldy 1+(address)\r
-                sty _SMCDesignator+2\r
-        .endif\r
-.else\r
-       .error "Invalid usage of macro 'SMC_TransferAddressSingle'"\r
-.endif\r
-.endmacro\r
-\r
-.macro SMC_TransferAddress      label, address\r
-.if (.match (.left (1, {address}), #))\r
-        ; immediate mode\r
-        lda #<(.right (.tcount ({address})-1, {address}))\r
-        sta _SMCDesignator+1\r
-        ldx #>(.right (.tcount ({address})-1, {address}))\r
-        stx _SMCDesignator+2\r
-.else\r
-        ; assume absolute or zero page\r
-        lda {address}\r
-        sta _SMCDesignator+1\r
-        ldx 1+{address}\r
-        stx _SMCDesignator)+2\r
-.endif\r
-.endmacro\r
-\r
-.macro SMC_StoreAddress label\r
-        sta _SMCDesignator+1\r
-        stx _SMCDesignator+2\r
-.endmacro\r
+; smc.mac
+; ca65 Macro-Pack for Self Modifying Code (SMC)
+;
+; (c) Christian Krüger, latest change: 17-Jul-2016
+;
+; This software is provided 'as-is', without any expressed or implied
+; warranty.  In no event will the authors be held liable for any damages
+; arising from the use of this software.
+;
+; Permission is granted to anyone to use this software for any purpose,
+; including commercial applications, and to alter it and redistribute it
+; freely, subject to the following restrictions:
+;
+; 1. The origin of this software must not be misrepresented; you must not
+;    claim that you wrote the original software. If you use this software
+;    in a product, an acknowledgment in the product documentation would be
+;    appreciated but is not required.
+; 2. Altered source versions must be plainly marked as such, and must not
+;    be misrepresented as being the original software.
+; 3. This notice may not be removed or altered from any source
+;    distribution.
+;
+
+.define _SMCDesignator  .mid(0, .tcount(label) - 1, label) .ident(.concat(.string(.right(1, label)), "_SMC"))
+.define _SMCAlias       .mid(0, .tcount(alias) - 1, alias) .ident(.concat(.string(.right(1, alias)), "_SMC"))
+.define SMC_AbsAdr      $FADE
+.define SMC_ZpAdr       $00
+.define SMC_Opcode      nop
+.define SMC_Value       $42
+
+.macro SMC_OperateOnValue opcode, label
+        opcode _SMCDesignator+1
+.endmacro
+
+.macro SMC_OperateOnLowByte opcode, label
+        SMC_OperateOnValue opcode, label
+.endmacro
+
+.macro SMC_OperateOnHighByte opcode, label
+        opcode _SMCDesignator + 2
+.endmacro
+
+.macro SMC_Import alias
+.import _SMCAlias
+.endmacro
+
+.macro SMC_Export alias, label
+.export _SMCAlias := _SMCDesignator
+.endmacro
+
+.macro  SMC     label, statement
+_SMCDesignator: statement
+.endmacro
+
+.macro SMC_TransferOpcode       label, opcode, register
+.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, )
+        lda #opcode
+        sta _SMCDesignator
+.elseif .match ({register}, x)
+        ldx #opcode
+        stx _SMCDesignator
+.elseif .match ({register}, y)
+        ldy #opcode
+        sty _SMCDesignator
+.else
+       .error "Invalid usage of macro 'SMC_TransferOpcode'"
+.endif
+.endmacro
+
+.macro SMC_LoadOpcode   label, register
+.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )
+        lda _SMCDesignator
+.elseif .match ({register}, x)
+        ldx _SMCDesignator
+.elseif .match ({register}, y)
+        ldy _SMCDesignator
+.else
+       .error "Invalid usage of macro 'SMC_LoadOpcode'"
+.endif
+.endmacro
+
+.macro SMC_StoreOpcode  label, register
+.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )
+        sta _SMCDesignator
+.elseif .match ({register}, x)
+        stx _SMCDesignator
+.elseif .match ({register}, y)
+        sty _SMCDesignator
+.else
+       .error "Invalid usage of macro 'SMC_StoreOpcode'"
+.endif
+.endmacro
+
+.macro SMC_ChangeBranch         label, destination, register
+.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, )
+        lda #(<(destination - _SMCDesignator -2))
+        sta _SMCDesignator+1
+.elseif .match ({register}, x)
+        ldx #(<(destination - _SMCDesignator - 2))
+        stx _SMCDesignator+1
+.elseif .match ({register}, y)
+        ldy #(<(destination - _SMCDesignator - 2))
+        sty _SMCDesignator+1
+.else
+       .error "Invalid usage of macro 'SMC_ChangeBranch'"
+.endif
+.endmacro
+
+.macro SMC_TransferValue        label, value, register
+.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, )
+        lda value
+        sta _SMCDesignator+1
+.elseif .match ({register}, x)
+        ldx value
+        stx _SMCDesignator+1
+.elseif .match ({register}, y)
+        ldy value
+        sty _SMCDesignator+1
+.else
+       .error "Invalid usage of macro 'SMC_TransferValue'"
+.endif
+.endmacro
+
+.macro SMC_LoadValue    label, register
+.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )
+        lda _SMCDesignator+1
+.elseif .match ({register}, x)
+        ldx _SMCDesignator+1
+.elseif .match ({register}, y)
+        ldy _SMCDesignator+1
+.else
+       .error "Invalid usage of macro 'SMC_LoadValue'"
+.endif
+.endmacro
+
+.macro SMC_StoreValue   label, register
+.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )
+        sta _SMCDesignator+1
+.elseif .match ({register}, x)
+        stx _SMCDesignator+1
+.elseif .match ({register}, y)
+        sty _SMCDesignator+1
+.else
+       .error "Invalid usage of macro 'SMC_StoreValue'"
+.endif
+.endmacro
+
+
+.macro SMC_TransferLowByte      label, value, register
+SMC_TransferValue label, value, register
+.endmacro
+
+.macro SMC_LoadLowByte  label, register
+SMC_LoadValue label, register
+.endmacro
+
+.macro SMC_StoreLowByte label, register
+SMC_StoreValue label, register
+.endmacro
+
+.macro SMC_TransferHighByte     label, value, register
+.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, )
+        lda value
+        sta _SMCDesignator+2
+.elseif .match ({register}, x)
+        ldx value
+        stx _SMCDesignator+2
+.elseif .match ({register}, y)
+        ldy value
+        sty _SMCDesignator+2
+.else
+       .error "Invalid usage of macro 'SMC_TransferHighByte'"
+.endif
+.endmacro
+
+.macro SMC_LoadHighByte label, register
+.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )
+        lda _SMCDesignator+2
+.elseif .match ({register}, x)
+        ldx _SMCDesignator+2
+.elseif .match ({register}, y)
+        ldy _SMCDesignator+2
+.else
+       .error "Invalid usage of macro 'SMC_LoadHighByte'"
+.endif
+.endmacro
+
+.macro SMC_StoreHighByte        label, register
+.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )
+        sta _SMCDesignator+2
+.elseif .match ({register}, x)
+        stx _SMCDesignator+2
+.elseif .match ({register}, y)
+        sty _SMCDesignator+2
+.else
+       .error "Invalid usage of macro 'SMC_StoreHighByte'"
+.endif
+.endmacro
+
+.macro SMC_TransferAddressSingle        label, address, register
+.if .paramcount = 2 .or .match ((register), a) .or .match ({register}, )
+        .if (.match (.left (1, {address}), #))
+                ; immediate mode
+                lda #<(.right (.tcount ({address})-1, {address}))
+                sta _SMCDesignator+1
+                lda #>(.right (.tcount ({address})-1, {address}))
+                sta _SMCDesignator+2
+        .else
+                ; assume absolute or zero page
+                lda address
+                sta _SMCDesignator+1
+                lda 1+(address)
+                sta _SMCDesignator+2
+        .endif
+.elseif .match ((register), x)
+        .if (.match (.left (1, {address}), #))
+                ; immediate mode
+                ldx #<(.right (.tcount ({address})-1, {address}))
+                stx _SMCDesignator+1
+                ldx #>(.right (.tcount ({address})-1, {address}))
+                stx _SMCDesignator+2
+        .else
+                ; assume absolute or zero page
+                ldx address
+                stx _SMCDesignator+1
+                ldx 1+(address)
+                stx _SMCDesignator+2
+        .endif
+.elseif .match ((register), y)
+        .if (.match (.left (1, {address}), #))
+                ; immediate mode
+                ldy #<(.right (.tcount ({address})-1, {address}))
+                sty _SMCDesignator+1
+                ldy #>(.right (.tcount ({address})-1, {address}))
+                sty _SMCDesignator+2
+        .else
+                ; assume absolute or zero page
+                ldy address
+                sty _SMCDesignator+1
+                ldy 1+(address)
+                sty _SMCDesignator+2
+        .endif
+.else
+       .error "Invalid usage of macro 'SMC_TransferAddressSingle'"
+.endif
+.endmacro
+
+.macro SMC_TransferAddress      label, address
+.if (.match (.left (1, {address}), #))
+        ; immediate mode
+        lda #<(.right (.tcount ({address})-1, {address}))
+        sta _SMCDesignator+1
+        ldx #>(.right (.tcount ({address})-1, {address}))
+        stx _SMCDesignator+2
+.else
+        ; assume absolute or zero page
+        lda {address}
+        sta _SMCDesignator+1
+        ldx 1+{address}
+        stx _SMCDesignator)+2
+.endif
+.endmacro
+
+.macro SMC_StoreAddress label
+        sta _SMCDesignator+1
+        stx _SMCDesignator+2
+.endmacro
index 2c3502ba8821a0f769cdcabd93ecfb61d25fe983..8a51e1c32a3894a97a31ff2c9dd0fe6753e9ec99 100644 (file)
@@ -107,6 +107,7 @@ XWR0             = $10
 XWSTR0           = $14 
 XTEXT            = $19
 XHIRES           = $1A
+XFILLM           = $1C
 XMINMA           = $1F
 XFREAD           = $27          ; only in TELEMON 3.0
 XOPEN            = $30          ; only in TELEMON 3.0
@@ -128,6 +129,13 @@ XINK             = $93
 XEXPLO           = $9C 
 XPING            = $9D
 
+; ---------------------------------------------------------------------------
+; Page $200
+SCRX             := $220
+SCRY             := $224
+ADSCRL           := $218
+ADSCRH           := $21C
+
 
 ; ---------------------------------------------------------------------------
 ; Page $500
index 06e39b36ffdcb73a8612838b6dde52571ecb740f..9e4ecd8cea7bd2d294bf2dd65fb07f7d3e816955 100644 (file)
@@ -4,7 +4,7 @@ SYMBOLS {
 MEMORY {
     ZP:  file = "", define = yes, start = $0020, size = $00E0;
     RAM: file = "", define = yes, start = $01FA, size = $0206;
-    ROM: file = %O, define = yes, start = $B000, size = $1000;
+    ROM: file = %O, define = yes, start = $B000, size = $1000, fill = yes, fillval = $FF;
 }
 SEGMENTS {
     ZEROPAGE: load = ZP,             type = zp;
index 80dba89b8b492e1ca85675a1f67b0c91fcf803ca..6a08cc3c395d118da661c40e653853b5c6707262 100644 (file)
@@ -4,7 +4,7 @@
 <title>cc65 Users Guide
 <author><url url="mailto:uz@cc65.org" name="Ullrich von Bassewitz">,<newline>
 <url url="mailto:gregdk@users.sf.net" name="Greg King">
-<date>2016-06-11
+<date>2017-02-27
 
 <abstract>
 cc65 is a C compiler for 6502 targets. It supports several 6502 based home
@@ -687,30 +687,37 @@ This cc65 version has some extensions to the ISO C standard.
        string.
        <p>
 
-<item>         cc65 allows the initialization of <tt/void/ variables. This may be
-       used to create variable structures that are more compatible with
-       interfaces written for assembler languages. Here is an example:
+<item>  cc65 allows the initialization of <tt/void/ variables. This may be
+        used to create arbitrary structures that are more compatible with
+        interfaces written for assembler languages. Here is an example:
 
-       <tscreen><verb>
-       void GCmd = {   (char)3, (unsigned)0x2000, (unsigned)0x3000 };
-       </verb></tscreen>
+        <tscreen><verb>
+        void GCmd = { (char)3, (unsigned)0x2000, (unsigned)0x3000 };
+        </verb></tscreen>
 
-       This will be translated as follows:
+        That will be translated as follows:
 
-       <tscreen><verb>
-       _GCmd:
-               .byte   3
-               .word   $2000
-               .word   $3000
-       </verb></tscreen>
+        <tscreen><verb>
+        _GCmd:
+                .byte   3
+                .word   $2000
+                .word   $3000
+        </verb></tscreen>
 
-       Since the variable is of type <tt/void/ you may not use it as is.
-       However, taking the address of the variable results in a <tt/void*/
-       which may be passed to any function expecting a pointer.
+        Since the variable is of type <tt/void/, you may not use it as-is.
+        However, taking the address of the variable results in a <tt/void*/
+        which may be passed to any function expecting a pointer.  Also, the
+        <tt/sizeof/ operator will give the length of the initializer:
 
-       See the <url url="geos.html" name="GEOS library document"> for examples
-       on how to use this feature.
-       <p>
+        <tscreen><verb>
+        GLen = sizeof GCmd;
+        </verb></tscreen>
+
+        will assign the value 5 to <tt/GLen/.
+
+        See the <url url="geos.html" name="GEOS library document"> for examples
+        on how to use that feature.
+        <p>
 
 <item>  cc65 implements flexible array struct members as defined in the C99 ISO
         standard. As an extension, these fields may be initialized. There are
index 9032156eeb5375f4fc32123819f4f2c9b367da82..fda4dee86731da4e2fd7812d05ee575b8af4d7aa 100644 (file)
@@ -141,7 +141,7 @@ Telestrat manages also mouse, but it had been no handled yet in this version.
 
 Telestrat has a RS232 port, but it's not used
 
-</descrip><
+</descrip>
 
 <sect>Limitations<label id="limitations"><p>
 
index 57fe0cd240ad343bd353f8baa5d14f11718c47c8..d6ab5fee179327c57b1a4dab5f9ed99a3863d05b 100644 (file)
@@ -1,47 +1,47 @@
-/*****************************************************************************/\r
-/*                                                                           */\r
-/*                                osic1p.h                                   */\r
-/*                                                                           */\r
-/*                Challenger 1P system specific definitions                  */\r
-/*                                                                           */\r
-/*                                                                           */\r
-/*                                                                           */\r
-/* (C) 2015 Stephan Muehlstrasser                                            */\r
-/*                                                                           */\r
-/*                                                                           */\r
-/* This software is provided 'as-is', without any expressed or implied       */\r
-/* warranty.  In no event will the authors be held liable for any damages    */\r
-/* arising from the use of this software.                                    */\r
-/*                                                                           */\r
-/* Permission is granted to anyone to use this software for any purpose,     */\r
-/* including commercial applications, and to alter it and redistribute it    */\r
-/* freely, subject to the following restrictions:                            */\r
-/*                                                                           */\r
-/* 1. The origin of this software must not be misrepresented; you must not   */\r
-/*    claim that you wrote the original software. If you use this software   */\r
-/*    in a product, an acknowledgment in the product documentation would be  */\r
-/*    appreciated but is not required.                                       */\r
-/* 2. Altered source versions must be plainly marked as such, and must not   */\r
-/*    be misrepresented as being the original software.                      */\r
-/* 3. This notice may not be removed or altered from any source              */\r
-/*    distribution.                                                          */\r
-/*                                                                           */\r
-/*****************************************************************************/\r
-\r
-#ifndef _OSIC1P_H\r
-#define _OSIC1P_H\r
-\r
-/* Check for errors */\r
-#if !defined(__OSIC1P__)\r
-#  error "This module may only be used when compiling for the Challenger 1P!"\r
-#endif\r
-\r
-/* The following #defines will cause the matching functions calls in conio.h\r
-** to be overlaid by macros with the same names, saving the function call\r
-** overhead.\r
-*/\r
-#define _textcolor(color)       COLOR_WHITE\r
-#define _bgcolor(color)         COLOR_BLACK\r
-#define _bordercolor(color)     COLOR_BLACK\r
-\r
-#endif\r
+/*****************************************************************************/
+/*                                                                           */
+/*                                osic1p.h                                   */
+/*                                                                           */
+/*                Challenger 1P system specific definitions                  */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (C) 2015 Stephan Muehlstrasser                                            */
+/*                                                                           */
+/*                                                                           */
+/* This software is provided 'as-is', without any expressed or implied       */
+/* warranty.  In no event will the authors be held liable for any damages    */
+/* arising from the use of this software.                                    */
+/*                                                                           */
+/* Permission is granted to anyone to use this software for any purpose,     */
+/* including commercial applications, and to alter it and redistribute it    */
+/* freely, subject to the following restrictions:                            */
+/*                                                                           */
+/* 1. The origin of this software must not be misrepresented; you must not   */
+/*    claim that you wrote the original software. If you use this software   */
+/*    in a product, an acknowledgment in the product documentation would be  */
+/*    appreciated but is not required.                                       */
+/* 2. Altered source versions must be plainly marked as such, and must not   */
+/*    be misrepresented as being the original software.                      */
+/* 3. This notice may not be removed or altered from any source              */
+/*    distribution.                                                          */
+/*                                                                           */
+/*****************************************************************************/
+
+#ifndef _OSIC1P_H
+#define _OSIC1P_H
+
+/* Check for errors */
+#if !defined(__OSIC1P__)
+#  error "This module may only be used when compiling for the Challenger 1P!"
+#endif
+
+/* The following #defines will cause the matching functions calls in conio.h
+** to be overlaid by macros with the same names, saving the function call
+** overhead.
+*/
+#define _textcolor(color)       COLOR_WHITE
+#define _bgcolor(color)         COLOR_BLACK
+#define _bordercolor(color)     COLOR_BLACK
+
+#endif
index 8fa6a2bd12c7c035e545e7a04f7e79e0a3fd6bbb..8ced898004a4cc7364a2c2d0f839a0e0e0971e5c 100644 (file)
-/*****************************************************************************/\r
-/*                                                                           */\r
-/*                                  zlib.h                                   */\r
-/*                                                                           */\r
-/*              Decompression routines for the 'deflate' format              */\r
-/*                                                                           */\r
-/*                                                                           */\r
-/*                                                                           */\r
-/* (C) 2000-2015 Piotr Fusik <fox@scene.pl>                                  */\r
-/*                                                                           */\r
-/* This file is based on the zlib.h from 'zlib' general purpose compression  */\r
-/* library, version 1.1.3, (C) 1995-1998 Jean-loup Gailly and Mark Adler.    */\r
-/*                                                                           */\r
-/*  Jean-loup Gailly        Mark Adler                                       */\r
-/*  jloup@gzip.org          madler@alumni.caltech.edu                        */\r
-/*                                                                           */\r
-/* This software is provided 'as-is', without any expressed or implied       */\r
-/* warranty.  In no event will the authors be held liable for any damages    */\r
-/* arising from the use of this software.                                    */\r
-/*                                                                           */\r
-/* Permission is granted to anyone to use this software for any purpose,     */\r
-/* including commercial applications, and to alter it and redistribute it    */\r
-/* freely, subject to the following restrictions:                            */\r
-/*                                                                           */\r
-/* 1. The origin of this software must not be misrepresented; you must not   */\r
-/*    claim that you wrote the original software. If you use this software   */\r
-/*    in a product, an acknowledgment in the product documentation would be  */\r
-/*    appreciated but is not required.                                       */\r
-/* 2. Altered source versions must be plainly marked as such, and must not   */\r
-/*    be misrepresented as being the original software.                      */\r
-/* 3. This notice may not be removed or altered from any source              */\r
-/*    distribution.                                                          */\r
-/*                                                                           */\r
-/*****************************************************************************/\r
-\r
-\r
-\r
-#ifndef _ZLIB_H\r
-#define _ZLIB_H\r
-\r
-#define Z_OK         0\r
-#define Z_DATA_ERROR (-3)\r
-/* Return codes for uncompress() */\r
-\r
-#define Z_DEFLATED   8\r
-/* The deflate compression method (the only one supported) */\r
-\r
-#define Z_NULL       0\r
-\r
-\r
-unsigned __fastcall__ inflatemem (char* dest, const char* source);\r
-/*\r
-     Decompresses the source buffer into the destination buffer.\r
-   Returns the size of the uncompressed data (number of bytes written starting\r
-   from dest).\r
-\r
-     This function expects data in the DEFLATE format, described in RFC\r
-   (Request for Comments) 1951 in the file\r
-   ftp://ds.internic.net/rfc/rfc1951.txt.\r
-\r
-     This function does not exist in the original zlib. Its implementation\r
-   using original zlib might be following:\r
-\r
-   unsigned inflatemem (char* dest, const char* source)\r
-   {\r
-     z_stream stream;\r
-\r
-     stream.next_in = (Bytef*) source;\r
-     stream.avail_in = 65535;\r
-\r
-     stream.next_out = dest;\r
-     stream.avail_out = 65535;\r
-\r
-     stream.zalloc = (alloc_func) 0;\r
-     stream.zfree = (free_func) 0;\r
-\r
-     inflateInit2(&stream, -MAX_WBITS);\r
-     inflate(&stream, Z_FINISH);\r
-     inflateEnd(&stream);\r
-\r
-     return stream.total_out;\r
-   }\r
-*/\r
-\r
-\r
-int __fastcall__ uncompress (char* dest, unsigned* destLen,\r
-                             const char* source, unsigned sourceLen);\r
-/*\r
-   Original zlib description:\r
-\r
-     Decompresses the source buffer into the destination buffer.  sourceLen is\r
-   the byte length of the source buffer. Upon entry, destLen is the total\r
-   size of the destination buffer, which must be large enough to hold the\r
-   entire uncompressed data. (The size of the uncompressed data must have\r
-   been saved previously by the compressor and transmitted to the decompressor\r
-   by some mechanism outside the scope of this compression library.)\r
-   Upon exit, destLen is the actual size of the compressed buffer.\r
-     This function can be used to decompress a whole file at once if the\r
-   input file is mmap'ed.\r
-\r
-     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not\r
-   enough memory, Z_BUF_ERROR if there was not enough room in the output\r
-   buffer, or Z_DATA_ERROR if the input data was corrupted.\r
-\r
-   Implementation notes:\r
-\r
-     This function expects data in the ZLIB format, described in RFC 1950\r
-   in the file ftp://ds.internic.net/rfc/rfc1950.txt. The ZLIB format is\r
-   essentially the DEFLATE format plus a very small header and Adler-32\r
-   checksum.\r
-\r
-     Z_MEM_ERROR and Z_BUF_ERROR are never returned in this implementation.\r
-*/\r
-\r
-\r
-unsigned long __fastcall__ adler32 (unsigned long adler, const char* buf,\r
-                                    unsigned len);\r
-\r
-/*\r
-   Original zlib description:\r
-\r
-     Update a running Adler-32 checksum with the bytes buf[0..len-1] and\r
-   return the updated checksum. If buf is NULL, this function returns\r
-   the required initial value for the checksum.\r
-   An Adler-32 checksum is almost as reliable as a CRC32 but can be computed\r
-   much faster. Usage example:\r
-\r
-     unsigned long adler = adler32(0L, Z_NULL, 0);\r
-\r
-     while (read_buffer(buffer, length) != EOF) {\r
-       adler = adler32(adler, buffer, length);\r
-     }\r
-     if (adler != original_adler) error();\r
-\r
-   Implementation notes:\r
-\r
-     This function isn't actually much faster than crc32(), but it is smaller\r
-   and does not use any lookup tables.\r
-*/\r
-\r
-\r
-unsigned long __fastcall__ crc32 (unsigned long crc, const char* buf,\r
-                                  unsigned len);\r
-/*\r
-   Original zlib description:\r
-\r
-     Update a running crc with the bytes buf[0..len-1] and return the updated\r
-   crc. If buf is NULL, this function returns the required initial value\r
-   for the crc. Pre- and post-conditioning (one's complement) is performed\r
-   within this function so it shouldn't be done by the application.\r
-   Usage example:\r
-\r
-     unsigned long crc = crc32(0L, Z_NULL, 0);\r
-\r
-     while (read_buffer(buffer, length) != EOF) {\r
-       crc = crc32(crc, buffer, length);\r
-     }\r
-     if (crc != original_crc) error();\r
-\r
-   Implementation notes:\r
-\r
-     This function uses statically allocated 1 KB lookup table. The table is\r
-   initialised before it is used for the first time (that is, if buffer is\r
-   NULL or length is zero, then the lookup table isn't initialised).\r
-*/\r
-\r
-\r
-/* end of zlib.h */\r
-#endif\r
-\r
-\r
-\r
+/*****************************************************************************/
+/*                                                                           */
+/*                                  zlib.h                                   */
+/*                                                                           */
+/*              Decompression routines for the 'deflate' format              */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (C) 2000-2015 Piotr Fusik <fox@scene.pl>                                  */
+/*                                                                           */
+/* This file is based on the zlib.h from 'zlib' general purpose compression  */
+/* library, version 1.1.3, (C) 1995-1998 Jean-loup Gailly and Mark Adler.    */
+/*                                                                           */
+/*  Jean-loup Gailly        Mark Adler                                       */
+/*  jloup@gzip.org          madler@alumni.caltech.edu                        */
+/*                                                                           */
+/* This software is provided 'as-is', without any expressed or implied       */
+/* warranty.  In no event will the authors be held liable for any damages    */
+/* arising from the use of this software.                                    */
+/*                                                                           */
+/* Permission is granted to anyone to use this software for any purpose,     */
+/* including commercial applications, and to alter it and redistribute it    */
+/* freely, subject to the following restrictions:                            */
+/*                                                                           */
+/* 1. The origin of this software must not be misrepresented; you must not   */
+/*    claim that you wrote the original software. If you use this software   */
+/*    in a product, an acknowledgment in the product documentation would be  */
+/*    appreciated but is not required.                                       */
+/* 2. Altered source versions must be plainly marked as such, and must not   */
+/*    be misrepresented as being the original software.                      */
+/* 3. This notice may not be removed or altered from any source              */
+/*    distribution.                                                          */
+/*                                                                           */
+/*****************************************************************************/
+
+
+
+#ifndef _ZLIB_H
+#define _ZLIB_H
+
+#define Z_OK         0
+#define Z_DATA_ERROR (-3)
+/* Return codes for uncompress() */
+
+#define Z_DEFLATED   8
+/* The deflate compression method (the only one supported) */
+
+#define Z_NULL       0
+
+
+unsigned __fastcall__ inflatemem (char* dest, const char* source);
+/*
+     Decompresses the source buffer into the destination buffer.
+   Returns the size of the uncompressed data (number of bytes written starting
+   from dest).
+
+     This function expects data in the DEFLATE format, described in RFC
+   (Request for Comments) 1951 in the file
+   ftp://ds.internic.net/rfc/rfc1951.txt.
+
+     This function does not exist in the original zlib. Its implementation
+   using original zlib might be following:
+
+   unsigned inflatemem (char* dest, const char* source)
+   {
+     z_stream stream;
+
+     stream.next_in = (Bytef*) source;
+     stream.avail_in = 65535;
+
+     stream.next_out = dest;
+     stream.avail_out = 65535;
+
+     stream.zalloc = (alloc_func) 0;
+     stream.zfree = (free_func) 0;
+
+     inflateInit2(&stream, -MAX_WBITS);
+     inflate(&stream, Z_FINISH);
+     inflateEnd(&stream);
+
+     return stream.total_out;
+   }
+*/
+
+
+int __fastcall__ uncompress (char* dest, unsigned* destLen,
+                             const char* source, unsigned sourceLen);
+/*
+   Original zlib description:
+
+     Decompresses the source buffer into the destination buffer.  sourceLen is
+   the byte length of the source buffer. Upon entry, destLen is the total
+   size of the destination buffer, which must be large enough to hold the
+   entire uncompressed data. (The size of the uncompressed data must have
+   been saved previously by the compressor and transmitted to the decompressor
+   by some mechanism outside the scope of this compression library.)
+   Upon exit, destLen is the actual size of the compressed buffer.
+     This function can be used to decompress a whole file at once if the
+   input file is mmap'ed.
+
+     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
+   enough memory, Z_BUF_ERROR if there was not enough room in the output
+   buffer, or Z_DATA_ERROR if the input data was corrupted.
+
+   Implementation notes:
+
+     This function expects data in the ZLIB format, described in RFC 1950
+   in the file ftp://ds.internic.net/rfc/rfc1950.txt. The ZLIB format is
+   essentially the DEFLATE format plus a very small header and Adler-32
+   checksum.
+
+     Z_MEM_ERROR and Z_BUF_ERROR are never returned in this implementation.
+*/
+
+
+unsigned long __fastcall__ adler32 (unsigned long adler, const char* buf,
+                                    unsigned len);
+
+/*
+   Original zlib description:
+
+     Update a running Adler-32 checksum with the bytes buf[0..len-1] and
+   return the updated checksum. If buf is NULL, this function returns
+   the required initial value for the checksum.
+   An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
+   much faster. Usage example:
+
+     unsigned long adler = adler32(0L, Z_NULL, 0);
+
+     while (read_buffer(buffer, length) != EOF) {
+       adler = adler32(adler, buffer, length);
+     }
+     if (adler != original_adler) error();
+
+   Implementation notes:
+
+     This function isn't actually much faster than crc32(), but it is smaller
+   and does not use any lookup tables.
+*/
+
+
+unsigned long __fastcall__ crc32 (unsigned long crc, const char* buf,
+                                  unsigned len);
+/*
+   Original zlib description:
+
+     Update a running crc with the bytes buf[0..len-1] and return the updated
+   crc. If buf is NULL, this function returns the required initial value
+   for the crc. Pre- and post-conditioning (one's complement) is performed
+   within this function so it shouldn't be done by the application.
+   Usage example:
+
+     unsigned long crc = crc32(0L, Z_NULL, 0);
+
+     while (read_buffer(buffer, length) != EOF) {
+       crc = crc32(crc, buffer, length);
+     }
+     if (crc != original_crc) error();
+
+   Implementation notes:
+
+     This function uses statically allocated 1 KB lookup table. The table is
+   initialised before it is used for the first time (that is, if buffer is
+   NULL or length is zero, then the lookup table isn't initialised).
+*/
+
+
+/* end of zlib.h */
+#endif
+
+
+
index 54b54860c3ab9987bf35f0942be15c4d0b14946d..f4aa031014f54e6bf6e402e897d94435960a746b 100644 (file)
@@ -1,4 +1,3 @@
-
 ifneq ($(shell echo),)
   CMD_EXE = 1
 endif
@@ -15,24 +14,24 @@ CBMS = c128   \
 GEOS = geos-apple \
        geos-cbm
 
-TARGETS = apple2    \
-          apple2enh \
-          atari     \
-          atarixl   \
-          atari2600 \
-          atari5200 \
-          atmos     \
+TARGETS = apple2       \
+          apple2enh    \
+          atari        \
+          atarixl      \
+          atari2600    \
+          atari5200    \
+          atmos        \
           creativision \
-          $(CBMS)   \
-          $(GEOS)   \
-          gamate    \
-          lynx      \
-          nes       \
-          osic1p    \
-          pce       \
-          sim6502   \
-          sim65c02  \
-          supervision\
+          $(CBMS)      \
+          $(GEOS)      \
+          gamate       \
+          lynx         \
+          nes          \
+          osic1p       \
+          pce          \
+          sim6502      \
+          sim65c02     \
+          supervision  \
           telestrat
 
 DRVTYPES = emd \
@@ -41,13 +40,13 @@ DRVTYPES = emd \
            ser \
            tgi
 
-OUTPUTDIRS := lib                 \
-              asminc              \
-              cfg                 \
-              include             \
-              $(subst ../,,$(filter-out $(wildcard ../include/*.*),$(wildcard ../include/*)))\
-              $(subst ../,,$(wildcard ../target/*/drv/*))\
-              $(subst ../,,$(wildcard ../target/*/util))\
+OUTPUTDIRS := lib                                                                             \
+              asminc                                                                          \
+              cfg                                                                             \
+              include                                                                         \
+              $(subst ../,,$(filter-out $(wildcard ../include/*.*),$(wildcard ../include/*))) \
+              $(subst ../,,$(wildcard ../target/*/drv/*))                                     \
+              $(subst ../,,$(wildcard ../target/*/util))
 
 .PHONY: all mostlyclean clean install zip lib $(TARGETS)
 
index bf44a0ecc522c251e45cf5130cdd45792effed04..39f323d28f3c4ee9f69ab66e0a9545a8d6e6e9f6 100644 (file)
-;\r
-; Extended memory driver for 65816 based extra RAM. Driver works without\r
-; problems when statically linked.\r
-;\r
-; Marco van den Heuvel, 2015-12-01\r
-;\r
-\r
-        .include        "zeropage.inc"\r
-\r
-        .include        "em-kernel.inc"\r
-        .include        "em-error.inc"\r
-\r
-\r
-        .macpack        generic\r
-        .macpack        module\r
-\r
-\r
-; ------------------------------------------------------------------------\r
-; Header. Includes jump table\r
-\r
-        module_header   _c64_65816_emd\r
-\r
-; Driver signature\r
-\r
-        .byte   $65, $6d, $64           ; "emd"\r
-        .byte   EMD_API_VERSION         ; EM API version number\r
-\r
-; Library reference\r
-\r
-        .addr   $0000\r
-\r
-; Jump table\r
-\r
-        .addr   INSTALL\r
-        .addr   UNINSTALL\r
-        .addr   PAGECOUNT\r
-        .addr   MAP\r
-        .addr   USE\r
-        .addr   COMMIT\r
-        .addr   COPYFROM\r
-        .addr   COPYTO\r
-\r
-; ------------------------------------------------------------------------\r
-; Data.\r
-\r
-.bss\r
-isnotscpu:      .res    1               ; SuperCPU not present\r
-curpage:        .res    1               ; Current page number\r
-curbank:        .res    1               ; Current bank number (+1)\r
-bankcount:      .res    1               ; Number of available banks (pages = banks * 256)\r
-window:         .res    256             ; Memory "window"\r
-\r
-.code\r
-\r
-; ------------------------------------------------------------------------\r
-; INSTALL routine. Is called after the driver is loaded into memory. If\r
-; possible, check if the hardware is present and determine the amount of\r
-; memory available.\r
-; Must return an EM_ERR_xx code in a/x.\r
-;\r
-\r
-INSTALL:\r
-        sei\r
-        clc\r
-        sed\r
-        lda     #$99\r
-        adc     #$01                    ; on 65C02, 65SC02, 65CE02, 65802 and 65816 sets the zero flag correctly\r
-        cld\r
-        bne     @not_present\r
-        clc\r
-.P816\r
-        sep     #$01                    ; nop #$01 on 65C02/65SC02 and lda ($01,s),y on 65CE02\r
-.P02\r
-        bcc     @not_present\r
-        lda     $d0bc\r
-        and     #$80\r
-        sta     isnotscpu\r
-        lda     $07e8\r
-        pha                             ; save value incase it was used somewhere else\r
-        ldx     #$ff\r
-@fillloop:                              ; fill from top (bank 255) to bottom\r
-        txa\r
-        pha\r
-.P816\r
-        plb                             ; pull dbr\r
-.P02\r
-        stx     $07e8\r
-        dex\r
-        cpx     #$ff\r
-        bne     @fillloop\r
-        inx\r
-@compareloop:                           ; check from bottom to top\r
-        txa\r
-        pha\r
-.P816\r
-        plb\r
-.P02\r
-        cmp     $07e8\r
-        bne     @found_pages\r
-.P816\r
-        inc\r
-.P02\r
-        sta     $07e8\r
-        cmp     $07e8\r
-        bne     @found_pages\r
-        inx\r
-        bne     @compareloop\r
-@found_pages:\r
-        dex\r
-        lda     #$00\r
-        pha\r
-.P816\r
-        plb\r
-.P02\r
-        pla\r
-        sta     $07e8\r
-        cli\r
-        lda     isnotscpu\r
-        bne     @noextradex\r
-        dex\r
-@noextradex:\r
-        stx     bankcount\r
-        lda     #<EM_ERR_OK\r
-        ldx     #>EM_ERR_OK\r
-        rts\r
-@not_present:\r
-        cli\r
-        lda     #<EM_ERR_NO_DEVICE\r
-        ldx     #>EM_ERR_NO_DEVICE\r
-;       rts                             ; Run into UNINSTALL instead\r
-\r
-\r
-; ------------------------------------------------------------------------\r
-; UNINSTALL routine. Is called before the driver is removed from memory.\r
-; Can do cleanup or whatever. Must not return anything.\r
-;\r
-\r
-UNINSTALL:\r
-        rts\r
-\r
-\r
-; ------------------------------------------------------------------------\r
-; PAGECOUNT: Return the total number of available pages in a/x.\r
-;\r
-\r
-PAGECOUNT:\r
-        lda     #$00                   ; a whole bank is either usable or not\r
-        ldx     bankcount\r
-        rts\r
-\r
-; ------------------------------------------------------------------------\r
-; MAP: Map the page in a/x into memory and return a pointer to the page in\r
-; a/x. The contents of the currently mapped page (if any) may be discarded\r
-; by the driver.\r
-;\r
-\r
-MAP:    sta     curpage                 ; Remember the new page\r
-        stx     curbank                 ; Remember the new bank\r
-\r
-        sta     ptr2+1                  ; src address low\r
-        lda     #$00\r
-        sta     ptr2                    ; src address high\r
-        inx\r
-        ldy     isnotscpu               ; check if not scpu\r
-        bne     @notscpu\r
-        inx\r
-@notscpu:\r
-        stx     tmp2                    ; src bank\r
-\r
-        sta     tmp1                    ; dst bank\r
-\r
-        sta     ptr3+1                  ; length high\r
-        lda     #$ff\r
-        sta     ptr3                    ; length low\r
-\r
-        lda     #<window\r
-        sta     ptr1                    ; dst address low\r
-        ldx     #>window\r
-        stx     ptr1+1                  ; dst address high\r
-\r
-        jsr     transfer\r
-\r
-        rts\r
-\r
-; ------------------------------------------------------------------------\r
-; USE: Tell the driver that the window is now associated with a given page.\r
-\r
-USE:    sta     curpage                 ; Remember the page\r
-        stx     curbank                 ; Remember the bank\r
-        lda     #<window\r
-        ldx     #>window                ; Return the window\r
-        rts\r
-\r
-; ------------------------------------------------------------------------\r
-; COMMIT: Commit changes in the memory window to extended storage.\r
-\r
-COMMIT: lda     curpage                 ; Get the current page\r
-        sta     ptr1+1                  ; dst high\r
-        ldx     #$00\r
-        stx     ptr1                    ; dst low\r
-\r
-        lda     #<window\r
-        sta     ptr2                    ; src low\r
-        lda     #>window\r
-        sta     ptr2+1                  ; src high\r
-\r
-        stx     ptr3+1                  ; length high\r
-        lda     #$ff\r
-        sta     ptr3                    ; length low\r
-\r
-        stx     tmp2                    ; src bank\r
-        ldy     curbank                 ; Get the current bank\r
-        iny\r
-        ldx     isnotscpu\r
-        bne     @notascpu\r
-        iny\r
-@notascpu:\r
-        sty     tmp1                    ; dst bank\r
-\r
-        jsr     transfer\r
-\r
-        rts\r
-\r
-; ------------------------------------------------------------------------\r
-; COPYFROM: Copy from extended into linear memory. A pointer to a structure\r
-; describing the request is passed in a/x.\r
-; The function must not return anything.\r
-;\r
-\r
-COPYFROM:\r
-        sta     ptr4\r
-        stx     ptr4+1                  ; Save the passed em_copy pointer\r
-\r
-        ldy     #EM_COPY::COUNT+1       ; start at the end of the struct\r
-        lda     (ptr4),y                ; get high byte of count\r
-        tax\r
-        dey\r
-        lda     (ptr4),y                ; get low byte of count\r
-        bne     @nodex\r
-        dex\r
-@nodex:\r
-.P816\r
-        dec\r
-.P02\r
-        sta     ptr3                    ; length low\r
-        stx     ptr3+1                  ; length high\r
-        dey\r
-        lda     (ptr4),y                ; get bank\r
-.P816\r
-        inc\r
-.P02\r
-        ldx     isnotscpu\r
-        bne     @notscpu64\r
-.P816\r
-        inc\r
-.P02\r
-@notscpu64:\r
-        sta     tmp2                    ; src bank\r
-        dey\r
-        lda     (ptr4),y                ; get page\r
-        sta     ptr2+1                  ; src high\r
-        dey\r
-        lda     (ptr4),y                ; get offset in page\r
-        sta     ptr2                    ; src low\r
-        dey\r
-        lda     (ptr4),y                ; get memory buffer high\r
-        sta     ptr1+1                  ; dst high\r
-        dey\r
-        lda     (ptr4),y                ; get memory buffer low\r
-        sta     ptr1                    ; dst low\r
-        lda     #$00\r
-        sta     tmp1                    ; dst bank\r
-\r
-        jsr     transfer\r
-\r
-        rts\r
-\r
-; ------------------------------------------------------------------------\r
-; COPYTO: Copy from linear into extended memory. A pointer to a structure\r
-; describing the request is passed in a/x.\r
-; The function must not return anything.\r
-;\r
-\r
-COPYTO: sta     ptr4\r
-        stx     ptr4+1                  ; Save the passed em_copy pointer\r
-\r
-        ldy     #EM_COPY::COUNT+1       ; start at the end of the struct\r
-        lda     (ptr4),y                ; get high byte of count\r
-        tax\r
-        dey\r
-        lda     (ptr4),y                ; get low byte of count\r
-        bne     @nodex2\r
-        dex\r
-@nodex2:\r
-.P816\r
-        dec\r
-.P02\r
-        sta     ptr3                    ; length low\r
-        txa\r
-        sta     ptr3+1                  ; length high\r
-        dey\r
-        lda     (ptr4),y                ; get bank\r
-.P816\r
-        inc\r
-.P02\r
-        ldx     isnotscpu\r
-        bne     @notascpu64\r
-.P816\r
-        inc\r
-.P02\r
-@notascpu64:\r
-        sta     tmp1                    ; dst bank\r
-        dey\r
-        lda     (ptr4),y                ; get page\r
-        sta     ptr1+1                  ; dst high\r
-        dey\r
-        lda     (ptr4),y                ; get page offset\r
-        sta     ptr1                    ; dst low\r
-        dey\r
-        lda     (ptr4),y                ; get memory buffer high\r
-        sta     ptr2+1                  ; src low\r
-        dey\r
-        lda     (ptr4),y                ; get memory buffer low\r
-        sta     ptr2                    ; src high\r
-        lda     #$00\r
-        sta     tmp2                    ; src bank\r
-\r
-        jsr     transfer\r
-\r
-        rts\r
-\r
-; ------------------------------------------------------------------------\r
-; Helper function for moving a block, the following is used:\r
-; ptr1: dst\r
-; ptr2: src\r
-; ptr3: length\r
-; tmp1: dst bank\r
-; tmp2: src bank\r
-\r
-transfer:\r
-.P816\r
-.A8\r
-.I8\r
-        sei\r
-        pha\r
-        phx\r
-        phy\r
-        ldx     tmp1                    ; load srcbank\r
-        stx     @move+1                 ; store srcbank in move + 1\r
-        ldy     tmp2                    ; load dstbank\r
-        sty     @move+2                 ; store dstbank in move + 2\r
-        clc                             ; switch to native mode\r
-        xce\r
-        php                             ; save status bits\r
-        rep     #%00110000              ; set A and index to 16bit\r
-.A16\r
-.I16\r
-        ldy     ptr1\r
-        ldx     ptr2\r
-        lda     ptr3\r
-@move:\r
-        mvn 0,0\r
-        plp                             ; restore status bits\r
-.A8\r
-.I8\r
-        lda     #$00\r
-        pha\r
-        plb                             ; restore dbr\r
-        sec\r
-        xce                             ; switch to emul mode\r
-        ply\r
-        plx\r
-        pla\r
-        cli\r
-        rts\r
-.P02\r
+;
+; Extended memory driver for 65816 based extra RAM. Driver works without
+; problems when statically linked.
+;
+; Marco van den Heuvel, 2015-12-01
+;
+
+        .include        "zeropage.inc"
+
+        .include        "em-kernel.inc"
+        .include        "em-error.inc"
+
+
+        .macpack        generic
+        .macpack        module
+
+
+; ------------------------------------------------------------------------
+; Header. Includes jump table
+
+        module_header   _c64_65816_emd
+
+; Driver signature
+
+        .byte   $65, $6d, $64           ; "emd"
+        .byte   EMD_API_VERSION         ; EM API version number
+
+; Library reference
+
+        .addr   $0000
+
+; Jump table
+
+        .addr   INSTALL
+        .addr   UNINSTALL
+        .addr   PAGECOUNT
+        .addr   MAP
+        .addr   USE
+        .addr   COMMIT
+        .addr   COPYFROM
+        .addr   COPYTO
+
+; ------------------------------------------------------------------------
+; Data.
+
+.bss
+isnotscpu:      .res    1               ; SuperCPU not present
+curpage:        .res    1               ; Current page number
+curbank:        .res    1               ; Current bank number (+1)
+bankcount:      .res    1               ; Number of available banks (pages = banks * 256)
+window:         .res    256             ; Memory "window"
+
+.code
+
+; ------------------------------------------------------------------------
+; INSTALL routine. Is called after the driver is loaded into memory. If
+; possible, check if the hardware is present and determine the amount of
+; memory available.
+; Must return an EM_ERR_xx code in a/x.
+;
+
+INSTALL:
+        sei
+        clc
+        sed
+        lda     #$99
+        adc     #$01                    ; on 65C02, 65SC02, 65CE02, 65802 and 65816 sets the zero flag correctly
+        cld
+        bne     @not_present
+        clc
+.P816
+        sep     #$01                    ; nop #$01 on 65C02/65SC02 and lda ($01,s),y on 65CE02
+.P02
+        bcc     @not_present
+        lda     $d0bc
+        and     #$80
+        sta     isnotscpu
+        lda     $07e8
+        pha                             ; save value incase it was used somewhere else
+        ldx     #$ff
+@fillloop:                              ; fill from top (bank 255) to bottom
+        txa
+        pha
+.P816
+        plb                             ; pull dbr
+.P02
+        stx     $07e8
+        dex
+        cpx     #$ff
+        bne     @fillloop
+        inx
+@compareloop:                           ; check from bottom to top
+        txa
+        pha
+.P816
+        plb
+.P02
+        cmp     $07e8
+        bne     @found_pages
+.P816
+        inc
+.P02
+        sta     $07e8
+        cmp     $07e8
+        bne     @found_pages
+        inx
+        bne     @compareloop
+@found_pages:
+        dex
+        lda     #$00
+        pha
+.P816
+        plb
+.P02
+        pla
+        sta     $07e8
+        cli
+        lda     isnotscpu
+        bne     @noextradex
+        dex
+@noextradex:
+        stx     bankcount
+        lda     #<EM_ERR_OK
+        ldx     #>EM_ERR_OK
+        rts
+@not_present:
+        cli
+        lda     #<EM_ERR_NO_DEVICE
+        ldx     #>EM_ERR_NO_DEVICE
+;       rts                             ; Run into UNINSTALL instead
+
+
+; ------------------------------------------------------------------------
+; UNINSTALL routine. Is called before the driver is removed from memory.
+; Can do cleanup or whatever. Must not return anything.
+;
+
+UNINSTALL:
+        rts
+
+
+; ------------------------------------------------------------------------
+; PAGECOUNT: Return the total number of available pages in a/x.
+;
+
+PAGECOUNT:
+        lda     #$00                   ; a whole bank is either usable or not
+        ldx     bankcount
+        rts
+
+; ------------------------------------------------------------------------
+; MAP: Map the page in a/x into memory and return a pointer to the page in
+; a/x. The contents of the currently mapped page (if any) may be discarded
+; by the driver.
+;
+
+MAP:    sta     curpage                 ; Remember the new page
+        stx     curbank                 ; Remember the new bank
+
+        sta     ptr2+1                  ; src address low
+        lda     #$00
+        sta     ptr2                    ; src address high
+        inx
+        ldy     isnotscpu               ; check if not scpu
+        bne     @notscpu
+        inx
+@notscpu:
+        stx     tmp2                    ; src bank
+
+        sta     tmp1                    ; dst bank
+
+        sta     ptr3+1                  ; length high
+        lda     #$ff
+        sta     ptr3                    ; length low
+
+        lda     #<window
+        sta     ptr1                    ; dst address low
+        ldx     #>window
+        stx     ptr1+1                  ; dst address high
+
+        jsr     transfer
+
+        rts
+
+; ------------------------------------------------------------------------
+; USE: Tell the driver that the window is now associated with a given page.
+
+USE:    sta     curpage                 ; Remember the page
+        stx     curbank                 ; Remember the bank
+        lda     #<window
+        ldx     #>window                ; Return the window
+        rts
+
+; ------------------------------------------------------------------------
+; COMMIT: Commit changes in the memory window to extended storage.
+
+COMMIT: lda     curpage                 ; Get the current page
+        sta     ptr1+1                  ; dst high
+        ldx     #$00
+        stx     ptr1                    ; dst low
+
+        lda     #<window
+        sta     ptr2                    ; src low
+        lda     #>window
+        sta     ptr2+1                  ; src high
+
+        stx     ptr3+1                  ; length high
+        lda     #$ff
+        sta     ptr3                    ; length low
+
+        stx     tmp2                    ; src bank
+        ldy     curbank                 ; Get the current bank
+        iny
+        ldx     isnotscpu
+        bne     @notascpu
+        iny
+@notascpu:
+        sty     tmp1                    ; dst bank
+
+        jsr     transfer
+
+        rts
+
+; ------------------------------------------------------------------------
+; COPYFROM: Copy from extended into linear memory. A pointer to a structure
+; describing the request is passed in a/x.
+; The function must not return anything.
+;
+
+COPYFROM:
+        sta     ptr4
+        stx     ptr4+1                  ; Save the passed em_copy pointer
+
+        ldy     #EM_COPY::COUNT+1       ; start at the end of the struct
+        lda     (ptr4),y                ; get high byte of count
+        tax
+        dey
+        lda     (ptr4),y                ; get low byte of count
+        bne     @nodex
+        dex
+@nodex:
+.P816
+        dec
+.P02
+        sta     ptr3                    ; length low
+        stx     ptr3+1                  ; length high
+        dey
+        lda     (ptr4),y                ; get bank
+.P816
+        inc
+.P02
+        ldx     isnotscpu
+        bne     @notscpu64
+.P816
+        inc
+.P02
+@notscpu64:
+        sta     tmp2                    ; src bank
+        dey
+        lda     (ptr4),y                ; get page
+        sta     ptr2+1                  ; src high
+        dey
+        lda     (ptr4),y                ; get offset in page
+        sta     ptr2                    ; src low
+        dey
+        lda     (ptr4),y                ; get memory buffer high
+        sta     ptr1+1                  ; dst high
+        dey
+        lda     (ptr4),y                ; get memory buffer low
+        sta     ptr1                    ; dst low
+        lda     #$00
+        sta     tmp1                    ; dst bank
+
+        jsr     transfer
+
+        rts
+
+; ------------------------------------------------------------------------
+; COPYTO: Copy from linear into extended memory. A pointer to a structure
+; describing the request is passed in a/x.
+; The function must not return anything.
+;
+
+COPYTO: sta     ptr4
+        stx     ptr4+1                  ; Save the passed em_copy pointer
+
+        ldy     #EM_COPY::COUNT+1       ; start at the end of the struct
+        lda     (ptr4),y                ; get high byte of count
+        tax
+        dey
+        lda     (ptr4),y                ; get low byte of count
+        bne     @nodex2
+        dex
+@nodex2:
+.P816
+        dec
+.P02
+        sta     ptr3                    ; length low
+        txa
+        sta     ptr3+1                  ; length high
+        dey
+        lda     (ptr4),y                ; get bank
+.P816
+        inc
+.P02
+        ldx     isnotscpu
+        bne     @notascpu64
+.P816
+        inc
+.P02
+@notascpu64:
+        sta     tmp1                    ; dst bank
+        dey
+        lda     (ptr4),y                ; get page
+        sta     ptr1+1                  ; dst high
+        dey
+        lda     (ptr4),y                ; get page offset
+        sta     ptr1                    ; dst low
+        dey
+        lda     (ptr4),y                ; get memory buffer high
+        sta     ptr2+1                  ; src low
+        dey
+        lda     (ptr4),y                ; get memory buffer low
+        sta     ptr2                    ; src high
+        lda     #$00
+        sta     tmp2                    ; src bank
+
+        jsr     transfer
+
+        rts
+
+; ------------------------------------------------------------------------
+; Helper function for moving a block, the following is used:
+; ptr1: dst
+; ptr2: src
+; ptr3: length
+; tmp1: dst bank
+; tmp2: src bank
+
+transfer:
+.P816
+.A8
+.I8
+        sei
+        pha
+        phx
+        phy
+        ldx     tmp1                    ; load srcbank
+        stx     @move+1                 ; store srcbank in move + 1
+        ldy     tmp2                    ; load dstbank
+        sty     @move+2                 ; store dstbank in move + 2
+        clc                             ; switch to native mode
+        xce
+        php                             ; save status bits
+        rep     #%00110000              ; set A and index to 16bit
+.A16
+.I16
+        ldy     ptr1
+        ldx     ptr2
+        lda     ptr3
+@move:
+        mvn 0,0
+        plp                             ; restore status bits
+.A8
+.I8
+        lda     #$00
+        pha
+        plb                             ; restore dbr
+        sec
+        xce                             ; switch to emul mode
+        ply
+        plx
+        pla
+        cli
+        rts
+.P02
index 9e723834546c4eb2522f8cdf3733be2e2c2f65b4..3c4856446e54d6b14531816ae8e914e4508f9453 100644 (file)
@@ -18,7 +18,7 @@ _clrscr:
         lda     #$50    ; VRAM offset high ($10 OR $40)
         sta     VDP_CONTROL_W
 
-        lda     #$C0    ; Space from ROM setup
+        lda     #$40    ; Space char from ROM setup
 
         ldx     #0
         ldy     #3
@@ -34,8 +34,8 @@ L1:     sta     VDP_DATA_W
         lda     #0
         sta     CURSOR_X
         sta     CURSOR_Y
-        sta     <SCREEN_PTR
+        sta     SCREEN_PTR
         lda     #$10
-        sta      >SCREEN_PTR
+        sta     SCREEN_PTR+1
 
         rts
index ff60494b9e2d1dc07c4e59a58cd253fc0d509911..437b738b2a3d62ea32fe2e616c8620ed9777ee88 100644 (file)
@@ -96,8 +96,8 @@ BAD_CHAR:
         jmp     plot
 
 ;-----------------------------------------------------------------------------
-; Initialize the conio subsystem. Code goes into the INIT segment, which may
-; be reused after startup.
+; Initialize the conio subsystem. "INIT" segment is nothing special on the
+; Creativision, it is part of the "ROM" memory.
 
 .segment        "INIT"
 
@@ -122,4 +122,4 @@ LL:     lda     boxchars,x
         bne     LL
 
         cli
-        jmp plot
+        jmp     plot
index 6faec38ebf0eee3db4caea7de347822cf363ee48..5185ff237fe979f2dc79e1a8ba060b066fc0fd91 100644 (file)
@@ -31,9 +31,6 @@ entry:
         ldx     #<__RAM_START__ - 1
         txs
 
-        ; Start interrupts
-        cli
-
         ; Clear the BSS data
         jsr     zerobss
 
@@ -49,13 +46,21 @@ entry:
         ; Call module constructors
         jsr     initlib
 
+        ; enable vertical blank interrupts in the display controller
+        lda      #$E0           ; 16K RAM, Active Display, Mode 1, VBI enabled
+        ldx      #$01           ; Register 1
+        jsr      BIOS_WRITE_VDP_REG
+
+        ; Start interrupts
+        cli
+
         ; Call main()
         jsr     callmain
 
         ; Call module destructors. This is also the _exit entry.
 _exit:  jsr     donelib
 
-        ; TODO: Replace with some sort of reset
+        ; A Creativision program isn't supposed to exit.
 loop:   jmp loop
 
 ; ------------------------------------------------------------------------
@@ -81,7 +86,7 @@ irq2:   jmp     BIOS_IRQ2_ADDR
         ; VDP Setup
         ; This sets to Graphics Mode 1
         .byte   $00             ; Register 0
-        .byte   $C0             ; Register 1 16K RAM, Active Display, Mode 1
+        .byte   $C0             ; Register 1 16K RAM, Active Display, Mode 1, VBI disabled
         .byte   $04             ; Register 2 Name Table at $1000 - $12FF
         .byte   $60             ; Register 3 Colour Table at $1800 - $181F
         .byte   $00             ; Register 4 Pattern Table at $0000 - $07FF
index 37b927d08c6fa40497e66cf15c963ca619f830ba..3f167464a1bdc1d3db5d250281b21cc1ff4f4a27 100644 (file)
@@ -1,60 +1,69 @@
 ;
 ; Standard joystick driver for the Creativision.
 ;
-; Christian Groessler, 2017-02-06
+; Christian Groessler, 2017-03-08
 ;
 
-        .include        "zeropage.inc"
+                .include        "zeropage.inc"
 
-        .include        "joy-kernel.inc"
-        .include        "joy-error.inc"
-        .include        "creativision.inc"
+                .include        "joy-kernel.inc"
+                .include        "joy-error.inc"
+                .include        "creativision.inc"
 
-        .macpack        module
+                .macpack        module
 
 
 ; ------------------------------------------------------------------------
 ; Header. Includes jump table
 
-        module_header   _creativisionstd_joy
+               module_header   _creativisionstd_joy
 
 ; Driver signature
 
-        .byte   $6A, $6F, $79           ; "joy"
-        .byte   JOY_API_VERSION         ; Driver API version number
+                .byte   $6A, $6F, $79           ; "joy"
+                .byte   JOY_API_VERSION         ; Driver API version number
 
 ; Library reference
 
-        .addr   $0000
+                .addr   $0000
 
-; Button state masks (8 values)
+; Symbolic names for joystick masks (similar names like the defines in joystick.h, but not related to them)
 
-        .byte   $10                     ; JOY_UP
-        .byte   $04                     ; JOY_DOWN
-        .byte   $20                     ; JOY_LEFT
-        .byte   $08                     ; JOY_RIGHT
-        .byte   $01                     ; JOY_FIRE (button #1)
-        .byte   $02                     ; JOY_FIRE2 (button #2)
-        .byte   $00                     ; Future expansion
-        .byte   $00                     ; Future expansion
+JOY_UP          =       $10
+JOY_DOWN        =       $04
+JOY_LEFT        =       $20
+JOY_RIGHT       =       $08
+JOY_FIRE        =       $01
+JOY_FIRE2       =       $02
+
+; Joystick state masks (8 values)
+
+                .byte   JOY_UP
+                .byte   JOY_DOWN
+                .byte   JOY_LEFT
+                .byte   JOY_RIGHT
+                .byte   JOY_FIRE
+                .byte   JOY_FIRE2
+                .byte   $00                     ; Future expansion
+                .byte   $00                     ; Future expansion
 
 ; Jump table.
 
-        .addr   INSTALL
-        .addr   UNINSTALL
-        .addr   COUNT
-        .addr   READJOY
-        .addr   0                       ; IRQ entry not used
+                .addr   INSTALL
+                .addr   UNINSTALL
+                .addr   COUNT
+                .addr   READJOY
+                .addr   0                       ; IRQ entry not used
 
 ; ------------------------------------------------------------------------
 ; Constants
 
-JOY_COUNT       = 2                     ; Number of joysticks we support
+JOY_COUNT       =       2                       ; Number of joysticks we support
 
 ; ------------------------------------------------------------------------
 ; Code
 
-        .code
+                .code
 
 ; ------------------------------------------------------------------------
 ; INSTALL routine. Is called after the driver is loaded into memory. If
@@ -63,131 +72,180 @@ JOY_COUNT       = 2                     ; Number of joysticks we support
 ; Must return an JOY_ERR_xx code in a/x.
 ;
 
-INSTALL:
-        lda     #JOY_ERR_OK
-        ldx     #0
-;       rts                             ; Fall through
+INSTALL:        lda     #JOY_ERR_OK
+                ldx     #0
+;               rts                             ; Fall through
 
 ; ------------------------------------------------------------------------
 ; UNINSTALL routine. Is called before the driver is removed from memory.
 ; Can do cleanup or whatever. Must not return anything.
 ;
 
-UNINSTALL:
-        rts
+UNINSTALL:      rts
 
 
 ; ------------------------------------------------------------------------
 ; COUNT: Return the total number of available joysticks in a/x.
 ;
 
-COUNT:
-        lda     #<JOY_COUNT
-        ldx     #>JOY_COUNT
-        rts
+COUNT:          lda     #<JOY_COUNT
+                ldx     #>JOY_COUNT
+                rts
 
 ; ------------------------------------------------------------------------
 ; READ: Read a particular joystick passed in A.
 ;
 
-READJOY:
-        and     #1                      ; fix joystick number
-        bne     READJOY_1               ; read right joystick
+READJOY:        and     #1                      ; fix joystick number
+                bne     READJOY_1               ; read right joystick
 
 ; Read left joystick
 
-        ldx     ZP_JOY0_DIR
-        lda     ZP_JOY0_BUTTONS
-        jmp     convert                 ; convert joystick state to sane cc65 values
+                ldx     ZP_JOY0_DIR
+                lda     ZP_JOY0_BUTTONS
+                jmp     convert                 ; convert joystick state to cc65 values
 
 ; Read right joystick
 
-READJOY_1:
-
-        ldx     ZP_JOY1_DIR
-        lda     ZP_JOY1_BUTTONS
-        lsr     a
-        lsr     a
-        ;jmp    convert                 ; convert joystick state to sane cc65 values
-                                        ; fall thru...
+READJOY_1:      ldx     ZP_JOY1_DIR
+                lda     ZP_JOY1_BUTTONS
+                lsr     a
+                lsr     a
+                ;jmp    convert                 ; convert joystick state to cc65 values
+                                                ; fall thru...
 
 ; ------------------------------------------------------------------------
 ; convert: make runtime lib compatible values
-;       A - buttons
-;       X - direction
+;       inputs:
+;               A - buttons
+;               X - direction
 ;
 
 convert:
-        ldy     #0
-        sty     retval                  ; initialize return value
 
 ; ------
 ; buttons:
-        ; Port values are for the left hand joystick (right hand joystick
-        ; values were shifted to the right to be identical).
-        ; Why are there two bits indicating a pressed trigger?
-        ; According to the "Second book of programs for the Dick Smith Wizard"
-        ; (pg. 88ff), the left hand fire button gives the value of
-        ; %00010001 and the right hand button gives %00100010
-        ; Why two bits? Am I missing something? Can there be cases that just
-        ; one of those bits is set?
-        ; We just test if any of those two bits is not zero...
-
-        tay
-        and     #%00010001
-        beq     cnv_1
-
-        inc     retval                  ; left button pressed
-
-cnv_1:  tya
-        and     #%00100010
-        beq     cnv_2
-
-        lda     #$02
-        ora     retval
-        sta     retval                  ; right button pressed
+; Port values are for the left hand joystick (right hand joystick
+; values were shifted to the right to be identical).
+; Why are there two bits indicating a pressed trigger?
+; According to the "Second book of programs for the Dick Smith Wizard"
+; (pg. 88ff), the left hand fire button gives the value of
+; %00010001 and the right hand button gives %00100010
+; Why two bits? Can there be cases that just one of those bits is set?
+; Until these questions have been answered, we only use the lower two
+; bits and ignore the upper ones...
+
+                and     #%00000011              ; button status came in in A, strip high bits
+                sta     retval                  ; initialize 'retval' with button status
 
 ; ------
 ; direction:
-cnv_2:  txa
-        ; tested with https://sourceforge.net/projects/creativisionemulator
-        ; $49 - %01001001 - up
-        ; $41 - %01000001 - down
-        ; $4D - %01001101 - left
-        ; $45 - %01000101 - right
-        ;
-        ; are these correct? "Second book of programs for the Dick Smith Wizard" pg. 85 says something different
-        ; ignored for now...
-        ; $85 - %10000101 - up + right
-        ; $8D - %10001101 - down + left
-        ; $89 - %10001001 - up + left
-        ; $85 - %10000101 - down + right (emulator bug?)
-
-        bit     testbit                 ; bit #0 set?
-        beq     done                    ; no, no direction
-
-        and     #%00001100              ; mask out other bits
-        lsr     a
-        lsr     a
-        tax
-        lda     #%00000100              ; init bitmask
-loop:   dex
-        bmi     done2
-        asl     a
-        bne     loop
-
-done2:  ora     retval
-        rts
-
-done:   lda     retval
-        rts
+; CV has a 16-direction joystick
+;
+; port values: (compass points)
+; N      -  $49 - %01001001
+; NNE    -  $48 - %01001000
+; NE     -  $47 - %01000111
+; ENE    -  $46 - %01000110
+; E      -  $45 - %01000101
+; ESE    -  $44 - %01000100
+; SE     -  $43 - %01000011
+; SSE    -  $42 - %01000010
+; S      -  $41 - %01000001
+; SSW    -  $40 - %01000000
+; SW     -  $4F - %01001111
+; WSW    -  $4E - %01001110
+; W      -  $4D - %01001101
+; WNW    -  $4C - %01001100
+; NW     -  $4B - %01001011
+; NNW    -  $4A - %01001010
+; center -  $00 - %00000000
+;
+; mapping to cc65 definitions (4-direction joystick with 8 possible directions thru combinations)
+; N, E, S, W            ->      JOY_UP, JOY_RIGHT, JOY_DOWN, JOY_LEFT
+; NE, SE, SW, NW        ->      (JOY_UP | JOY_RIGHT), (JOY_DOWN | JOY_RIGHT), (JOY_DOWN | JOY_LEFT), (JOY_UP | JOY_LEFT)
+; NNE, ENE, ESE, SSE, SSW, WSW, WNW, NNW:
+;  toggle between straight and diagonal direction for every call, e.g.
+;  NNE:
+;    call to READJOY:   return JOY_UP | JOY_RIGHT
+;    call to READJOY:   return JOY_UP
+;    call to READJOY:   return JOY_UP | JOY_RIGHT
+;    call to READJOY:   return JOY_UP
+;    call to READJOY:   return JOY_UP | JOY_RIGHT
+;    etc...
+
+                txa                             ; move direction status into A
+                beq     done                    ; center position (no bits are set), nothing to do
+
+                and     #$0F                    ; get rid of the "$40" bit
+                bit     bit0                    ; is it a "three letter" direction (NNE, ENE, etc.)?
+                beq     special                 ; yes (bit #0 is zero)
+
+                lsr     a                       ; create index into table
+                tax
+                lda     dirtable,x
+done:           ora     retval                  ; include "button" bits
+                ldx     #0
+                rts
+
+; NNE, ENE, ESE, SSE, SSW, WSW, WNW, NNW
+
+special:        lsr     a
+                tax
+
+                lda     toggler                 ; toggle the toggler
+                eor     #$01
+                sta     toggler
+                bne     spec_1                  ; toggler is 1, use spectable_1 entry
+
+                lda     spectable_0,x           ; toggler is 0, use spectable_0 entry
+                bne     done                    ; jump always
+
+spec_1:         lda     spectable_1,x
+                bne     done                    ; jump always
 
 ; ------------------------------------------------------------------------
 ;
-        .data
-testbit:.byte   $01
+                .rodata
+
+                ; a mapping table of "port values" to "cc65 values"
+                ; port value had been shifted one bit to the right (range 0..7)
+dirtable:       .byte   JOY_DOWN                ; S
+                .byte   JOY_DOWN | JOY_RIGHT    ; SE
+                .byte   JOY_RIGHT               ; E
+                .byte   JOY_UP   | JOY_RIGHT    ; NE
+                .byte   JOY_UP                  ; N
+                .byte   JOY_UP   | JOY_LEFT     ; NW
+                .byte   JOY_LEFT                ; W
+                .byte   JOY_DOWN | JOY_LEFT     ; SW
+
+                ; two "special" mapping tables for three-letter directions (NNE, etc.)
+spectable_0:    .byte   JOY_DOWN                ; SSW
+                .byte   JOY_DOWN                ; SSE
+                .byte   JOY_RIGHT               ; ESE
+                .byte   JOY_RIGHT               ; ENE
+                .byte   JOY_RIGHT               ; NNE
+                .byte   JOY_UP                  ; NNW
+                .byte   JOY_LEFT                ; WNW
+                .byte   JOY_LEFT                ; WSW
+
+spectable_1:    .byte   JOY_DOWN | JOY_LEFT     ; SSW
+                .byte   JOY_DOWN | JOY_RIGHT    ; SSE
+                .byte   JOY_DOWN | JOY_RIGHT    ; ESE
+                .byte   JOY_UP   | JOY_RIGHT    ; ENE
+                .byte   JOY_UP   | JOY_RIGHT    ; NNE
+                .byte   JOY_UP   | JOY_LEFT     ; NNW
+                .byte   JOY_UP   | JOY_LEFT     ; WNW
+                .byte   JOY_DOWN | JOY_LEFT     ; WSW
 
 ; ------------------------------------------------------------------------
 ;
-        .bss
-retval: .res    0
+bit0:           .byte   $01
+
+; ------------------------------------------------------------------------
+;
+                .bss
+toggler:        .res    1
+retval:         .res    1
+
+                .end
diff --git a/libsrc/creativision/mainargs.s b/libsrc/creativision/mainargs.s
deleted file mode 100644 (file)
index cda76d8..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-;
-; Ullrich von Bassewitz, 2003-03-07
-;
-; Setup arguments for main
-;
-
-
-        .constructor    initmainargs, 24
-        .import         __argc, __argv
-
-
-;---------------------------------------------------------------------------
-; Get possible command-line arguments. Goes into the special INIT segment,
-; which may be reused after the startup code is run
-
-.segment        "INIT"
-
-.proc   initmainargs
-
-        rts
-
-.endproc
index 9161645c77899bd30334ba5f4adc86f26f34e56c..f05ad33e014c8a1e7e6df55a3abe0a7bb2c24d2f 100644 (file)
@@ -1,50 +1,50 @@
-;\r
-; char cgetc (void);\r
-;\r
-\r
-        .constructor    initcgetc\r
-        .export         _cgetc\r
-        .import         cursor\r
-\r
-        .include        "osic1p.inc"\r
-        .include        "extzp.inc"\r
-        .include        "zeropage.inc"\r
-\r
-; Initialize one-character buffer that is filled by kbhit()\r
-        .segment        "ONCE"\r
-initcgetc:\r
-        lda     #$00\r
-        sta     CHARBUF         ; No character in buffer initially\r
-        rts\r
-\r
-; Input routine from 65V PROM MONITOR, show cursor if enabled\r
-        .code\r
-_cgetc:\r
-        lda     CHARBUF         ; character in buffer available?\r
-        beq     nobuffer\r
-        tax                     ; save character in X\r
-        lda     #$00\r
-        sta     CHARBUF         ; empty buffer\r
-        beq     restorex        ; restore X and return\r
-nobuffer:\r
-        lda     cursor          ; show cursor?\r
-        beq     nocursor\r
-        ldy     CURS_X\r
-        lda     (SCREEN_PTR),y  ; fetch current character\r
-        sta     tmp1            ; save it\r
-        lda     #$A1            ; full white square\r
-        sta     (SCREEN_PTR),y  ; store at cursor position\r
-nocursor:\r
-        jsr     INPUTC          ; get input character in A\r
-        ldx     cursor\r
-        beq     done            ; was cursor on?\r
-        tax                     ; save A in X\r
-        lda     tmp1            ; fetch saved character\r
-        ldy     CURS_X\r
-        sta     (SCREEN_PTR),y  ; store at cursor position\r
-\r
-restorex:\r
-        txa                     ; restore saved character from X\r
-done:\r
-        ldx     #$00            ; high byte of int return value\r
-        rts\r
+;
+; char cgetc (void);
+;
+
+        .constructor    initcgetc
+        .export         _cgetc
+        .import         cursor
+
+        .include        "osic1p.inc"
+        .include        "extzp.inc"
+        .include        "zeropage.inc"
+
+; Initialize one-character buffer that is filled by kbhit()
+        .segment        "ONCE"
+initcgetc:
+        lda     #$00
+        sta     CHARBUF         ; No character in buffer initially
+        rts
+
+; Input routine from 65V PROM MONITOR, show cursor if enabled
+        .code
+_cgetc:
+        lda     CHARBUF         ; character in buffer available?
+        beq     nobuffer
+        tax                     ; save character in X
+        lda     #$00
+        sta     CHARBUF         ; empty buffer
+        beq     restorex        ; restore X and return
+nobuffer:
+        lda     cursor          ; show cursor?
+        beq     nocursor
+        ldy     CURS_X
+        lda     (SCREEN_PTR),y  ; fetch current character
+        sta     tmp1            ; save it
+        lda     #$A1            ; full white square
+        sta     (SCREEN_PTR),y  ; store at cursor position
+nocursor:
+        jsr     INPUTC          ; get input character in A
+        ldx     cursor
+        beq     done            ; was cursor on?
+        tax                     ; save A in X
+        lda     tmp1            ; fetch saved character
+        ldy     CURS_X
+        sta     (SCREEN_PTR),y  ; store at cursor position
+
+restorex:
+        txa                     ; restore saved character from X
+done:
+        ldx     #$00            ; high byte of int return value
+        rts
index eabeaf79e7ea61cae53ab85ee6adf3180f128f04..aaa03ba6189a05b56ddffdbf0ddbe87b85c29ecf 100644 (file)
@@ -1,4 +1,4 @@
-; Addresses\r
-INPUTC          := $FD00        ; Input character from keyboard\r
-RESET           := $FF00        ; Reset address, show boot prompt\r
-KBD             := $DF00        ; Polled keyboard register\r
+; Addresses
+INPUTC          := $FD00        ; Input character from keyboard
+RESET           := $FF00        ; Reset address, show boot prompt
+KBD             := $DF00        ; Polled keyboard register
index fc832478199a2fd821dd42562c65a7f0ba647fb4..9399d7eee073f11b169dc6d48ea8e77250c812ea 100644 (file)
-;\r
-; Macro definitions for screen layout modules\r
-;\r
-\r
-        .include        "extzp.inc"\r
-        \r
-.linecont +\r
-\r
-;\r
-; Internal function for screensize()\r
-;\r
-.macro  osi_screensize ScrWidth, ScrHeight\r
-                                ; Macro implementation of internal screensize\r
-                                ; function for given width and height in\r
-                                ; characters\r
-                                \r
-        .export         screensize\r
-\r
-.proc   screensize\r
-        ldx     #ScrWidth\r
-        ldy     #ScrHeight\r
-        rts\r
-.endproc\r
-.endmacro\r
-\r
-;\r
-; void clrscr (void);\r
-;\r
-.macro  osi_clrscr ScrBase, ScrRamSize\r
-\r
-        .export         _clrscr\r
-\r
-.proc   _clrscr\r
-        lda     #<ScrBase       ; Fill whole video RAM with blanks by calling\r
-        ldx     #>ScrBase       ; memset appropriately\r
-        jsr     pushax\r
-        \r
-        lda     #' '\r
-        ldx     #$00\r
-        jsr     pushax\r
-        \r
-        lda     #<ScrRamSize\r
-        ldx     #>ScrRamSize\r
-        jsr     _memset\r
-\r
-        lda     #$00            ; Cursor in upper left corner\r
-        sta     CURS_X\r
-        sta     CURS_Y\r
-        \r
-        jmp     plot            ; Set the cursor position\r
-.endproc\r
-\r
-.endmacro\r
-\r
-;\r
-; cputc/cputcxy for Challenger 1P\r
-; Based on PET/CBM implementation\r
-;\r
-\r
-.macro  osi_cputfuncs ScrBase, ScrFirstChar, ScrWidth, ScrHeight, \\r
-                         ScrollDist, ScrLo, ScrHi\r
-\r
-                                ; Number of characters to move for scrolling\r
-                                ; by one line\r
-ScrollLength    = (ScrHeight - 1) * ScrollDist\r
-\r
-;\r
-; void cputcxy (unsigned char x, unsigned char y, char c);\r
-; void cputc (char c);\r
-;\r
-        .export         _cputcxy, _cputc, cputdirect, putchar\r
-        .export         newline, plot\r
-\r
-_cputcxy:\r
-        pha                     ; Save C\r
-        jsr     gotoxy          ; Set cursor, drop x and y\r
-        pla                     ; Restore C\r
-\r
-; Plot a character - also used as internal function\r
-\r
-_cputc: cmp     #$0A            ; CR?\r
-        bne     L1\r
-        lda     #0\r
-        sta     CURS_X\r
-        beq     plot            ; Recalculate pointers\r
-\r
-L1:     cmp     #$0D            ; LF?\r
-        beq     newline         ; Recalculate pointers\r
-\r
-cputdirect:\r
-        jsr     putchar         ; Write the character to the screen\r
-\r
-; Advance cursor position, register Y contains horizontal position after\r
-; putchar\r
-\r
-        cpy     #(ScrWidth - 1) ; Check whether line is full\r
-        bne     L3\r
-        jsr     newline         ; New line\r
-        ldy     #$FF            ; + cr\r
-L3:     iny\r
-        sty     CURS_X\r
-        rts\r
-\r
-newline:\r
-        inc     CURS_Y\r
-        lda     CURS_Y\r
-        cmp     #ScrHeight      ; Screen height\r
-        bne     plot\r
-        dec     CURS_Y          ; Bottom of screen reached, scroll\r
-\r
-                                ; Scroll destination address\r
-        lda     #<(ScrBase + ScrFirstChar)\r
-        ldx     #>(ScrBase + ScrFirstChar)\r
-        jsr     pushax\r
-        \r
-                                ; Scroll source address\r
-        lda     #<(ScrBase + ScrFirstChar + ScrollDist)\r
-        ldx     #>(ScrBase + ScrFirstChar + ScrollDist)\r
-        jsr     pushax\r
-        \r
-                                ; Number of characters to move\r
-        lda     #<ScrollLength\r
-        ldx     #>ScrollLength\r
-        jsr     _memmove\r
-\r
-                                ; Address of first character in last line\r
-                                ; of screen\r
-        lda     #<(ScrBase + ScrFirstChar + ScrollLength)\r
-        sta     ptr1\r
-        lda     #>(ScrBase + ScrFirstChar + ScrollLength)\r
-        sta     ptr1+1\r
-        \r
-        ldy     #ScrWidth       ; Fill last line with blanks\r
-        lda     #' '\r
-clrln:  sta     (ptr1),y\r
-        dey\r
-        bpl     clrln\r
-\r
-plot:   ldy     CURS_Y\r
-        lda     ScrLo,y\r
-        sta     SCREEN_PTR\r
-        lda     ScrHi,y\r
-        sta     SCREEN_PTR+1\r
-        rts\r
-\r
-; Write one character to the screen without doing anything else, return X\r
-; position in register Y\r
-\r
-putchar:\r
-        ldy     CURS_X\r
-        sta     (SCREEN_PTR),y  ; Set char\r
-        rts\r
-        \r
-.endmacro\r
-\r
-.macro osi_screen_funcs ScrBase, ScrRamSize, ScrFirstChar, \\r
-                        ScrWidth, ScrHeight, ScrollDist\r
-\r
-        .import         gotoxy\r
-        .import         _memmove, _memset, pushax\r
-        .importzp       ptr1\r
-\r
-.rodata\r
-\r
-; Screen address tables - offset to real screen\r
-ScrTabLo:\r
-        .repeat ScrHeight, I\r
-        .byte <(ScrBase + ScrFirstChar + I * ScrollDist)\r
-        .endrep\r
-        \r
-ScrTabHi:\r
-        .repeat ScrHeight, I\r
-        .byte >(ScrBase + ScrFirstChar + I * ScrollDist)\r
-        .endrep\r
-\r
-.code\r
-\r
-osi_cputfuncs   ScrBase, ScrFirstChar, ScrWidth, ScrHeight, \\r
-                         ScrollDist, ScrTabLo, ScrTabHi\r
-osi_screensize  ScrWidth, ScrHeight\r
-osi_clrscr      ScrBase, ScrRamSize\r
-\r
+;
+; Macro definitions for screen layout modules
+;
+
+        .include        "extzp.inc"
+        
+.linecont +
+
+;
+; Internal function for screensize()
+;
+.macro  osi_screensize ScrWidth, ScrHeight
+                                ; Macro implementation of internal screensize
+                                ; function for given width and height in
+                                ; characters
+                                
+        .export         screensize
+
+.proc   screensize
+        ldx     #ScrWidth
+        ldy     #ScrHeight
+        rts
+.endproc
+.endmacro
+
+;
+; void clrscr (void);
+;
+.macro  osi_clrscr ScrBase, ScrRamSize
+
+        .export         _clrscr
+
+.proc   _clrscr
+        lda     #<ScrBase       ; Fill whole video RAM with blanks by calling
+        ldx     #>ScrBase       ; memset appropriately
+        jsr     pushax
+        
+        lda     #' '
+        ldx     #$00
+        jsr     pushax
+        
+        lda     #<ScrRamSize
+        ldx     #>ScrRamSize
+        jsr     _memset
+
+        lda     #$00            ; Cursor in upper left corner
+        sta     CURS_X
+        sta     CURS_Y
+        
+        jmp     plot            ; Set the cursor position
+.endproc
+
+.endmacro
+
+;
+; cputc/cputcxy for Challenger 1P
+; Based on PET/CBM implementation
+;
+
+.macro  osi_cputfuncs ScrBase, ScrFirstChar, ScrWidth, ScrHeight, \
+                         ScrollDist, ScrLo, ScrHi
+
+                                ; Number of characters to move for scrolling
+                                ; by one line
+ScrollLength    = (ScrHeight - 1) * ScrollDist
+
+;
+; void cputcxy (unsigned char x, unsigned char y, char c);
+; void cputc (char c);
+;
+        .export         _cputcxy, _cputc, cputdirect, putchar
+        .export         newline, plot
+
+_cputcxy:
+        pha                     ; Save C
+        jsr     gotoxy          ; Set cursor, drop x and y
+        pla                     ; Restore C
+
+; Plot a character - also used as internal function
+
+_cputc: cmp     #$0A            ; CR?
+        bne     L1
+        lda     #0
+        sta     CURS_X
+        beq     plot            ; Recalculate pointers
+
+L1:     cmp     #$0D            ; LF?
+        beq     newline         ; Recalculate pointers
+
+cputdirect:
+        jsr     putchar         ; Write the character to the screen
+
+; Advance cursor position, register Y contains horizontal position after
+; putchar
+
+        cpy     #(ScrWidth - 1) ; Check whether line is full
+        bne     L3
+        jsr     newline         ; New line
+        ldy     #$FF            ; + cr
+L3:     iny
+        sty     CURS_X
+        rts
+
+newline:
+        inc     CURS_Y
+        lda     CURS_Y
+        cmp     #ScrHeight      ; Screen height
+        bne     plot
+        dec     CURS_Y          ; Bottom of screen reached, scroll
+
+                                ; Scroll destination address
+        lda     #<(ScrBase + ScrFirstChar)
+        ldx     #>(ScrBase + ScrFirstChar)
+        jsr     pushax
+        
+                                ; Scroll source address
+        lda     #<(ScrBase + ScrFirstChar + ScrollDist)
+        ldx     #>(ScrBase + ScrFirstChar + ScrollDist)
+        jsr     pushax
+        
+                                ; Number of characters to move
+        lda     #<ScrollLength
+        ldx     #>ScrollLength
+        jsr     _memmove
+
+                                ; Address of first character in last line
+                                ; of screen
+        lda     #<(ScrBase + ScrFirstChar + ScrollLength)
+        sta     ptr1
+        lda     #>(ScrBase + ScrFirstChar + ScrollLength)
+        sta     ptr1+1
+        
+        ldy     #ScrWidth       ; Fill last line with blanks
+        lda     #' '
+clrln:  sta     (ptr1),y
+        dey
+        bpl     clrln
+
+plot:   ldy     CURS_Y
+        lda     ScrLo,y
+        sta     SCREEN_PTR
+        lda     ScrHi,y
+        sta     SCREEN_PTR+1
+        rts
+
+; Write one character to the screen without doing anything else, return X
+; position in register Y
+
+putchar:
+        ldy     CURS_X
+        sta     (SCREEN_PTR),y  ; Set char
+        rts
+        
+.endmacro
+
+.macro osi_screen_funcs ScrBase, ScrRamSize, ScrFirstChar, \
+                        ScrWidth, ScrHeight, ScrollDist
+
+        .import         gotoxy
+        .import         _memmove, _memset, pushax
+        .importzp       ptr1
+
+.rodata
+
+; Screen address tables - offset to real screen
+ScrTabLo:
+        .repeat ScrHeight, I
+        .byte <(ScrBase + ScrFirstChar + I * ScrollDist)
+        .endrep
+        
+ScrTabHi:
+        .repeat ScrHeight, I
+        .byte >(ScrBase + ScrFirstChar + I * ScrollDist)
+        .endrep
+
+.code
+
+osi_cputfuncs   ScrBase, ScrFirstChar, ScrWidth, ScrHeight, \
+                         ScrollDist, ScrTabLo, ScrTabHi
+osi_screensize  ScrWidth, ScrHeight
+osi_clrscr      ScrBase, ScrRamSize
+
 .endmacro
\ No newline at end of file
diff --git a/libsrc/telestrat/clrscr.s b/libsrc/telestrat/clrscr.s
new file mode 100644 (file)
index 0000000..f2b8faf
--- /dev/null
@@ -0,0 +1,35 @@
+;
+; jede jede@oric.org 2017-02-25
+; 
+
+    .export    _clrscr
+       
+    .importzp  sp
+       
+    .include   "telestrat.inc"
+
+.proc _clrscr
+    lda     #<SCREEN
+    ldy     #>SCREEN
+    sta     RES
+    sty     RES+1
+
+    ldy     #<(SCREEN+SCREEN_XSIZE*SCREEN_YSIZE)
+    ldx     #>(SCREEN+SCREEN_XSIZE*SCREEN_YSIZE)
+    lda     #' '
+    BRK_TELEMON XFILLM
+       
+       
+    ; reset prompt position
+    lda     #<(SCREEN+40)
+    sta     ADSCRL
+    lda     #>(SCREEN+40)
+    sta     ADSCRH
+       
+    ; reset display position
+    lda     #$01
+    sta     SCRY
+    lda     #$00
+    sta     SCRX       
+    rts
+.endproc       
diff --git a/libsrc/telestrat/gotox.s b/libsrc/telestrat/gotox.s
new file mode 100644 (file)
index 0000000..d6af0e4
--- /dev/null
@@ -0,0 +1,16 @@
+;
+; jede jede@oric.org 2017-02-25
+;
+    .export    _gotox
+       
+    .import    popa
+       
+    .importzp  sp
+
+    .include   "telestrat.inc"
+
+
+.proc _gotox
+   sta    SCRX
+   rts
+.endproc       
diff --git a/libsrc/telestrat/gotoxy.s b/libsrc/telestrat/gotoxy.s
new file mode 100644 (file)
index 0000000..e0c8154
--- /dev/null
@@ -0,0 +1,19 @@
+;
+; jede jede@oric.org 2017-02-25
+;
+    .export    _gotoxy
+       
+    .import    popa
+       
+    .importzp  sp
+
+    .include   "telestrat.inc"
+
+.proc _gotoxy
+   ; This function move only cursor for display, it does not move the prompt position
+   ; in telemon, there is position for prompt, and another for the cursor
+   sta    SCRY
+   jsr    popa
+   sta    SCRX
+   rts
+.endproc       
diff --git a/libsrc/telestrat/gotoy.s b/libsrc/telestrat/gotoy.s
new file mode 100644 (file)
index 0000000..ed7101c
--- /dev/null
@@ -0,0 +1,13 @@
+;
+; jede jede@oric.org 2017-02-25
+;
+    .export    _gotoy
+
+    .importzp  sp
+
+    .include   "telestrat.inc"
+
+.proc _gotoy
+   sta     SCRY
+   rts
+.endproc       
diff --git a/libsrc/telestrat/wherex.s b/libsrc/telestrat/wherex.s
new file mode 100644 (file)
index 0000000..0dd5139
--- /dev/null
@@ -0,0 +1,14 @@
+;
+; jede jede@oric.org 2017-02-25
+;
+    .export    _wherex
+       
+    .importzp  sp
+
+    .include   "telestrat.inc"
+
+.proc _wherex
+    ldx    #$00
+    lda    SCRX
+    rts
+.endproc       
diff --git a/libsrc/telestrat/wherey.s b/libsrc/telestrat/wherey.s
new file mode 100644 (file)
index 0000000..4958f10
--- /dev/null
@@ -0,0 +1,14 @@
+;
+; jede jede@oric.org 2017-02-25
+; 
+    .export    _wherey
+       
+    .importzp  sp
+
+    .include   "telestrat.inc"
+
+.proc _wherey
+    ldx    #$00
+    lda    SCRY
+    rts
+.endproc       
index edfeca689c42ff1b92823474d3266110f0e0bd8d..94994002224dd425bb977f1416098bce15233c8a 100644 (file)
@@ -90,7 +90,7 @@ LDFLAGS_tgidemo_atarixl    = --start-addr 0x4000
 %: %.s
 
 .c.o:
-       $(CC) $(CFLAGS) -Oirs --codesize 500 -T -g -t $(SYS) $<
+       $(CC) $(CFLAGS) -Ors --codesize 500 -T -g -t $(SYS) $<
        $(AS) $(<:.c=.s)
 
 .s.o:
index 9f1ab29f55a0a89d1945f8e649f11ccd357364cb..48a5c29d35adca95c566a0adf9f490b041ffbab9 100644 (file)
@@ -157,7 +157,7 @@ static void Parse (void)
                   CurTok.Tok == TOK_ASSIGN))) {
 
                 /* We will allocate storage */
-                Decl.StorageClass |= SC_STORAGE | SC_DEF;
+                Decl.StorageClass |= SC_STORAGE;
             }
 
             /* If this is a function declarator that is not followed by a comma
@@ -190,6 +190,13 @@ static void Parse (void)
                 /* Allow initialization */
                 if (CurTok.Tok == TOK_ASSIGN) {
 
+                    /* This is a definition */
+                    if (SymIsDef (Entry)) {
+                        Error ("Global variable `%s' has already been defined",
+                               Entry->Name);
+                    }
+                    Entry->Flags |= SC_DEF;
+
                     /* We cannot initialize types of unknown size, or
                     ** void types in ISO modes.
                     */
@@ -237,18 +244,14 @@ static void Parse (void)
                         Entry->Flags &= ~(SC_STORAGE | SC_DEF);
                     }
 
-                    /* Allocate storage if it is still needed */
-                    if (Entry->Flags & SC_STORAGE) {
-
-                        /* Switch to the BSS segment */
-                        g_usebss ();
-
-                        /* Define a label */
-                        g_defgloblabel (Entry->Name);
-
-                        /* Allocate space for uninitialized variable */
-                        g_res (Size);
-                    }
+                    /* A global (including static) uninitialized variable
+                    ** is only a tentative definition. For example, this is valid:
+                    ** int i;
+                    ** int i;
+                    ** static int j;
+                    ** static int j = 42;
+                    ** Code for these will be generated in FinishCompile.
+                    */
                 }
 
             }
@@ -303,7 +306,7 @@ void Compile (const char* FileName)
     struct tm*  TM;
 
     /* Since strftime is locale dependent, we need the abbreviated month names
-    ** in english.
+    ** in English.
     */
     static const char MonthNames[12][4] = {
         "Jan", "Feb", "Mar", "Apr", "May", "Jun",
@@ -400,20 +403,26 @@ void Compile (const char* FileName)
 void FinishCompile (void)
 /* Emit literals, externals, debug info, do cleanup and optimizations */
 {
-    SymTable* SymTab;
-    SymEntry* Func;
-
-    /* Walk over all functions, doing cleanup, optimizations ... */
-    SymTab = GetGlobalSymTab ();
-    Func   = SymTab->SymHead;
-    while (Func) {
-        if (SymIsOutputFunc (Func)) {
+    SymEntry* Entry;
+
+    /* Walk over all global symbols:
+    ** - for functions do cleanup, optimizations ...
+    ** - generate code for uninitialized global variables
+    */
+    for (Entry = GetGlobalSymTab ()->SymHead; Entry; Entry = Entry->NextSym) {
+        if (SymIsOutputFunc (Entry)) {
             /* Function which is defined and referenced or extern */
-            MoveLiteralPool (Func->V.F.LitPool);
-            CS_MergeLabels (Func->V.F.Seg->Code);
-            RunOpt (Func->V.F.Seg->Code);
+            MoveLiteralPool (Entry->V.F.LitPool);
+            CS_MergeLabels (Entry->V.F.Seg->Code);
+            RunOpt (Entry->V.F.Seg->Code);
+        } else if ((Entry->Flags & (SC_STORAGE | SC_DEF | SC_STATIC)) == (SC_STORAGE | SC_STATIC)) {
+            /* Tentative definition of uninitialized global variable */
+            g_usebss ();
+            g_defgloblabel (Entry->Name);
+            g_res (SizeOf (Entry->Type));
+            /* Mark as defined, so that it will be exported not imported */
+            Entry->Flags |= SC_DEF;
         }
-        Func = Func->NextSym;
     }
 
     /* Output the literal pool */
index 8c9d6dcb00d6feb81cf12b7b2cc28316d7023c8f..2d54316cd9cbba88b28f97773107e48c8e132cac 100644 (file)
@@ -389,7 +389,10 @@ unsigned SizeOf (const Type* T)
     switch (UnqualifiedType (T->C)) {
 
         case T_VOID:
-            return 0;   /* Assume voids have size zero */
+            /* A void variable is a cc65 extension.
+            ** Get its size (in bytes).
+            */
+            return T->A.U;
 
         /* Beware: There's a chance that this triggers problems in other parts
            of the compiler. The solution is to fix the callers, because calling
@@ -438,7 +441,7 @@ unsigned SizeOf (const Type* T)
                 /* Array with unspecified size */
                 return 0;
             } else {
-                return T->A.L * SizeOf (T + 1);
+                return T->A.U * SizeOf (T + 1);
             }
 
         default:
index 1630848350892bafc71df8006490d3720c8e35c9..7b543aa55aa913c52ac21af66656a273c61021f6 100644 (file)
@@ -891,6 +891,7 @@ static void ParseTypeSpec (DeclSpec* D, long Default, TypeCode Qualifiers)
         case TOK_VOID:
             NextToken ();
             D->Type[0].C = T_VOID;
+            D->Type[0].A.U = 0;
             D->Type[1].C = T_END;
             break;
 
@@ -2114,7 +2115,7 @@ NextMember:
 
 
 
-static unsigned ParseVoidInit (void)
+static unsigned ParseVoidInit (Type* T)
 /* Parse an initialization of a void variable (special cc65 extension).
 ** Return the number of bytes initialized.
 */
@@ -2181,6 +2182,9 @@ static unsigned ParseVoidInit (void)
     /* Closing brace */
     ConsumeRCurly ();
 
+    /* Number of bytes determined by initializer */
+    T->A.U = Size;
+
     /* Return the number of bytes initialized */
     return Size;
 }
@@ -2216,8 +2220,8 @@ static unsigned ParseInitInternal (Type* T, int AllowFlexibleMembers)
 
         case T_VOID:
             if (IS_Get (&Standard) == STD_CC65) {
-                /* Special cc65 extension in non ANSI mode */
-                return ParseVoidInit ();
+                /* Special cc65 extension in non-ANSI mode */
+                return ParseVoidInit (T);
             }
             /* FALLTHROUGH */
 
index fdf45987370581f3d833104d92f937c4080b7d70..3275332c5490c68b89ab7a5c4b6e560716574144 100644 (file)
@@ -821,7 +821,7 @@ SymEntry* AddGlobalSym (const char* Name, const Type* T, unsigned Flags)
         }
 
         /* An extern declaration must not change the current linkage. */
-        if (IsFunc || (Flags & (SC_EXTERN | SC_DEF)) == SC_EXTERN) {
+        if (IsFunc || (Flags & (SC_EXTERN | SC_STORAGE)) == SC_EXTERN) {
             Flags &= ~SC_EXTERN;
         }
 
index e6f35829527a06f2d4aebd1c5bae2f1bb445e3ab..0320dd895da3785dc00bee2e58572b0ae270fa50 100644 (file)
@@ -11,6 +11,7 @@
 /*                D-70794 Filderstadt                                        */
 /* EMail:         uz@cc65.org                                                */
 /*                                                                           */
+/* Mar-2017, Christian Krueger, added support for 65SC02                     */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
 /* warranty.  In no event will the authors be held liable for any damages    */
 /*                                                                           */
 /*****************************************************************************/
 
-
+/* Known bugs and limitations of the 65C02 simulation:
+ * support currently only on the level of 65SC02:
+   BBRx, BBSx, RMBx, SMBx, WAI and STP are unsupported
+ * BCD flag handling equals 6502 (unchecked if bug is simulated or wrong for
+   6502)
+ * one cycle win for fetch-modify-write instructions ignored
+   (e.g. ROL abs,x takes only 6 cycles if no page break occurs)
+ */
 
 #include "memory.h"
 #include "error.h"
@@ -205,7 +213,23 @@ int PrintCycles;
     unsigned Addr;                                              \
     Cycles = 5;                                                 \
     ZPAddr = MemReadByte (Regs.PC+1);                           \
-    Addr = MemReadZPWord (ZPAddr) + Regs.YR;                    \
+    Addr = MemReadZPWord (ZPAddr);                              \
+    if (PAGE_CROSS (Addr, Regs.YR)) {                           \
+        ++Cycles;                                               \
+    }                                                           \
+    Addr += Regs.YR;                                            \
+    Regs.AC = Regs.AC op MemReadByte (Addr);                    \
+    TEST_ZF (Regs.AC);                                          \
+    TEST_SF (Regs.AC);                                          \
+    Regs.PC += 2
+
+/* (zp) */
+#define AC_OP_ZPIND(op)                                         \
+    unsigned char ZPAddr;                                       \
+    unsigned Addr;                                              \
+    Cycles = 5;                                                 \
+    ZPAddr = MemReadByte (Regs.PC+1);                           \
+    Addr = MemReadZPWord (ZPAddr);                              \
     Regs.AC = Regs.AC op MemReadByte (Addr);                    \
     TEST_ZF (Regs.AC);                                          \
     TEST_SF (Regs.AC);                                          \
@@ -234,6 +258,9 @@ int PrintCycles;
             }                                                   \
             TEST_CF (Regs.AC);                                  \
             SET_OF ((res < -128) || (res > 127));               \
+            if (CPU != CPU_6502) {                              \
+                ++Cycles;                                       \
+            }                                                   \
         } else {                                                \
             Regs.AC += rhs + GET_CF ();                         \
             TEST_ZF (Regs.AC);                                  \
@@ -313,6 +340,9 @@ int PrintCycles;
             TEST_SF (res);                                      \
             SET_CF (res <= 0xFF);                               \
             SET_OF (((old^rhs) & (old^res) & 0x80));            \
+            if (CPU != CPU_6502) {                              \
+                ++Cycles;                                       \
+            }                                                   \
         } else {                                                \
             Regs.AC -= rhs + (!GET_CF ());                      \
             TEST_ZF (Regs.AC);                                  \
@@ -362,6 +392,21 @@ static void OPC_6502_01 (void)
 
 
 
+static void OPC_65SC02_04 (void)
+/* Opcode $04: TSB zp */
+{
+    unsigned char ZPAddr;
+    unsigned char Val;
+    Cycles = 5;
+    ZPAddr = MemReadByte (Regs.PC+1);
+    Val = MemReadByte (ZPAddr);
+    SET_ZF ((Val & Regs.AC) == 0);
+    MemWriteByte (ZPAddr, (unsigned char)(Val | Regs.AC)); 
+    Regs.PC += 2;
+}
+
+
+
 static void OPC_6502_05 (void)
 /* Opcode $05: ORA zp */
 {
@@ -377,7 +422,7 @@ static void OPC_6502_06 (void)
     unsigned Val;
     Cycles = 5;
     ZPAddr = MemReadByte (Regs.PC+1);
-    Val    = MemReadByte (ZPAddr) << 1;
+    Val = MemReadByte (ZPAddr) << 1;
     MemWriteByte (ZPAddr, (unsigned char) Val);
     TEST_ZF (Val & 0xFF);
     TEST_SF (Val);
@@ -419,6 +464,21 @@ static void OPC_6502_0A (void)
 
 
 
+static void OPC_65SC02_0C (void)
+/* Opcode $0C: TSB abs */
+{
+    unsigned Addr;
+    unsigned char Val;
+    Cycles = 6;
+    Addr = MemReadByte (Regs.PC+1);
+    Val = MemReadByte (Addr);
+    SET_ZF ((Val & Regs.AC) == 0);
+    MemWriteByte (Addr, (unsigned char) (Val | Regs.AC));    
+    Regs.PC += 3;
+}
+
+
+
 static void OPC_6502_0D (void)
 /* Opcode $0D: ORA abs */
 {
@@ -434,7 +494,7 @@ static void OPC_6502_0E (void)
     unsigned Val;
     Cycles = 6;
     Addr = MemReadWord (Regs.PC+1);
-    Val  = MemReadByte (Addr) << 1;
+    Val = MemReadByte (Addr) << 1;
     MemWriteByte (Addr, (unsigned char) Val);
     TEST_ZF (Val & 0xFF);
     TEST_SF (Val);
@@ -460,6 +520,29 @@ static void OPC_6502_11 (void)
 
 
 
+static void OPC_65SC02_12 (void)
+/* Opcode $12: ORA (zp) */
+{
+    AC_OP_ZPIND (|);
+}
+
+
+
+static void OPC_65SC02_14 (void)
+/* Opcode $14: TRB zp */
+{
+    unsigned char ZPAddr;
+    unsigned char Val;
+    Cycles = 5;
+    ZPAddr = MemReadByte (Regs.PC+1);
+    Val = MemReadByte (ZPAddr);
+    SET_ZF ((Val & Regs.AC) == 0);
+    MemWriteByte (ZPAddr, (unsigned char)(Val & ~Regs.AC)); 
+    Regs.PC += 2;
+}
+
+
+
 static void OPC_6502_15 (void)
 /* Opcode $15: ORA zp,x */
 {
@@ -475,7 +558,7 @@ static void OPC_6502_16 (void)
     unsigned Val;
     Cycles = 6;
     ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
-    Val    = MemReadByte (ZPAddr) << 1;
+    Val = MemReadByte (ZPAddr) << 1;
     MemWriteByte (ZPAddr, (unsigned char) Val);
     TEST_ZF (Val & 0xFF);
     TEST_SF (Val);
@@ -503,6 +586,33 @@ static void OPC_6502_19 (void)
 
 
 
+static void OPC_65SC02_1A (void)
+/* Opcode $1A: INC a */
+{
+    Cycles = 2;
+    Regs.AC = (Regs.AC + 1) & 0xFF;
+    TEST_ZF (Regs.AC);
+    TEST_SF (Regs.AC);
+    Regs.PC += 1;
+}
+
+
+
+static void OPC_65SC02_1C (void)
+/* Opcode $1C: TRB abs */
+{
+    unsigned Addr;
+    unsigned char Val;
+    Cycles = 6;
+    Addr = MemReadByte (Regs.PC+1);
+    Val = MemReadByte (Addr);
+    SET_ZF ((Val & Regs.AC) == 0);
+    MemWriteByte (Addr, (unsigned char) (Val & ~Regs.AC));    
+    Regs.PC += 3;
+}
+
+
+
 static void OPC_6502_1D (void)
 /* Opcode $1D: ORA abs,x */
 {
@@ -518,7 +628,7 @@ static void OPC_6502_1E (void)
     unsigned Val;
     Cycles = 7;
     Addr = MemReadWord (Regs.PC+1) + Regs.XR;
-    Val  = MemReadByte (Addr) << 1;
+    Val = MemReadByte (Addr) << 1;
     MemWriteByte (Addr, (unsigned char) Val);
     TEST_ZF (Val & 0xFF);
     TEST_SF (Val);
@@ -533,7 +643,7 @@ static void OPC_6502_20 (void)
 {
     unsigned Addr;
     Cycles = 6;
-    Addr   = MemReadWord (Regs.PC+1);
+    Addr = MemReadWord (Regs.PC+1);
     Regs.PC += 2;
     PUSH (PCH);
     PUSH (PCL);
@@ -559,7 +669,7 @@ static void OPC_6502_24 (void)
     unsigned char Val;
     Cycles = 3;
     ZPAddr = MemReadByte (Regs.PC+1);
-    Val    = MemReadByte (ZPAddr);
+    Val = MemReadByte (ZPAddr);
     SET_SF (Val & 0x80);
     SET_OF (Val & 0x40);
     SET_ZF ((Val & Regs.AC) == 0);
@@ -583,7 +693,7 @@ static void OPC_6502_26 (void)
     unsigned Val;
     Cycles = 5;
     ZPAddr = MemReadByte (Regs.PC+1);
-    Val    = MemReadByte (ZPAddr);
+    Val = MemReadByte (ZPAddr);
     ROL (Val);
     MemWriteByte (ZPAddr, Val);
     Regs.PC += 2;
@@ -627,7 +737,7 @@ static void OPC_6502_2C (void)
     unsigned char Val;
     Cycles = 4;
     Addr = MemReadByte (Regs.PC+1);
-    Val  = MemReadByte (Addr);
+    Val = MemReadByte (Addr);
     SET_SF (Val & 0x80);
     SET_OF (Val & 0x40);
     SET_ZF ((Val & Regs.AC) == 0);
@@ -651,7 +761,7 @@ static void OPC_6502_2E (void)
     unsigned Val;
     Cycles = 6;
     Addr = MemReadWord (Regs.PC+1);
-    Val  = MemReadByte (Addr);
+    Val = MemReadByte (Addr);
     ROL (Val);
     MemWriteByte (Addr, Val);
     Regs.PC += 3;
@@ -675,6 +785,30 @@ static void OPC_6502_31 (void)
 
 
 
+static void OPC_65SC02_32 (void)
+/* Opcode $32: AND (zp) */
+{
+    AC_OP_ZPIND (&);
+}
+
+
+
+static void OPC_65SC02_34 (void)
+/* Opcode $34: BIT zp,x */
+{
+    unsigned char ZPAddr;
+    unsigned char Val;
+    Cycles = 4;
+    ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
+    Val = MemReadByte (ZPAddr);
+    SET_SF (Val & 0x80);
+    SET_OF (Val & 0x40);
+    SET_ZF ((Val & Regs.AC) == 0);
+    Regs.PC += 2;
+}
+
+
+
 static void OPC_6502_35 (void)
 /* Opcode $35: AND zp,x */
 {
@@ -690,7 +824,7 @@ static void OPC_6502_36 (void)
     unsigned Val;
     Cycles = 6;
     ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
-    Val    = MemReadByte (ZPAddr);
+    Val = MemReadByte (ZPAddr);
     ROL (Val);
     MemWriteByte (ZPAddr, Val);
     Regs.PC += 2;
@@ -716,6 +850,36 @@ static void OPC_6502_39 (void)
 
 
 
+static void OPC_65SC02_3A (void)
+/* Opcode $3A: DEC a */
+{
+    Cycles = 2;
+    Regs.AC = (Regs.AC - 1) & 0xFF;
+    TEST_ZF (Regs.AC);
+    TEST_SF (Regs.AC);
+    Regs.PC += 1;
+}
+
+
+
+static void OPC_65SC02_3C (void)
+/* Opcode $3C: BIT abs,x */
+{
+    unsigned Addr;
+    unsigned char Val;
+    Cycles = 4;
+    Addr = MemReadWord (Regs.PC+1);
+    if (PAGE_CROSS (Addr, Regs.XR))
+        ++Cycles;
+    Val  = MemReadByte (Addr + Regs.XR);
+    SET_SF (Val & 0x80);
+    SET_OF (Val & 0x40);
+    SET_ZF ((Val & Regs.AC) == 0);
+    Regs.PC += 3;
+}
+
+
+
 static void OPC_6502_3D (void)
 /* Opcode $3D: AND abs,x */
 {
@@ -731,7 +895,7 @@ static void OPC_6502_3E (void)
     unsigned Val;
     Cycles = 7;
     Addr = MemReadWord (Regs.PC+1) + Regs.XR;
-    Val  = MemReadByte (Addr);
+    Val = MemReadByte (Addr);
     ROL (Val);
     MemWriteByte (Addr, Val);
     Regs.PC += 2;
@@ -758,6 +922,15 @@ static void OPC_6502_41 (void)
 
 
 
+static void OPC_65C02_44 (void)
+/* Opcode $44: 'zp' 3 cycle NOP */
+{
+    Cycles = 3;
+    Regs.PC += 2;
+}
+
+
+
 static void OPC_6502_45 (void)
 /* Opcode $45: EOR zp */
 {
@@ -773,7 +946,7 @@ static void OPC_6502_46 (void)
     unsigned char Val;
     Cycles = 5;
     ZPAddr = MemReadByte (Regs.PC+1);
-    Val    = MemReadByte (ZPAddr);
+    Val = MemReadByte (ZPAddr);
     SET_CF (Val & 0x01);
     Val >>= 1;
     MemWriteByte (ZPAddr, Val);
@@ -841,7 +1014,7 @@ static void OPC_6502_4E (void)
     unsigned char Val;
     Cycles = 6;
     Addr = MemReadWord (Regs.PC+1);
-    Val  = MemReadByte (Addr);
+    Val = MemReadByte (Addr);
     SET_CF (Val & 0x01);
     Val >>= 1;
     MemWriteByte (Addr, Val);
@@ -868,6 +1041,14 @@ static void OPC_6502_51 (void)
 
 
 
+static void OPC_65SC02_52 (void)
+/* Opcode $52: EOR (zp) */
+{
+    AC_OP_ZPIND (^);
+}
+
+
+
 static void OPC_6502_55 (void)
 /* Opcode $55: EOR zp,x */
 {
@@ -883,7 +1064,7 @@ static void OPC_6502_56 (void)
     unsigned char Val;
     Cycles = 6;
     ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
-    Val    = MemReadByte (ZPAddr);
+    Val = MemReadByte (ZPAddr);
     SET_CF (Val & 0x01);
     Val >>= 1;
     MemWriteByte (ZPAddr, Val);
@@ -912,6 +1093,25 @@ static void OPC_6502_59 (void)
 
 
 
+static void OPC_65SC02_5A (void)
+/* Opcode $5A: PHY */
+{
+    Cycles = 3;
+    PUSH (Regs.YR);
+    Regs.PC += 1;
+}
+
+
+
+static void OPC_65C02_5C (void)
+/* Opcode $5C: 'Absolute' 8 cycle NOP */
+{
+    Cycles = 8;
+    Regs.PC += 3;
+}
+
+
+
 static void OPC_6502_5D (void)
 /* Opcode $5D: EOR abs,x */
 {
@@ -927,7 +1127,7 @@ static void OPC_6502_5E (void)
     unsigned char Val;
     Cycles = 7;
     Addr = MemReadWord (Regs.PC+1) + Regs.XR;
-    Val  = MemReadByte (Addr);
+    Val = MemReadByte (Addr);
     SET_CF (Val & 0x01);
     Val >>= 1;
     MemWriteByte (Addr, Val);
@@ -956,13 +1156,25 @@ static void OPC_6502_61 (void)
     unsigned Addr;
     Cycles = 6;
     ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
-    Addr   = MemReadZPWord (ZPAddr);
+    Addr = MemReadZPWord (ZPAddr);
     ADC (MemReadByte (Addr));
     Regs.PC += 2;
 }
 
 
 
+static void OPC_65SC02_64 (void)
+/* Opcode $64: STZ zp */
+{
+    unsigned char ZPAddr;
+    Cycles = 3;
+    ZPAddr = MemReadByte (Regs.PC+1);
+    MemWriteByte (ZPAddr, 0);
+    Regs.PC += 2;
+}
+
+
+
 static void OPC_6502_65 (void)
 /* Opcode $65: ADC zp */
 {
@@ -982,7 +1194,7 @@ static void OPC_6502_66 (void)
     unsigned Val;
     Cycles = 5;
     ZPAddr = MemReadByte (Regs.PC+1);
-    Val    = MemReadByte (ZPAddr);
+    Val = MemReadByte (ZPAddr);
     ROR (Val);
     MemWriteByte (ZPAddr, Val);
     Regs.PC += 2;
@@ -1026,19 +1238,28 @@ static void OPC_6502_6C (void)
 /* Opcode $6C: JMP (ind) */
 {
     unsigned PC, Lo, Hi;
-    Cycles = 5;
     PC = Regs.PC;
     Lo = MemReadWord (PC+1);
 
-    /* Emulate the 6502 bug */
-    Regs.PC = MemReadByte (Lo);
-    Hi = (Lo & 0xFF00) | ((Lo + 1) & 0xFF);
-    Regs.PC |= (MemReadByte (Hi) << 8);
-
-    /* Output a warning if the bug is triggered */
-    if (Hi != Lo + 1) {
-        Warning ("6502 indirect jump bug triggered at $%04X, ind addr = $%04X",
-                 PC, Lo);
+    if (CPU == CPU_6502)
+    {
+         /* Emulate the 6502 bug */
+        Cycles = 5;
+        Regs.PC = MemReadByte (Lo);
+        Hi = (Lo & 0xFF00) | ((Lo + 1) & 0xFF);
+        Regs.PC |= (MemReadByte (Hi) << 8);
+
+        /* Output a warning if the bug is triggered */
+        if (Hi != Lo + 1)
+        {
+            Warning ("6502 indirect jump bug triggered at $%04X, ind addr = $%04X",
+                     PC, Lo);
+        }
+    }
+    else
+    {
+        Cycles = 6;
+        Regs.PC = MemReadWord(Lo);
     }
 }
 
@@ -1106,6 +1327,32 @@ static void OPC_6502_71 (void)
 
 
 
+static void OPC_65SC02_72 (void)
+/* Opcode $72: ADC (zp) */
+{
+    unsigned char ZPAddr;
+    unsigned Addr;
+    Cycles = 5;
+    ZPAddr = MemReadByte (Regs.PC+1);
+    Addr   = MemReadZPWord (ZPAddr);
+    ADC (MemReadByte (Addr));
+    Regs.PC += 2;
+}
+
+
+
+static void OPC_65SC02_74 (void)
+/* Opcode $74: STZ zp,x */
+{
+    unsigned char ZPAddr;
+    Cycles = 4;
+    ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
+    MemWriteByte (ZPAddr, 0);
+    Regs.PC += 2;
+}
+
+
+
 static void OPC_6502_75 (void)
 /* Opcode $75: ADC zp,x */
 {
@@ -1125,7 +1372,7 @@ static void OPC_6502_76 (void)
     unsigned Val;
     Cycles = 6;
     ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
-    Val    = MemReadByte (ZPAddr);
+    Val = MemReadByte (ZPAddr);
     ROR (Val);
     MemWriteByte (ZPAddr, Val);
     Regs.PC += 2;
@@ -1148,7 +1395,7 @@ static void OPC_6502_79 (void)
 {
     unsigned Addr;
     Cycles = 4;
-    Addr   = MemReadWord (Regs.PC+1);
+    Addr = MemReadWord (Regs.PC+1);
     if (PAGE_CROSS (Addr, Regs.YR)) {
         ++Cycles;
     }
@@ -1158,12 +1405,36 @@ static void OPC_6502_79 (void)
 
 
 
+static void OPC_65SC02_7A (void)
+/* Opcode $7A: PLY */
+{
+    Cycles = 4;
+    Regs.YR = POP ();
+    TEST_ZF (Regs.YR);
+    TEST_SF (Regs.YR);
+    Regs.PC += 1;
+}
+
+
+
+static void OPC_65SC02_7C (void)
+/* Opcode $7C: JMP (ind,X) */
+{
+    unsigned PC, Adr;
+    Cycles = 6;
+    PC = Regs.PC;
+    Adr = MemReadWord (PC+1);
+    Regs.PC = MemReadWord(Adr+Regs.XR);
+}
+
+
+
 static void OPC_6502_7D (void)
 /* Opcode $7D: ADC abs,x */
 {
     unsigned Addr;
     Cycles = 4;
-    Addr   = MemReadWord (Regs.PC+1);
+    Addr = MemReadWord (Regs.PC+1);
     if (PAGE_CROSS (Addr, Regs.XR)) {
         ++Cycles;
     }
@@ -1179,8 +1450,8 @@ static void OPC_6502_7E (void)
     unsigned Addr;
     unsigned Val;
     Cycles = 7;
-    Addr = MemReadByte (Regs.PC+1) + Regs.XR;
-    Val  = MemReadByte (Addr);
+    Addr = MemReadWord (Regs.PC+1) + Regs.XR;
+    Val = MemReadByte (Addr);
     ROR (Val);
     MemWriteByte (Addr, Val);
     Regs.PC += 3;
@@ -1188,6 +1459,14 @@ static void OPC_6502_7E (void)
 
 
 
+static void OPC_65SC02_80 (void)
+/* Opcode $80: BRA */
+{
+    BRANCH (1);
+}
+
+
+
 static void OPC_6502_81 (void)
 /* Opcode $81: STA (zp,x) */
 {
@@ -1195,7 +1474,7 @@ static void OPC_6502_81 (void)
     unsigned Addr;
     Cycles = 6;
     ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
-    Addr   = MemReadZPWord (ZPAddr);
+    Addr = MemReadZPWord (ZPAddr);
     MemWriteByte (Addr, Regs.AC);
     Regs.PC += 2;
 }
@@ -1250,6 +1529,20 @@ static void OPC_6502_88 (void)
 
 
 
+static void OPC_65SC02_89 (void)
+/* Opcode $89: BIT #imm */
+{
+    unsigned char Val;
+    Cycles = 2;
+    Val = MemReadByte (Regs.PC+1);
+    SET_SF (Val & 0x80);
+    SET_OF (Val & 0x40);
+    SET_ZF ((Val & Regs.AC) == 0);
+    Regs.PC += 2;
+}
+
+
+
 static void OPC_6502_8A (void)
 /* Opcode $8A: TXA */
 {
@@ -1313,7 +1606,21 @@ static void OPC_6502_91 (void)
     unsigned Addr;
     Cycles = 6;
     ZPAddr = MemReadByte (Regs.PC+1);
-    Addr   = MemReadZPWord (ZPAddr) + Regs.YR;
+    Addr = MemReadZPWord (ZPAddr) + Regs.YR;
+    MemWriteByte (Addr, Regs.AC);
+    Regs.PC += 2;
+}
+
+
+
+static void OPC_65SC02_92 (void)
+/* Opcode $92: sta (zp) */
+{
+    unsigned char ZPAddr;
+    unsigned Addr;
+    Cycles = 5;
+    ZPAddr = MemReadByte (Regs.PC+1);
+    Addr = MemReadZPWord (ZPAddr);
     MemWriteByte (Addr, Regs.AC);
     Regs.PC += 2;
 }
@@ -1373,7 +1680,7 @@ static void OPC_6502_99 (void)
 {
     unsigned Addr;
     Cycles = 5;
-    Addr   = MemReadWord (Regs.PC+1) + Regs.YR;
+    Addr = MemReadWord (Regs.PC+1) + Regs.YR;
     MemWriteByte (Addr, Regs.AC);
     Regs.PC += 3;
 }
@@ -1390,18 +1697,42 @@ static void OPC_6502_9A (void)
 
 
 
+static void OPC_65SC02_9C (void)
+/* Opcode $9C: STZ abs */
+{
+    unsigned Addr;
+    Cycles = 4;
+    Addr = MemReadWord (Regs.PC+1);
+    MemWriteByte (Addr, 0);
+    Regs.PC += 3;
+}
+
+
+
 static void OPC_6502_9D (void)
 /* Opcode $9D: STA abs,x */
 {
     unsigned Addr;
     Cycles = 5;
-    Addr   = MemReadWord (Regs.PC+1) + Regs.XR;
+    Addr = MemReadWord (Regs.PC+1) + Regs.XR;
     MemWriteByte (Addr, Regs.AC);
     Regs.PC += 3;
 }
 
 
 
+static void OPC_65SC02_9E (void)
+/* Opcode $9E: STZ abs,x */
+{
+    unsigned Addr;
+    Cycles = 5;
+    Addr = MemReadWord (Regs.PC+1) + Regs.XR;
+    MemWriteByte (Addr, 0);
+    Regs.PC += 3;
+}
+
+
+
 static void OPC_6502_A0 (void)
 /* Opcode $A0: LDY #imm */
 {
@@ -1525,7 +1856,7 @@ static void OPC_6502_AC (void)
 {
     unsigned Addr;
     Cycles = 4;
-    Addr   = MemReadWord (Regs.PC+1);
+    Addr = MemReadWord (Regs.PC+1);
     Regs.YR = MemReadByte (Addr);
     TEST_ZF (Regs.YR);
     TEST_SF (Regs.YR);
@@ -1539,7 +1870,7 @@ static void OPC_6502_AD (void)
 {
     unsigned Addr;
     Cycles = 4;
-    Addr   = MemReadWord (Regs.PC+1);
+    Addr = MemReadWord (Regs.PC+1);
     Regs.AC = MemReadByte (Addr);
     TEST_ZF (Regs.AC);
     TEST_SF (Regs.AC);
@@ -1553,7 +1884,7 @@ static void OPC_6502_AE (void)
 {
     unsigned Addr;
     Cycles = 4;
-    Addr   = MemReadWord (Regs.PC+1);
+    Addr = MemReadWord (Regs.PC+1);
     Regs.XR = MemReadByte (Addr);
     TEST_ZF (Regs.XR);
     TEST_SF (Regs.XR);
@@ -1577,7 +1908,7 @@ static void OPC_6502_B1 (void)
     unsigned Addr;
     Cycles = 5;
     ZPAddr = MemReadByte (Regs.PC+1);
-    Addr   = MemReadZPWord (ZPAddr);
+    Addr = MemReadZPWord (ZPAddr);
     if (PAGE_CROSS (Addr, Regs.YR)) {
         ++Cycles;
     }
@@ -1589,6 +1920,22 @@ static void OPC_6502_B1 (void)
 
 
 
+static void OPC_65SC02_B2 (void)
+/* Opcode $B2: LDA (zp) */
+{
+    unsigned char ZPAddr;
+    unsigned Addr;
+    Cycles = 5;
+    ZPAddr = MemReadByte (Regs.PC+1);
+    Addr = MemReadZPWord (ZPAddr);
+    Regs.AC = MemReadByte (Addr);
+    TEST_ZF (Regs.AC);
+    TEST_SF (Regs.AC);
+    Regs.PC += 2;
+}
+
+
+
 static void OPC_6502_B4 (void)
 /* Opcode $B4: LDY zp,x */
 {
@@ -1738,7 +2085,7 @@ static void OPC_6502_C1 (void)
     unsigned Addr;
     Cycles = 6;
     ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
-    Addr   = MemReadZPWord (ZPAddr);
+    Addr = MemReadZPWord (ZPAddr);
     CMP (Regs.AC, MemReadByte (Addr));
     Regs.PC += 2;
 }
@@ -1776,7 +2123,7 @@ static void OPC_6502_C6 (void)
     unsigned char Val;
     Cycles = 5;
     ZPAddr = MemReadByte (Regs.PC+1);
-    Val    = MemReadByte (ZPAddr) - 1;
+    Val = MemReadByte (ZPAddr) - 1;
     MemWriteByte (ZPAddr, Val);
     TEST_ZF (Val);
     TEST_SF (Val);
@@ -1824,7 +2171,7 @@ static void OPC_6502_CC (void)
 {
     unsigned Addr;
     Cycles = 4;
-    Addr   = MemReadWord (Regs.PC+1);
+    Addr = MemReadWord (Regs.PC+1);
     CMP (Regs.YR, MemReadByte (Addr));
     Regs.PC += 3;
 }
@@ -1836,7 +2183,7 @@ static void OPC_6502_CD (void)
 {
     unsigned Addr;
     Cycles = 4;
-    Addr   = MemReadWord (Regs.PC+1);
+    Addr = MemReadWord (Regs.PC+1);
     CMP (Regs.AC, MemReadByte (Addr));
     Regs.PC += 3;
 }
@@ -1874,7 +2221,7 @@ static void OPC_6502_D1 (void)
     unsigned Addr;
     Cycles = 5;
     ZPAddr = MemReadByte (Regs.PC+1);
-    Addr   = MemReadWord (ZPAddr);
+    Addr = MemReadWord (ZPAddr);
     if (PAGE_CROSS (Addr, Regs.YR)) {
         ++Cycles;
     }
@@ -1884,6 +2231,20 @@ static void OPC_6502_D1 (void)
 
 
 
+static void OPC_65SC02_D2 (void)
+/* Opcode $D2: CMP (zp) */
+{
+    unsigned ZPAddr;
+    unsigned Addr;
+    Cycles = 5;
+    ZPAddr = MemReadByte (Regs.PC+1);
+    Addr = MemReadWord (ZPAddr);
+    CMP (Regs.AC, MemReadByte (Addr));
+    Regs.PC += 2;
+}
+
+
+
 static void OPC_6502_D5 (void)
 /* Opcode $D5: CMP zp,x */
 {
@@ -1937,6 +2298,16 @@ static void OPC_6502_D9 (void)
 
 
 
+static void OPC_65SC02_DA (void)
+/* Opcode $DA: PHX */
+{
+    Cycles = 3;
+    PUSH (Regs.XR);
+    Regs.PC += 1;
+}
+
+
+
 static void OPC_6502_DD (void)
 /* Opcode $DD: CMP abs,x */
 {
@@ -1959,7 +2330,7 @@ static void OPC_6502_DE (void)
     unsigned char Val;
     Cycles = 7;
     Addr = MemReadWord (Regs.PC+1) + Regs.XR;
-    Val  = MemReadByte (Addr) - 1;
+    Val = MemReadByte (Addr) - 1;
     MemWriteByte (Addr, Val);
     TEST_ZF (Val);
     TEST_SF (Val);
@@ -1985,7 +2356,7 @@ static void OPC_6502_E1 (void)
     unsigned Addr;
     Cycles = 6;
     ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
-    Addr   = MemReadZPWord (ZPAddr);
+    Addr = MemReadZPWord (ZPAddr);
     SBC (MemReadByte (Addr));
     Regs.PC += 2;
 }
@@ -2023,7 +2394,7 @@ static void OPC_6502_E6 (void)
     unsigned char Val;
     Cycles = 5;
     ZPAddr = MemReadByte (Regs.PC+1);
-    Val    = MemReadByte (ZPAddr) + 1;
+    Val = MemReadByte (ZPAddr) + 1;
     MemWriteByte (ZPAddr, Val);
     TEST_ZF (Val);
     TEST_SF (Val);
@@ -2064,6 +2435,42 @@ static void OPC_6502_EA (void)
 
 
 
+static void OPC_65C02_NOP11(void)
+/* Opcode 'Illegal' 1 cycle NOP */
+{
+    Cycles = 1;
+    Regs.PC += 1;
+}
+
+
+
+static void OPC_65C02_NOP22 (void)
+/* Opcode 'Illegal' 2 byte 2 cycle NOP */
+{
+    Cycles = 2;
+    Regs.PC += 2;
+}
+
+
+
+static void OPC_65C02_NOP24 (void)
+/* Opcode 'Illegal' 2 byte 4 cycle NOP */
+{
+    Cycles = 4;
+    Regs.PC += 2;
+}
+
+
+
+static void OPC_65C02_NOP34 (void)
+/* Opcode 'Illegal' 3 byte 4 cycle NOP */
+{
+    Cycles = 4;
+    Regs.PC += 3;
+}
+
+
+
 static void OPC_6502_EC (void)
 /* Opcode $EC: CPX abs */
 {
@@ -2081,7 +2488,7 @@ static void OPC_6502_ED (void)
 {
     unsigned Addr;
     Cycles = 4;
-    Addr   = MemReadWord (Regs.PC+1);
+    Addr = MemReadWord (Regs.PC+1);
     SBC (MemReadByte (Addr));
     Regs.PC += 3;
 }
@@ -2095,7 +2502,7 @@ static void OPC_6502_EE (void)
     unsigned char Val;
     Cycles = 6;
     Addr = MemReadWord (Regs.PC+1);
-    Val  = MemReadByte (Addr) + 1;
+    Val = MemReadByte (Addr) + 1;
     MemWriteByte (Addr, Val);
     TEST_ZF (Val);
     TEST_SF (Val);
@@ -2119,7 +2526,7 @@ static void OPC_6502_F1 (void)
     unsigned Addr;
     Cycles = 5;
     ZPAddr = MemReadByte (Regs.PC+1);
-    Addr   = MemReadZPWord (ZPAddr);
+    Addr = MemReadZPWord (ZPAddr);
     if (PAGE_CROSS (Addr, Regs.YR)) {
         ++Cycles;
     }
@@ -2129,6 +2536,20 @@ static void OPC_6502_F1 (void)
 
 
 
+static void OPC_65SC02_F2 (void)
+/* Opcode $F2: SBC (zp) */
+{
+    unsigned char ZPAddr;
+    unsigned Addr;
+    Cycles = 5;
+    ZPAddr = MemReadByte (Regs.PC+1);
+    Addr = MemReadZPWord (ZPAddr);
+    SBC (MemReadByte (Addr));
+    Regs.PC += 2;
+}
+
+
+
 static void OPC_6502_F5 (void)
 /* Opcode $F5: SBC zp,x */
 {
@@ -2148,7 +2569,7 @@ static void OPC_6502_F6 (void)
     unsigned char Val;
     Cycles = 6;
     ZPAddr = MemReadByte (Regs.PC+1) + Regs.XR;
-    Val  = MemReadByte (ZPAddr) + 1;
+    Val = MemReadByte (ZPAddr) + 1;
     MemWriteByte (ZPAddr, Val);
     TEST_ZF (Val);
     TEST_SF (Val);
@@ -2170,7 +2591,7 @@ static void OPC_6502_F9 (void)
 {
     unsigned Addr;
     Cycles = 4;
-    Addr   = MemReadWord (Regs.PC+1);
+    Addr = MemReadWord (Regs.PC+1);
     if (PAGE_CROSS (Addr, Regs.YR)) {
         ++Cycles;
     }
@@ -2180,12 +2601,24 @@ static void OPC_6502_F9 (void)
 
 
 
+static void OPC_65SC02_FA (void)
+/* Opcode $7A: PLX */
+{
+    Cycles = 4;
+    Regs.XR = POP ();
+    TEST_ZF (Regs.XR);
+    TEST_SF (Regs.XR);
+    Regs.PC += 1;
+}
+
+
+
 static void OPC_6502_FD (void)
 /* Opcode $FD: SBC abs,x */
 {
     unsigned Addr;
     Cycles = 4;
-    Addr   = MemReadWord (Regs.PC+1);
+    Addr = MemReadWord (Regs.PC+1);
     if (PAGE_CROSS (Addr, Regs.XR)) {
         ++Cycles;
     }
@@ -2202,7 +2635,7 @@ static void OPC_6502_FE (void)
     unsigned char Val;
     Cycles = 7;
     Addr = MemReadWord (Regs.PC+1) + Regs.XR;
-    Val  = MemReadByte (Addr) + 1;
+    Val = MemReadByte (Addr) + 1;
     MemWriteByte (Addr, Val);
     TEST_ZF (Val);
     TEST_SF (Val);
@@ -2483,260 +2916,260 @@ static const OPFunc OP6502Table[256] = {
 static const OPFunc OP65C02Table[256] = {
     OPC_6502_00,
     OPC_6502_01,
-    OPC_Illegal,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65C02_NOP22,    // $02
+    OPC_65C02_NOP11,    // $03
+    OPC_65SC02_04,
     OPC_6502_05,
     OPC_6502_06,
-    OPC_Illegal,
+    OPC_Illegal,        // $07: RMB0 currently unsupported
     OPC_6502_08,
     OPC_6502_09,
     OPC_6502_0A,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65C02_NOP11,    // $0B
+    OPC_65SC02_0C,
     OPC_6502_0D,
     OPC_6502_0E,
-    OPC_Illegal,
+    OPC_Illegal,        // $0F: BBR0 currently unsupported
     OPC_6502_10,
     OPC_6502_11,
-    OPC_Illegal,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65SC02_12,
+    OPC_65C02_NOP11,    // $13
+    OPC_65SC02_14,
     OPC_6502_15,
     OPC_6502_16,
-    OPC_Illegal,
+    OPC_Illegal,        // $17: RMB1 currently unsupported
     OPC_6502_18,
     OPC_6502_19,
-    OPC_Illegal,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65SC02_1A,
+    OPC_65C02_NOP11,    // $1B
+    OPC_65SC02_1C,
     OPC_6502_1D,
     OPC_6502_1E,
-    OPC_Illegal,
+    OPC_Illegal,        // $1F: BBR1 currently unsupported
     OPC_6502_20,
     OPC_6502_21,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65C02_NOP22,    // $22
+    OPC_65C02_NOP11,    // $23
     OPC_6502_24,
     OPC_6502_25,
     OPC_6502_26,
-    OPC_Illegal,
+    OPC_Illegal,        // $27: RMB2 currently unsupported
     OPC_6502_28,
     OPC_6502_29,
     OPC_6502_2A,
-    OPC_Illegal,
+    OPC_65C02_NOP11,    // $2B
     OPC_6502_2C,
     OPC_6502_2D,
     OPC_6502_2E,
-    OPC_Illegal,
+    OPC_Illegal,        // $2F: BBR2 currently unsupported
     OPC_6502_30,
     OPC_6502_31,
-    OPC_Illegal,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65SC02_32,
+    OPC_65C02_NOP11,    // $33
+    OPC_65SC02_34,
     OPC_6502_35,
     OPC_6502_36,
-    OPC_Illegal,
+    OPC_Illegal,        // $37: RMB3 currently unsupported
     OPC_6502_38,
     OPC_6502_39,
-    OPC_Illegal,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65SC02_3A,
+    OPC_65C02_NOP11,    // $3B
+    OPC_65SC02_3C,
     OPC_6502_3D,
     OPC_6502_3E,
-    OPC_Illegal,
+    OPC_Illegal,        // $3F: BBR3 currently unsupported
     OPC_6502_40,
     OPC_6502_41,
-    OPC_Illegal,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65C02_NOP22,    // $42
+    OPC_65C02_NOP11,    // $43
+    OPC_65C02_44,       // $44
     OPC_6502_45,
     OPC_6502_46,
-    OPC_Illegal,
+    OPC_Illegal,        // $47: RMB4 currently unsupported
     OPC_6502_48,
     OPC_6502_49,
     OPC_6502_4A,
-    OPC_Illegal,
+    OPC_65C02_NOP11,    // $4B
     OPC_6502_4C,
     OPC_6502_4D,
     OPC_6502_4E,
-    OPC_Illegal,
+    OPC_Illegal,        // $4F: BBR4 currently unsupported
     OPC_6502_50,
     OPC_6502_51,
-    OPC_Illegal,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65SC02_52,
+    OPC_65C02_NOP11,    // $53
+    OPC_65C02_NOP24,    // $54
     OPC_6502_55,
     OPC_6502_56,
-    OPC_Illegal,
+    OPC_Illegal,        // $57: RMB5 currently unsupported
     OPC_6502_58,
     OPC_6502_59,
-    OPC_Illegal,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65SC02_5A,
+    OPC_65C02_NOP11,    // $5B
+    OPC_65C02_5C,
     OPC_6502_5D,
     OPC_6502_5E,
-    OPC_Illegal,
+    OPC_Illegal,        // $5F: BBR5 currently unsupported
     OPC_6502_60,
     OPC_6502_61,
-    OPC_Illegal,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65C02_NOP22,    // $62
+    OPC_65C02_NOP11,    // $63
+    OPC_65SC02_64,
     OPC_6502_65,
     OPC_6502_66,
-    OPC_Illegal,
+    OPC_Illegal,        // $67: RMB6 currently unsupported
     OPC_6502_68,
     OPC_6502_69,
     OPC_6502_6A,
-    OPC_Illegal,
+    OPC_65C02_NOP11,    // $6B
     OPC_65C02_6C,
     OPC_6502_6D,
     OPC_6502_6E,
-    OPC_Illegal,
+    OPC_Illegal,        // $6F: BBR6 currently unsupported
     OPC_6502_70,
     OPC_6502_71,
-    OPC_Illegal,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65SC02_72,
+    OPC_65C02_NOP11,    // $73
+    OPC_65SC02_74,
     OPC_6502_75,
     OPC_6502_76,
-    OPC_Illegal,
+    OPC_Illegal,        // $77: RMB7 currently unsupported
     OPC_6502_78,
     OPC_6502_79,
-    OPC_Illegal,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65SC02_7A,
+    OPC_65C02_NOP11,    // $7B
+    OPC_65SC02_7C,
     OPC_6502_7D,
     OPC_6502_7E,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_Illegal,        // $7F: BBR7 currently unsupported
+    OPC_65SC02_80,
     OPC_6502_81,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65C02_NOP22,    // $82
+    OPC_65C02_NOP11,    // $83
     OPC_6502_84,
     OPC_6502_85,
     OPC_6502_86,
-    OPC_Illegal,
+    OPC_Illegal,        // $87: SMB0 currently unsupported
     OPC_6502_88,
-    OPC_Illegal,
+    OPC_65SC02_89,
     OPC_6502_8A,
-    OPC_Illegal,
+    OPC_65C02_NOP11,    // $8B
     OPC_6502_8C,
     OPC_6502_8D,
     OPC_6502_8E,
-    OPC_Illegal,
+    OPC_Illegal,        // $8F: BBS0 currently unsupported
     OPC_6502_90,
     OPC_6502_91,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65SC02_92,
+    OPC_65C02_NOP11,    // $93
     OPC_6502_94,
     OPC_6502_95,
     OPC_6502_96,
-    OPC_Illegal,
+    OPC_Illegal,        // $97: SMB1 currently unsupported
     OPC_6502_98,
     OPC_6502_99,
     OPC_6502_9A,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65C02_NOP11,    // $9B
+    OPC_65SC02_9C,
     OPC_6502_9D,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65SC02_9E,
+    OPC_Illegal,        // $9F: BBS1 currently unsupported
     OPC_6502_A0,
     OPC_6502_A1,
     OPC_6502_A2,
-    OPC_Illegal,
+    OPC_65C02_NOP11,    // $A3
     OPC_6502_A4,
     OPC_6502_A5,
     OPC_6502_A6,
-    OPC_Illegal,
+    OPC_Illegal,        // $A7: SMB2 currently unsupported
     OPC_6502_A8,
     OPC_6502_A9,
     OPC_6502_AA,
-    OPC_Illegal,
+    OPC_65C02_NOP11,    // $AB
     OPC_6502_AC,
     OPC_6502_AD,
     OPC_6502_AE,
-    OPC_Illegal,
+    OPC_Illegal,        // $AF: BBS2 currently unsupported
     OPC_6502_B0,
     OPC_6502_B1,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65SC02_B2,
+    OPC_65C02_NOP11,    // $B3
     OPC_6502_B4,
     OPC_6502_B5,
     OPC_6502_B6,
-    OPC_Illegal,
+    OPC_Illegal,        // $B7: SMB3 currently unsupported
     OPC_6502_B8,
     OPC_6502_B9,
     OPC_6502_BA,
-    OPC_Illegal,
+    OPC_65C02_NOP11,    // $BB
     OPC_6502_BC,
     OPC_6502_BD,
     OPC_6502_BE,
-    OPC_Illegal,
+    OPC_Illegal,        // $BF: BBS3 currently unsupported
     OPC_6502_C0,
     OPC_6502_C1,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65C02_NOP22,    // $C2
+    OPC_65C02_NOP11,    // $C3
     OPC_6502_C4,
     OPC_6502_C5,
     OPC_6502_C6,
-    OPC_Illegal,
+    OPC_Illegal,        // $C7: SMB4 currently unsupported
     OPC_6502_C8,
     OPC_6502_C9,
     OPC_6502_CA,
-    OPC_Illegal,
+    OPC_Illegal,        // $CB: WAI currently unsupported
     OPC_6502_CC,
     OPC_6502_CD,
     OPC_6502_CE,
-    OPC_Illegal,
+    OPC_Illegal,        // $CF: BBS4 currently unsupported
     OPC_6502_D0,
     OPC_6502_D1,
-    OPC_Illegal,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65SC02_D2,
+    OPC_65C02_NOP11,    // $D3
+    OPC_65C02_NOP24,    // $D4
     OPC_6502_D5,
     OPC_6502_D6,
-    OPC_Illegal,
+    OPC_Illegal,        // $D7: SMB5 currently unsupported
     OPC_6502_D8,
     OPC_6502_D9,
-    OPC_Illegal,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65SC02_DA,
+    OPC_Illegal,        // $DB: STP currently unsupported
+    OPC_65C02_NOP34,    // $DC
     OPC_6502_DD,
     OPC_6502_DE,
-    OPC_Illegal,
+    OPC_Illegal,        // $DF: BBS5 currently unsupported
     OPC_6502_E0,
     OPC_6502_E1,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65C02_NOP22,    // $E2
+    OPC_65C02_NOP11,    // $E3
     OPC_6502_E4,
     OPC_6502_E5,
     OPC_6502_E6,
-    OPC_Illegal,
+    OPC_Illegal,        // $E7: SMB6 currently unsupported
     OPC_6502_E8,
     OPC_6502_E9,
     OPC_6502_EA,
-    OPC_Illegal,
+    OPC_65C02_NOP11,    // $EB
     OPC_6502_EC,
     OPC_6502_ED,
     OPC_6502_EE,
-    OPC_Illegal,
+    OPC_Illegal,        // $EF: BBS6 currently unsupported
     OPC_6502_F0,
     OPC_6502_F1,
-    OPC_Illegal,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65SC02_F2,
+    OPC_65C02_NOP11,    // $F3
+    OPC_65C02_NOP24,    // $F4
     OPC_6502_F5,
     OPC_6502_F6,
-    OPC_Illegal,
+    OPC_Illegal,        // $F7: SMB7 currently unsupported
     OPC_6502_F8,
     OPC_6502_F9,
-    OPC_Illegal,
-    OPC_Illegal,
-    OPC_Illegal,
+    OPC_65SC02_FA,
+    OPC_65C02_NOP11,    // $FB
+    OPC_65C02_NOP34,    // $FC
     OPC_6502_FD,
     OPC_6502_FE,
-    OPC_Illegal,
+    OPC_Illegal,        // $FF: BBS7 currently unsupported
 };
 
 
index 4817e70e0ff103ce6692c9901578e7a81b1d34bc..c858835171d3cfb169d5f60e7303800f688569c1 100644 (file)
@@ -1,51 +1,36 @@
-
-# top-level makefile for the regression tests
-
-# You can comment this special target when you debug the regression tests.
-# Then, make will give you more progress reports.
-.SILENT:
+# top-level Makefile for the regression tests
 
 ifneq ($(shell echo),)
-  CMD_EXE := 1
+  CMD_EXE = 1
 endif
 
 ifdef CMD_EXE
-  EXE := .exe
-  MKDIR = mkdir $(subst /,\,$1)
   RMDIR = -rmdir /s /q $(subst /,\,$1)
 else
-  EXE :=
-  MKDIR = mkdir $1
   RMDIR = $(RM) -r $1
 endif
 
-WORKDIR := ../testwrk
-
-CC := gcc
+WORKDIR = ../testwrk
 
 .PHONY: all dotests continue mostlyclean clean
 
 all: dotests
 
-$(WORKDIR):
-       $(call MKDIR,$(WORKDIR))
-
-$(WORKDIR)/bdiff$(EXE): bdiff.c | $(WORKDIR)
-       $(CC) -O2 -o $@ $<
-
 .NOTPARALLEL:
 
 dotests: mostlyclean continue
 
-continue: $(WORKDIR)/bdiff$(EXE)
-       @$(MAKE) -C assembler all
-       @$(MAKE) -C disassembler all
+continue:
+       @$(MAKE) -C asm all
+       @$(MAKE) -C dasm all
        @$(MAKE) -C val all
        @$(MAKE) -C ref all
        @$(MAKE) -C err all
        @$(MAKE) -C misc all
 
 mostlyclean:
+       @$(MAKE) -C asm clean
+       @$(MAKE) -C dasm clean
        @$(MAKE) -C val clean
        @$(MAKE) -C ref clean
        @$(MAKE) -C err clean
diff --git a/test/asm/4510-cpudetect.ref b/test/asm/4510-cpudetect.ref
new file mode 100644 (file)
index 0000000..515557c
Binary files /dev/null and b/test/asm/4510-cpudetect.ref differ
diff --git a/test/asm/4510-opcodes.ref b/test/asm/4510-opcodes.ref
new file mode 100644 (file)
index 0000000..b65b12e
Binary files /dev/null and b/test/asm/4510-opcodes.ref differ
diff --git a/test/asm/4510-opcodes.s b/test/asm/4510-opcodes.s
new file mode 100644 (file)
index 0000000..3d68056
--- /dev/null
@@ -0,0 +1,278 @@
+.setcpu "4510"
+
+   brk
+   ora ($05,x)
+   cle
+   see
+   tsb $02
+   ora $02
+   asl $02
+   rmb0 $02
+   php
+   ora #$01
+   asl
+   tsy
+   tsb $1234
+   ora $1234
+   asl $1234
+   bbr0 $02,*+$34
+
+   bpl *+$32
+   ora ($06),y
+   ora ($07),z
+   lbpl *+$3133 ; bpl *+$3133
+   trb $02
+   ora $03,x
+   asl $03,x
+   rmb1 $02
+   clc
+   ora $1456,y
+   inc
+   inz
+   trb $1234
+   ora $1345,x
+   asl $1345,x
+   bbr1 $02,*+$34
+
+   jsr $1234
+   and ($05,x)
+   jsr ($2345)
+   jsr ($2456,x)
+   bit $02
+   and $02
+   rol $02
+   rmb2 $02
+   plp
+   and #$01
+   rol
+   tys
+   bit $1234
+   and $1234
+   rol $1234
+   bbr2 $02,*+$34
+
+   bmi *+$32
+   and ($06),y
+   and ($07),z
+   lbmi *+$3133 ; bmi *+$3133
+   bit $03,x
+   and $03,x
+   rol $03,x
+   rmb3 $02
+   sec
+   and $1456,y
+   dec
+   dez
+   bit $1345,x
+   and $1345,x
+   rol $1345,x
+   bbr3 $02,*+$34
+
+   rti
+   eor ($05,x)
+   neg
+   asr
+   asr $02
+   eor $02
+   lsr $02
+   rmb4 $02
+   pha
+   eor #$01
+   lsr
+   taz
+   jmp $1234
+   eor $1234
+   lsr $1234
+   bbr4 $02,*+$34
+
+   bvc *+$32
+   eor ($06),y
+   eor ($07),z
+   lbvc *+$3133 ; bvc *+$3133
+   asr $03,x
+   eor $03,x
+   lsr $03,x
+   rmb5 $02
+   cli
+   eor $1456,y
+   phy
+   tab
+   map
+   eor $1345,x
+   lsr $1345,x
+   bbr5 $02,*+$34
+
+   rts
+   adc ($05,x)
+   rtn #$09
+   bsr *+$3133
+   stz $02
+   adc $02
+   ror $02
+   rmb6 $02
+   pla
+   adc #$01
+   ror
+   tza
+   jmp ($2345)
+   adc $1234
+   ror $1234
+   bbr6 $02,*+$34
+
+   bvs *+$32
+   adc ($06),y
+   adc ($07),z
+   lbvs *+$3133 ; bvs *+$3133
+   stz $03,x
+   adc $03,x
+   ror $03,x
+   rmb7 $02
+   sei
+   adc $1456,y
+   ply
+   tba
+   jmp ($2456,x)
+   adc $1345,x
+   ror $1345,x
+   bbr7 $02,*+$34
+
+   bra *+$32
+   sta ($05,x)
+   sta ($0f,s),y
+   sta ($0f,sp),y
+   lbra *+$3133 ; bra *+$3133
+   sty $02
+   sta $02
+   stx $02
+   smb0 $02
+   dey
+   bit #$01
+   txa
+   sty $1345,x
+   sty $1234
+   sta $1234
+   stx $1234
+   bbs0 $02,*+$34
+
+   bcc *+$32
+   sta ($06),y
+   sta ($07),z
+   lbcc *+$3133 ; bcc *+$3133
+   sty $03,x
+   sta $03,x
+   stx $04,y
+   smb1 $02
+   tya
+   sta $1456,y
+   txs
+   stx $1456,y
+   stz $1234
+   sta $1345,x
+   stz $1345,x
+   bbs1 $02,*+$34
+
+   ldy #$01
+   lda ($05,x)
+   ldx #$01
+   ldz #$01
+   ldy $02
+   lda $02
+   ldx $02
+   smb2 $02
+   tay
+   lda #$01
+   tax
+   ldz $1234
+   ldy $1234
+   lda $1234
+   ldx $1234
+   bbs2 $02,*+$34
+
+   bcs *+$32
+   lda ($06),y
+   lda ($07),z
+   lbcs *+$3133 ; bcs *+$3133
+   ldy $03,x
+   lda $03,x
+   ldx $04,y
+   smb3 $02
+   clv
+   lda $1456,y
+   tsx
+   ldz $1345,x
+   ldy $1345,x
+   lda $1345,x
+   ldx $1456,y
+   bbs3 $02,*+$34
+
+   cpy #$01
+   cmp ($05,x)
+   cpz #$01
+   dew $02
+   cpy $02
+   cmp $02
+   dec $02
+   smb4 $02
+   iny
+   cmp #$01
+   dex
+   asw $1234
+   cpy $1234
+   cmp $1234
+   dec $1234
+   bbs4 $02,*+$34
+
+   bne *+$32
+   cmp ($06),y
+   cmp ($07),z
+   lbne *+$3133 ; bne *+$3133
+   cpz $02
+   cmp $03,x
+   dec $03,x
+   smb5 $02
+   cld
+   cmp $1456,y
+   phx
+   phz
+   cpz $1234
+   cmp $1345,x
+   dec $1345,x
+   bbs5 $02,*+$34
+
+   cpx #$01
+   sbc ($05,x)
+   lda ($0f,s),y
+   lda ($0f,sp),y
+   inw $02
+   cpx $02
+   sbc $02
+   inc $02
+   smb6 $02
+   inx
+   sbc #$01
+   eom
+   nop
+   row $1234
+   cpx $1234
+   sbc $1234
+   inc $1234
+   bbs6 $02,*+$34
+
+   beq *+$32
+   sbc ($06),y
+   sbc ($07),z
+   lbeq *+$3133 ; beq *+$3133
+   phd #$089a
+   phw #$089a
+   sbc $03,x
+   inc $03,x
+   smb7 $02
+   sed
+   sbc $1456,y
+   plx
+   plz
+   phd $1234
+   phw $1234
+   sbc $1345,x
+   inc $1345,x
+   bbs7 $02,*+$34
diff --git a/test/asm/6502-cpudetect.ref b/test/asm/6502-cpudetect.ref
new file mode 100644 (file)
index 0000000..9b0aeb1
Binary files /dev/null and b/test/asm/6502-cpudetect.ref differ
diff --git a/test/asm/6502-opcodes.ref b/test/asm/6502-opcodes.ref
new file mode 100644 (file)
index 0000000..c12fa8f
Binary files /dev/null and b/test/asm/6502-opcodes.ref differ
diff --git a/test/asm/6502-opcodes.s b/test/asm/6502-opcodes.s
new file mode 100644 (file)
index 0000000..5cb94c2
--- /dev/null
@@ -0,0 +1,257 @@
+.setcpu "6502"
+
+   brk
+   ora     ($12,x)
+   .byte   $02
+   .byte   $03
+   .byte   $04
+   ora     $12
+   asl     $12
+   .byte   $07
+   php
+   ora     #$12
+   asl     a
+   .byte   $0B
+   .byte   $0C
+   ora     $3456
+   asl     $3456
+   .byte   $0F
+   bpl     *+122
+   ora     ($12),y
+   .byte   $12
+   .byte   $13
+   .byte   $14
+   ora     $12,x
+   asl     $12,x
+   .byte   $17
+   clc
+   ora     $3456,y
+   .byte   $1A
+   .byte   $1B
+   .byte   $1C
+   ora     $3456,x
+   asl     $3456,x
+   .byte   $1F
+   jsr     $3456
+   and     ($12,x)
+   .byte   $22
+   .byte   $23
+   bit     $12
+   and     $12
+   rol     $12
+   .byte   $27
+   plp
+   and     #$12
+   rol     a
+   .byte   $2B
+   bit     $3456
+   and     $3456
+   rol     $3456
+   .byte   $2F
+   bmi     *+122
+   and     ($12),y
+   .byte   $32
+   .byte   $33
+   .byte   $34
+   and     $12,x
+   rol     $12,x
+   .byte   $37
+   sec
+   and     $3456,y
+   .byte   $3A
+   .byte   $3B
+   .byte   $3C
+   and     $3456,x
+   rol     $3456,x
+   .byte   $3F
+   rti
+   eor     ($12,x)
+   .byte   $42
+   .byte   $43
+   .byte   $44
+   eor     $12
+   lsr     $12
+   .byte   $47
+   pha
+   eor     #$12
+   lsr     a
+   .byte   $4B
+   jmp     $3456
+   eor     $3456
+   lsr     $3456
+   .byte   $4F
+   bvc     *+122
+   eor     ($12),y
+   .byte   $52
+   .byte   $53
+   .byte   $54
+   eor     $12,x
+   lsr     $12,x
+   .byte   $57
+   cli
+   eor     $3456,y
+   .byte   $5A
+   .byte   $5B
+   .byte   $5C
+   eor     $3456,x
+   lsr     $3456,x
+   .byte   $5F
+   rts
+   adc     ($12,x)
+   .byte   $62
+   .byte   $63
+   .byte   $64
+   adc     $12
+   ror     $12
+   .byte   $67
+   pla
+   adc     #$12
+   ror     a
+   .byte   $6B
+   jmp     ($3456)
+   adc     $3456
+   ror     $3456
+   .byte   $6F
+   bvs     *+122
+   adc     ($12),y
+   .byte   $72
+   .byte   $73
+   .byte   $74
+   adc     $12,x
+   ror     $12,x
+   .byte   $77
+   sei
+   adc     $3456,y
+   .byte   $7A
+   .byte   $7B
+   .byte   $7C
+   adc     $3456,x
+   ror     $3456,x
+   .byte   $7F
+   .byte   $80
+   sta     ($12,x)
+   .byte   $82
+   .byte   $83
+   sty     $12
+   sta     $12
+   stx     $12
+   .byte   $87
+   dey
+   .byte   $89
+   txa
+   .byte   $8B
+   sty     $3456
+   sta     $3456
+   stx     $3456
+   .byte   $8F
+   bcc     *+122
+   sta     ($12),y
+   .byte   $92
+   .byte   $93
+   sty     $12,x
+   sta     $12,x
+   stx     $12,y
+   .byte   $97
+   tya
+   sta     $3456,y
+   txs
+   .byte   $9B
+   .byte   $9C
+   sta     $3456,x
+   .byte   $9E
+   .byte   $9F
+   ldy     #$12
+   lda     ($12,x)
+   ldx     #$12
+   .byte   $A3
+   ldy     $12
+   lda     $12
+   ldx     $12
+   .byte   $A7
+   tay
+   lda     #$12
+   tax
+   .byte   $AB
+   ldy     $3456
+   lda     $3456
+   ldx     $3456
+   .byte   $AF
+   bcs     *+122
+   lda     ($12),y
+   .byte   $B2
+   .byte   $B3
+   ldy     $12,x
+   lda     $12,x
+   ldx     $12,y
+   .byte   $B7
+   clv
+   lda     $3456,y
+   tsx
+   .byte   $BB
+   ldy     $3456,x
+   lda     $3456,x
+   ldx     $3456,y
+   .byte   $BF
+   cpy     #$12
+   cmp     ($12,x)
+   .byte   $C2
+   .byte   $C3
+   cpy     $12
+   cmp     $12
+   dec     $12
+   .byte   $C7
+   iny
+   cmp     #$12
+   dex
+   .byte   $CB
+   cpy     $3456
+   cmp     $3456
+   dec     $3456
+   .byte   $CF
+   bne     *+122
+   cmp     ($12),y
+   .byte   $D2
+   .byte   $D3
+   .byte   $D4
+   cmp     $12,x
+   dec     $12,x
+   .byte   $D7
+   cld
+   cmp     $3456,y
+   .byte   $DA
+   .byte   $DB
+   .byte   $DC
+   cmp     $3456,x
+   dec     $3456,x
+   .byte   $DF
+   cpx     #$12
+   sbc     ($12,x)
+   .byte   $E2
+   .byte   $E3
+   cpx     $12
+   sbc     $12
+   inc     $12
+   .byte   $E7
+   inx
+   sbc     #$12
+   .byte   $EB
+   cpx     $3456
+   sbc     $3456
+   inc     $3456
+   .byte   $EF
+   beq     *+122
+   sbc     ($12),y
+   .byte   $F2
+   .byte   $F3
+   .byte   $F4
+   sbc     $12,x
+   inc     $12,x
+   .byte   $F7
+   sed
+   sbc     $3456,y
+   .byte   $FA
+   .byte   $FB
+   .byte   $FC
+   sbc     $3456,x
+   inc     $3456,x
+   .byte   $FF
diff --git a/test/asm/6502x-cpudetect.ref b/test/asm/6502x-cpudetect.ref
new file mode 100644 (file)
index 0000000..3434ecb
Binary files /dev/null and b/test/asm/6502x-cpudetect.ref differ
diff --git a/test/asm/6502x-opcodes.ref b/test/asm/6502x-opcodes.ref
new file mode 100644 (file)
index 0000000..f942bec
Binary files /dev/null and b/test/asm/6502x-opcodes.ref differ
diff --git a/test/asm/6502x-opcodes.s b/test/asm/6502x-opcodes.s
new file mode 100644 (file)
index 0000000..5f21aeb
--- /dev/null
@@ -0,0 +1,258 @@
+.setcpu "6502X"
+
+   brk
+   ora     ($12,x)
+   jam
+   slo     ($12,x)
+   nop     $12
+   ora     $12
+   asl     $12
+   slo     $12
+   php
+   ora     #$12
+   asl     a
+   anc     #$12
+   nop     $3456
+   ora     $3456
+   asl     $3456
+   slo     $3456
+   bpl     *+122
+   ora     ($12),y
+   .byte   $12         ; jam
+   slo     ($12),y
+   nop     $12,x
+   ora     $12,x
+   asl     $12,x
+   slo     $12,x
+   clc
+   ora     $3456,y
+   .byte   $1a         ; nop
+   slo     $3456,y
+   nop     $3456,x
+   ora     $3456,x
+   asl     $3456,x
+   slo     $3456,x
+   jsr     $3456
+   and     ($12,x)
+   .byte   $22         ; jam
+   rla     ($12,x)
+   bit     $12
+   and     $12
+   rol     $12
+   rla     $12
+   plp
+   and     #$12
+   rol     a
+   .byte   $2b         ; anc     #$12
+   bit     $3456
+   and     $3456
+   rol     $3456
+   rla     $3456
+   bmi     *+122
+   and     ($12),y
+   .byte   $32         ; jam
+   rla     ($12),y
+   .byte   $34,$12     ; nop     $12,x
+   and     $12,x
+   rol     $12,x
+   rla     $12,x
+   sec
+   and     $3456,y
+   .byte   $3a         ; nop
+   rla     $3456,y
+   .byte   $3c,$56,$34 ; nop     $3456,x
+   and     $3456,x
+   rol     $3456,x
+   rla     $3456,x
+   rti
+   eor     ($12,x)
+   .byte   $42         ; jam
+   sre     ($12,x)
+   .byte   $44,$12     ; nop     $12
+   eor     $12
+   lsr     $12
+   sre     $12
+   pha
+   eor     #$12
+   lsr     a
+   alr     #$12
+   jmp     $3456
+   eor     $3456
+   lsr     $3456
+   sre     $3456
+   bvc     *+122
+   eor     ($12),y
+   .byte   $52         ; jam
+   sre     ($12),y
+   .byte   $54,$12     ; nop     $12,x
+   eor     $12,x
+   lsr     $12,x
+   sre     $12,x
+   cli
+   eor     $3456,y
+   .byte   $5a         ; nop
+   sre     $3456,y
+   nop     $3456,x
+   eor     $3456,x
+   lsr     $3456,x
+   sre     $3456,x
+   rts
+   adc     ($12,x)
+   .byte   $62         ; jam
+   rra     ($12,x)
+   .byte   $64,$12     ; nop     $12
+   adc     $12
+   ror     $12
+   rra     $12
+   pla
+   adc     #$12
+   ror     a
+   arr     #$12
+   jmp     ($3456)
+   adc     $3456
+   ror     $3456
+   rra     $3456
+   bvs     *+122
+   adc     ($12),y
+   .byte   $72         ; jam
+   rra     ($12),y
+   .byte   $74,$12     ; nop     $12,x
+   adc     $12,x
+   ror     $12,x
+   rra     $12,x
+   sei
+   adc     $3456,y
+   .byte   $7a         ; nop
+   rra     $3456,y
+   .byte   $7c,$56,$34 ; nop     $3456,x
+   adc     $3456,x
+   ror     $3456,x
+   rra     $3456,x
+   nop     #$12
+   sta     ($12,x)
+   .byte   $82,$12     ; nop     #$12
+   sax     ($12,x)
+   sty     $12
+   sta     $12
+   stx     $12
+   sax     $12
+   dey
+   .byte   $89,$12     ; nop     #$12
+   txa
+   .byte   $8b,$12     ; xaa     #$12
+   sty     $3456
+   sta     $3456
+   stx     $3456
+   sax     $3456
+   bcc     *+122
+   sta     ($12),y
+   .byte   $92     ; jam
+   .byte   $93,$12 ; ahx     ($12),y
+   sty     $12,x
+   sta     $12,x
+   stx     $12,y
+   sax     $12,y
+   tya
+   sta     $3456,y
+   txs
+   tas     $3456,y
+   shy     $3456,x
+   sta     $3456,x
+   shx     $3456,y
+   .byte   $9f,$56,$34 ;  ahx     $3456,y
+   ldy     #$12
+   lda     ($12,x)
+   ldx     #$12
+   lax     ($12,x)
+   ldy     $12
+   lda     $12
+   ldx     $12
+   lax     $12
+   tay
+   lda     #$12
+   tax
+   lax     #$12
+   ldy     $3456
+   lda     $3456
+   ldx     $3456
+   lax     $3456
+   bcs     *+122
+   lda     ($12),y
+   .byte   $b2     ; jam
+   lax     ($12),y
+   ldy     $12,x
+   lda     $12,x
+   ldx     $12,y
+   lax     $12,y
+   clv
+   lda     $3456,y
+   tsx
+   las     $3456,y
+   ldy     $3456,x
+   lda     $3456,x
+   ldx     $3456,y
+   lax     $3456,y
+   cpy     #$12
+   cmp     ($12,x)
+   .byte   $c2,$12     ; nop     #$12
+   dcp     ($12,x)
+   cpy     $12
+   cmp     $12
+   dec     $12
+   dcp     $12
+   iny
+   cmp     #$12
+   dex
+   axs     #$12
+   cpy     $3456
+   cmp     $3456
+   dec     $3456
+   dcp     $3456
+   bne     *+122
+   cmp     ($12),y
+   .byte   $d2         ; jam
+   dcp     ($12),y
+   .byte   $d4,$12     ; nop     $12,x
+   cmp     $12,x
+   dec     $12,x
+   dcp     $12,x
+   cld
+   cmp     $3456,y
+   .byte   $da         ; nop
+   dcp     $3456,y
+   .byte   $dc,$56,$34 ; nop     $3456,x
+   cmp     $3456,x
+   dec     $3456,x
+   dcp     $3456,x
+   cpx     #$12
+   sbc     ($12,x)
+   .byte   $e2,$12     ; nop     #$12
+   isc     ($12,x)
+   cpx     $12
+   sbc     $12
+   inc     $12
+   isc     $12
+   inx
+   sbc     #$12
+   nop
+   .byte   $eb         ; nop
+   cpx     $3456
+   sbc     $3456
+   inc     $3456
+   isc     $3456
+   beq     *+122
+   sbc     ($12),y
+   .byte   $f2         ; jam
+   isc     ($12),y
+   .byte   $f4,$12     ; nop     $12,x
+   sbc     $12,x
+   inc     $12,x
+   isc     $12,x
+   sed
+   sbc     $3456,y
+   .byte   $fa         ; nop
+   isc     $3456,y
+   .byte   $fc,$56,$34 ; nop     $3456,x
+   sbc     $3456,x
+   inc     $3456,x
+   isc     $3456,x
diff --git a/test/asm/65816-cpudetect.ref b/test/asm/65816-cpudetect.ref
new file mode 100644 (file)
index 0000000..4f6e767
Binary files /dev/null and b/test/asm/65816-cpudetect.ref differ
diff --git a/test/asm/65c02-cpudetect.ref b/test/asm/65c02-cpudetect.ref
new file mode 100644 (file)
index 0000000..9f790d5
Binary files /dev/null and b/test/asm/65c02-cpudetect.ref differ
diff --git a/test/asm/65c02-opcodes.ref b/test/asm/65c02-opcodes.ref
new file mode 100644 (file)
index 0000000..2d44045
Binary files /dev/null and b/test/asm/65c02-opcodes.ref differ
diff --git a/test/asm/65c02-opcodes.s b/test/asm/65c02-opcodes.s
new file mode 100644 (file)
index 0000000..09c3f04
--- /dev/null
@@ -0,0 +1,258 @@
+.setcpu "65C02"
+
+   brk
+   ora     ($12,x)
+   .byte   $02
+   .byte   $03
+   tsb     $12
+   ora     $12
+   asl     $12
+   rmb0    $12
+   php
+   ora     #$12
+   asl     a
+   .byte   $0B
+   tsb     $3456
+   ora     $3456
+   asl     $3456
+   bbr0    $12,*+122
+   bpl     *+122
+   ora     ($12),y
+   ora     ($12)
+   .byte   $13
+   trb     $12
+   ora     $12,x
+   asl     $12,x
+   rmb1    $12
+   clc
+   ora     $3456,y
+   inc     a
+   .byte   $1B
+   trb     $3456
+   ora     $3456,x
+   asl     $3456,x
+   bbr1    $12,*+122
+   jsr     $3456
+   and     ($12,x)
+   .byte   $22
+   .byte   $23
+   bit     $12
+   and     $12
+   rol     $12
+   rmb2    $12
+   plp
+   and     #$12
+   rol     a
+   .byte   $2B
+   bit     $3456
+   and     $3456
+   rol     $3456
+   bbr2    $12,*+122
+   bmi     *+122
+   and     ($12),y
+   and     ($12)
+   .byte   $33
+   bit     $12,x
+   and     $12,x
+   rol     $12,x
+   rmb3    $12
+   sec
+   and     $3456,y
+   dec     a
+   .byte   $3B
+   bit     $3456,x
+   and     $3456,x
+   rol     $3456,x
+   bbr3    $12,*+122
+   rti
+   eor     ($12,x)
+   .byte   $42
+   .byte   $43
+   .byte   $44
+   eor     $12
+   lsr     $12
+   rmb4    $12
+   pha
+   eor     #$12
+   lsr     a
+   .byte   $4B
+   jmp     $3456
+   eor     $3456
+   lsr     $3456
+   bbr4    $12,*+122
+   bvc     *+122
+   eor     ($12),y
+   eor     ($12)
+   .byte   $53
+   .byte   $54
+   eor     $12,x
+   lsr     $12,x
+   rmb5    $12
+   cli
+   eor     $3456,y
+   phy
+   .byte   $5B
+   .byte   $5C
+   eor     $3456,x
+   lsr     $3456,x
+   bbr5    $12,*+122
+   rts
+   adc     ($12,x)
+   .byte   $62
+   .byte   $63
+   stz     $12
+   adc     $12
+   ror     $12
+   rmb6    $12
+   pla
+   adc     #$12
+   ror     a
+   .byte   $6B
+   jmp     ($3456)
+   adc     $3456
+   ror     $3456
+   bbr6    $12,*+122
+   bvs     *+122
+   adc     ($12),y
+   adc     ($12)
+   .byte   $73
+   stz     $12,x
+   adc     $12,x
+   ror     $12,x
+   rmb7    $12
+   sei
+   adc     $3456,y
+   ply
+   .byte   $7B
+   jmp     ($3456,x)
+   adc     $3456,x
+   ror     $3456,x
+   bbr7    $12,*+122
+   bra     *+122
+   sta     ($12,x)
+   .byte   $82
+   .byte   $83
+   sty     $12
+   sta     $12
+   stx     $12
+   smb0    $12
+   dey
+   bit     #$12
+   txa
+   .byte   $8B
+   sty     $3456
+   sta     $3456
+   stx     $3456
+   bbs0    $12,*+122
+   bcc     *+122
+   sta     ($12),y
+   sta     ($12)
+   .byte   $93
+   sty     $12,x
+   sta     $12,x
+   stx     $12,y
+   smb1    $12
+   tya
+   sta     $3456,y
+   txs
+   .byte   $9B
+   stz     $3456
+   sta     $3456,x
+   stz     $3456,x
+   bbs1    $12,*+122
+   ldy     #$12
+   lda     ($12,x)
+   ldx     #$12
+   .byte   $A3
+   ldy     $12
+   lda     $12
+   ldx     $12
+   smb2    $12
+   tay
+   lda     #$12
+   tax
+   .byte   $AB
+   ldy     $3456
+   lda     $3456
+   ldx     $3456
+   bbs2    $12,*+122
+   bcs     *+122
+   lda     ($12),y
+   lda     ($12)
+   .byte   $B3
+   ldy     $12,x
+   lda     $12,x
+   ldx     $12,y
+   smb3    $12
+   clv
+   lda     $3456,y
+   tsx
+   .byte   $BB
+   ldy     $3456,x
+   lda     $3456,x
+   ldx     $3456,y
+   bbs3    $12,*+122
+   cpy     #$12
+   cmp     ($12,x)
+   .byte   $C2
+   .byte   $C3
+   cpy     $12
+   cmp     $12
+   dec     $12
+   smb4    $12
+   iny
+   cmp     #$12
+   dex
+   .byte   $CB
+   cpy     $3456
+   cmp     $3456
+   dec     $3456
+   bbs4    $12,*+122
+   bne     *+122
+   cmp     ($12),y
+   cmp     ($12)
+   .byte   $D3
+   .byte   $D4
+   cmp     $12,x
+   dec     $12,x
+   smb5    $12
+   cld
+   cmp     $3456,y
+   phx
+   .byte   $DB
+   .byte   $DC
+   cmp     $3456,x
+   dec     $3456,x
+   bbs5    $12,*+122
+   cpx     #$12
+   sbc     ($12,x)
+   .byte   $E2
+   .byte   $E3
+   cpx     $12
+   sbc     $12
+   inc     $12
+   smb6    $12
+   inx
+   sbc     #$12
+   nop
+   .byte   $EB
+   cpx     $3456
+   sbc     $3456
+   inc     $3456
+   bbs6    $12,*+122
+   beq     *+122
+   sbc     ($12),y
+   sbc     ($12)
+   .byte   $F3
+   .byte   $F4
+   sbc     $12,x
+   inc     $12,x
+   smb7    $12
+   sed
+   sbc     $3456,y
+   plx
+   .byte   $FB
+   .byte   $FC
+   sbc     $3456,x
+   inc     $3456,x
+   bbs7    $12,*+122
diff --git a/test/asm/65sc02-cpudetect.ref b/test/asm/65sc02-cpudetect.ref
new file mode 100644 (file)
index 0000000..4e11bd7
Binary files /dev/null and b/test/asm/65sc02-cpudetect.ref differ
diff --git a/test/asm/65sc02-opcodes.ref b/test/asm/65sc02-opcodes.ref
new file mode 100644 (file)
index 0000000..d22fe66
Binary files /dev/null and b/test/asm/65sc02-opcodes.ref differ
diff --git a/test/asm/65sc02-opcodes.s b/test/asm/65sc02-opcodes.s
new file mode 100644 (file)
index 0000000..aa53991
--- /dev/null
@@ -0,0 +1,258 @@
+.setcpu "65SC02"
+
+   brk
+   ora     ($12,x)
+   .byte   $02
+   .byte   $03
+   tsb     $12
+   ora     $12
+   asl     $12
+   .byte   $07
+   php
+   ora     #$12
+   asl     a
+   .byte   $0B
+   tsb     $3456
+   ora     $3456
+   asl     $3456
+   .byte   $0F
+   bpl     *+122
+   ora     ($12),y
+   ora     ($12)
+   .byte   $13
+   trb     $12
+   ora     $12,x
+   asl     $12,x
+   .byte   $17
+   clc
+   ora     $3456,y
+   inc     a
+   .byte   $1B
+   trb     $3456
+   ora     $3456,x
+   asl     $3456,x
+   .byte   $1F
+   jsr     $3456
+   and     ($12,x)
+   .byte   $22
+   .byte   $23
+   bit     $12
+   and     $12
+   rol     $12
+   .byte   $27
+   plp
+   and     #$12
+   rol     a
+   .byte   $2B
+   bit     $3456
+   and     $3456
+   rol     $3456
+   .byte   $2F
+   bmi     *+122
+   and     ($12),y
+   and     ($12)
+   .byte   $33
+   bit     $12,x
+   and     $12,x
+   rol     $12,x
+   .byte   $37
+   sec
+   and     $3456,y
+   dec     a
+   .byte   $3B
+   bit     $3456,x
+   and     $3456,x
+   rol     $3456,x
+   .byte   $3F
+   rti
+   eor     ($12,x)
+   .byte   $42
+   .byte   $43
+   .byte   $44
+   eor     $12
+   lsr     $12
+   .byte   $47
+   pha
+   eor     #$12
+   lsr     a
+   .byte   $4B
+   jmp     $3456
+   eor     $3456
+   lsr     $3456
+   .byte   $4F
+   bvc     *+122
+   eor     ($12),y
+   eor     ($12)
+   .byte   $53
+   .byte   $54
+   eor     $12,x
+   lsr     $12,x
+   .byte   $57
+   cli
+   eor     $3456,y
+   phy
+   .byte   $5B
+   .byte   $5C
+   eor     $3456,x
+   lsr     $3456,x
+   .byte   $5F
+   rts
+   adc     ($12,x)
+   .byte   $62
+   .byte   $63
+   stz     $12
+   adc     $12
+   ror     $12
+   .byte   $67
+   pla
+   adc     #$12
+   ror     a
+   .byte   $6B
+   jmp     ($3456)
+   adc     $3456
+   ror     $3456
+   .byte   $6F
+   bvs     *+122
+   adc     ($12),y
+   adc     ($12)
+   .byte   $73
+   stz     $12,x
+   adc     $12,x
+   ror     $12,x
+   .byte   $77
+   sei
+   adc     $3456,y
+   ply
+   .byte   $7B
+   jmp     ($3456,x)
+   adc     $3456,x
+   ror     $3456,x
+   .byte   $7F
+   bra     *+122
+   sta     ($12,x)
+   .byte   $82
+   .byte   $83
+   sty     $12
+   sta     $12
+   stx     $12
+   .byte   $87
+   dey
+   bit     #$12
+   txa
+   .byte   $8B
+   sty     $3456
+   sta     $3456
+   stx     $3456
+   .byte   $8F
+   bcc     *+122
+   sta     ($12),y
+   sta     ($12)
+   .byte   $93
+   sty     $12,x
+   sta     $12,x
+   stx     $12,y
+   .byte   $97
+   tya
+   sta     $3456,y
+   txs
+   .byte   $9B
+   stz     $3456
+   sta     $3456,x
+   stz     $3456,x
+   .byte   $9F
+   ldy     #$12
+   lda     ($12,x)
+   ldx     #$12
+   .byte   $A3
+   ldy     $12
+   lda     $12
+   ldx     $12
+   .byte   $A7
+   tay
+   lda     #$12
+   tax
+   .byte   $AB
+   ldy     $3456
+   lda     $3456
+   ldx     $3456
+   .byte   $AF
+   bcs     *+122
+   lda     ($12),y
+   lda     ($12)
+   .byte   $B3
+   ldy     $12,x
+   lda     $12,x
+   ldx     $12,y
+   .byte   $B7
+   clv
+   lda     $3456,y
+   tsx
+   .byte   $BB
+   ldy     $3456,x
+   lda     $3456,x
+   ldx     $3456,y
+   .byte   $BF
+   cpy     #$12
+   cmp     ($12,x)
+   .byte   $C2
+   .byte   $C3
+   cpy     $12
+   cmp     $12
+   dec     $12
+   .byte   $C7
+   iny
+   cmp     #$12
+   dex
+   .byte   $CB
+   cpy     $3456
+   cmp     $3456
+   dec     $3456
+   .byte   $CF
+   bne     *+122
+   cmp     ($12),y
+   cmp     ($12)
+   .byte   $D3
+   .byte   $D4
+   cmp     $12,x
+   dec     $12,x
+   .byte   $D7
+   cld
+   cmp     $3456,y
+   phx
+   .byte   $DB
+   .byte   $DC
+   cmp     $3456,x
+   dec     $3456,x
+   .byte   $DF
+   cpx     #$12
+   sbc     ($12,x)
+   .byte   $E2
+   .byte   $E3
+   cpx     $12
+   sbc     $12
+   inc     $12
+   .byte   $E7
+   inx
+   sbc     #$12
+   nop
+   .byte   $EB
+   cpx     $3456
+   sbc     $3456
+   inc     $3456
+   .byte   $EF
+   beq     *+122
+   sbc     ($12),y
+   sbc     ($12)
+   .byte   $F3
+   .byte   $F4
+   sbc     $12,x
+   inc     $12,x
+   .byte   $F7
+   sed
+   sbc     $3456,y
+   plx
+   .byte   $FB
+   .byte   $FC
+   sbc     $3456,x
+   inc     $3456,x
+   .byte   $FF
diff --git a/test/asm/Makefile b/test/asm/Makefile
new file mode 100644 (file)
index 0000000..93210aa
--- /dev/null
@@ -0,0 +1,74 @@
+# Makefile for the assembler regression tests
+
+ifneq ($(shell echo),)
+  CMD_EXE = 1
+endif
+
+ifdef CMD_EXE
+  EXE = .exe
+  MKDIR = mkdir $(subst /,\,$1)
+  RMDIR = -rmdir /s /q $(subst /,\,$1)
+  DEL = del /f $(subst /,\,$1)
+else
+  EXE =
+  MKDIR = mkdir -p $1
+  RMDIR = $(RM) -r $1
+  DEL = $(RM) $1
+endif
+
+ifdef QUIET
+  .SILENT:
+endif
+
+CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
+
+WORKDIR = ../../testwrk/asm
+
+DIFF = $(WORKDIR)/bdiff$(EXE)
+
+CC = gcc
+CFLAGS = -O2
+
+.PHONY: all clean
+
+OPCODE_REFS := $(wildcard *-opcodes.ref)
+OPCODE_CPUS = $(foreach ref,$(OPCODE_REFS),$(ref:%-opcodes.ref=%))
+OPCODE_BINS = $(foreach cpu,$(OPCODE_CPUS),$(WORKDIR)/$(cpu)-opcodes.bin)
+
+CPUDETECT_REFS := $(wildcard *-cpudetect.ref)
+CPUDETECT_CPUS = $(foreach ref,$(CPUDETECT_REFS),$(ref:%-cpudetect.ref=%))
+CPUDETECT_BINS = $(foreach cpu,$(CPUDETECT_CPUS),$(WORKDIR)/$(cpu)-cpudetect.bin)
+
+all: $(OPCODE_BINS) $(CPUDETECT_BINS)
+
+$(WORKDIR):
+       $(call MKDIR,$(WORKDIR))
+
+$(DIFF): ../bdiff.c | $(WORKDIR)
+       $(CC) $(CFLAGS) -o $@ $<
+
+define OPCODE_template
+
+$(WORKDIR)/$1-opcodes.bin: $1-opcodes.s $(DIFF)
+       $(if $(QUIET),echo asm/$1-opcodes.bin)
+       $(CL65) --cpu $1 -t none -l $(WORKDIR)/$1-opcodes.lst -o $$@ $$<
+       $(DIFF) $$@ $1-opcodes.ref
+
+endef # OPCODE_template
+
+$(foreach cpu,$(OPCODE_CPUS),$(eval $(call OPCODE_template,$(cpu))))
+
+define CPUDETECT_template
+
+$(WORKDIR)/$1-cpudetect.bin: cpudetect.s $(DIFF)
+       $(if $(QUIET),echo asm/$1-cpudetect.bin)
+       $(CL65) --cpu $1 -t none -l $(WORKDIR)/$1-cpudetect.lst -o $$@ $$<
+       $(DIFF) $$@ $1-cpudetect.ref
+
+endef # CPUDETECT_template
+
+$(foreach cpu,$(CPUDETECT_CPUS),$(eval $(call CPUDETECT_template,$(cpu))))
+
+clean:
+       @$(call RMDIR,$(WORKDIR))
+       @$(call DEL,$(OPCODE_REFS:.ref=.o) cpudetect.o)
diff --git a/test/asm/README b/test/asm/README
new file mode 100644 (file)
index 0000000..a2b1e9a
--- /dev/null
@@ -0,0 +1,48 @@
+
+Assembler Testcases
+===================
+
+Opcode Tests:
+-------------
+
+These testcases are inspired by the ones now removed from test/assembler.
+The main purpose is to have each possible opcode generated at least once,
+either by an assembly instruction or a ".byte"-placeholder. Typically
+generated by disassembling a binary dump that contains data in the form
+of the pattern that each opcode is stated once in order followed by easy
+to recognise:
+
+00 00 EA 00
+01 00 EA 00
+02 00 EA 00
+[...]
+fe 00 EA 00
+ff 00 EA 00
+
+The disassembly is then put in a better readable form by replacing the
+leftover dummy opcode parameters with something more recognizable.
+
+The testcases for 6502, 6502x, 65sc02, 65c02, 4510, and huc6280 have been
+put together by Sven Oliver ("SvOlli") Moll, as well as a template for the
+m740 instructions set.
+
+Still to do is to find a way to implement an opcode testcase for the 65816
+processor, since it's capable of executing instructions with an 8-bit and
+a 16-bit operator alike, only distinguished by one processor flag.
+
+
+CPU detect Tests
+----------------
+
+These tests all assemble the same file "cpudetect.s" which contains several
+conditionals for several CPUs, only using every option known to the "--cpu"
+commandline switch of ca65/cl65.
+
+
+Reference (".ref") Files
+------------------------
+
+A hint on creating these files: when running the test, it will fail due to
+the missing ".ref" file. Review the output of the ".lst" very pedantic, then
+copy the ".bin" to the ".ref" file.
+
diff --git a/test/asm/cpudetect.s b/test/asm/cpudetect.s
new file mode 100644 (file)
index 0000000..adad7c1
--- /dev/null
@@ -0,0 +1,66 @@
+
+.macpack cpu
+
+; step 1: try to assemble an instruction that's exclusive to this set
+;         (when possible)
+
+.ifp02
+   lda #$ea
+.endif
+
+.ifpsc02
+   jmp ($1234,x)
+.endif
+
+.ifpc02
+   rmb0 $12
+.endif
+
+.ifp816
+   xba
+.endif
+
+.ifp4510
+   taz
+.endif
+
+
+; step 2: check for bitwise compatibility of instructions sets
+;         (made verbose for better reading with hexdump/hd(1))
+
+.if (.cpu .bitand CPU_ISET_NONE)
+   .byte 0,"CPU_ISET_NONE"
+.endif
+
+.if (.cpu .bitand CPU_ISET_6502)
+   .byte 0,"CPU_ISET_6502"
+.endif
+
+.if (.cpu .bitand CPU_ISET_6502X)
+   .byte 0,"CPU_ISET_6502X"
+.endif
+
+.if (.cpu .bitand CPU_ISET_65SC02)
+   .byte 0,"CPU_ISET_65SC02"
+.endif
+
+.if (.cpu .bitand CPU_ISET_65C02)
+   .byte 0,"CPU_ISET_65C02"
+.endif
+
+.if (.cpu .bitand CPU_ISET_65816)
+   .byte 0,"CPU_ISET_65816"
+.endif
+
+.if (.cpu .bitand CPU_ISET_SWEET16)
+   .byte 0,"CPU_ISET_SWEET16"
+.endif
+
+.if (.cpu .bitand CPU_ISET_HUC6280)
+   .byte 0,"CPU_ISET_HUC6280"
+.endif
+
+.if (.cpu .bitand CPU_ISET_4510)
+   .byte 0,"CPU_ISET_4510"
+.endif
+
diff --git a/test/asm/huc6280-cpudetect.ref b/test/asm/huc6280-cpudetect.ref
new file mode 100644 (file)
index 0000000..646e0f4
Binary files /dev/null and b/test/asm/huc6280-cpudetect.ref differ
diff --git a/test/asm/huc6280-opcodes.ref b/test/asm/huc6280-opcodes.ref
new file mode 100644 (file)
index 0000000..33f5b29
Binary files /dev/null and b/test/asm/huc6280-opcodes.ref differ
diff --git a/test/asm/huc6280-opcodes.s b/test/asm/huc6280-opcodes.s
new file mode 100644 (file)
index 0000000..bd3ad5c
--- /dev/null
@@ -0,0 +1,258 @@
+.setcpu "huc6280"
+
+   brk
+   ora     ($12,x)
+   sxy
+   st0     #$12
+   tsb     $12
+   ora     $12
+   asl     $12
+   rmb0    $12
+   php
+   ora     #$12
+   asl     a
+   .byte   $0B
+   tsb     $3456
+   ora     $3456
+   asl     $3456
+   bbr0    $12,*+122
+   bpl     *+122
+   ora     ($12),y
+   ora     ($12)
+   st1     #$12
+   trb     $12
+   ora     $12,x
+   asl     $12,x
+   rmb1    $12
+   clc
+   ora     $3456,y
+   inc     a
+   .byte   $1B
+   trb     $3456
+   ora     $3456,x
+   asl     $3456,x
+   bbr1    $12,*+122
+   jsr     $3456
+   and     ($12,x)
+   sax
+   st2     #$12
+   bit     $12
+   and     $12
+   rol     $12
+   rmb2    $12
+   plp
+   and     #$12
+   rol     a
+   .byte   $2B
+   bit     $3456
+   and     $3456
+   rol     $3456
+   bbr2    $12,*+122
+   bmi     *+122
+   and     ($12),y
+   and     ($12)
+   .byte   $33
+   bit     $12,x
+   and     $12,x
+   rol     $12,x
+   rmb3    $12
+   sec
+   and     $3456,y
+   dec     a
+   .byte   $3B
+   bit     $3456,x
+   and     $3456,x
+   rol     $3456,x
+   bbr3    $12,*+122
+   rti
+   eor     ($12,x)
+   say
+   tma     #$02
+   bsr     *+122
+   eor     $12
+   lsr     $12
+   rmb4    $12
+   pha
+   eor     #$12
+   lsr     a
+   .byte   $4B
+   jmp     $3456
+   eor     $3456
+   lsr     $3456
+   bbr4    $12,*+122
+   bvc     *+122
+   eor     ($12),y
+   eor     ($12)
+   tam     #$12
+   csl
+   eor     $12,x
+   lsr     $12,x
+   rmb5    $12
+   cli
+   eor     $3456,y
+   phy
+   .byte   $5B
+   .byte   $5C
+   eor     $3456,x
+   lsr     $3456,x
+   bbr5    $12,*+122
+   rts
+   adc     ($12,x)
+   cla
+   .byte   $63
+   stz     $12
+   adc     $12
+   ror     $12
+   rmb6    $12
+   pla
+   adc     #$12
+   ror     a
+   .byte   $6B
+   jmp     ($3456)
+   adc     $3456
+   ror     $3456
+   bbr6    $12,*+122
+   bvs     *+122
+   adc     ($12),y
+   adc     ($12)
+   tii     $3333,$7373,$1111
+   stz     $12,x
+   adc     $12,x
+   ror     $12,x
+   rmb7    $12
+   sei
+   adc     $3456,y
+   ply
+   .byte   $7B
+   jmp     ($3456,x)
+   adc     $3456,x
+   ror     $3456,x
+   bbr7    $12,*+122
+   bra     *+122
+   sta     ($12,x)
+   clx
+   tst     #$12,$EA
+   sty     $12
+   sta     $12
+   stx     $12
+   smb0    $12
+   dey
+   bit     #$12
+   txa
+   .byte   $8B
+   sty     $3456
+   sta     $3456
+   stx     $3456
+   bbs0    $12,*+122
+   bcc     *+122
+   sta     ($12),y
+   sta     ($12)
+   tst     #$12,$EAEA
+   sty     $12,x
+   sta     $12,x
+   stx     $12,y
+   smb1    $12
+   tya
+   sta     $3456,y
+   txs
+   .byte   $9B
+   stz     $3456
+   sta     $3456,x
+   stz     $3456,x
+   bbs1    $12,*+122
+   ldy     #$12
+   lda     ($12,x)
+   ldx     #$12
+   tst     #$12,$EA,x
+   ldy     $12
+   lda     $12
+   ldx     $12
+   smb2    $12
+   tay
+   lda     #$12
+   tax
+   .byte   $AB
+   ldy     $3456
+   lda     $3456
+   ldx     $3456
+   bbs2    $12,*+122
+   bcs     *+122
+   lda     ($12),y
+   lda     ($12)
+   tst     #$12,$EAEA,x
+   ldy     $12,x
+   lda     $12,x
+   ldx     $12,y
+   smb3    $12
+   clv
+   lda     $3456,y
+   tsx
+   .byte   $BB
+   ldy     $3456,x
+   lda     $3456,x
+   ldx     $3456,y
+   bbs3    $12,*+122
+   cpy     #$12
+   cmp     ($12,x)
+   cly
+   tdd     $3333,$C3C3,$1111
+   cpy     $12
+   cmp     $12
+   dec     $12
+   smb4    $12
+   iny
+   cmp     #$12
+   dex
+   .byte   $CB
+   cpy     $3456
+   cmp     $3456
+   dec     $3456
+   bbs4    $12,*+122
+   bne     *+122
+   cmp     ($12),y
+   cmp     ($12)
+   tin     $3333,$D3D3,$1111
+   .byte   $D4
+   cmp     $12,x
+   dec     $12,x
+   smb5    $12
+   cld
+   cmp     $3456,y
+   phx
+   .byte   $DB
+   .byte   $DC
+   cmp     $3456,x
+   dec     $3456,x
+   bbs5    $12,*+122
+   cpx     #$12
+   sbc     ($12,x)
+   .byte   $E2
+   tia     $3333,$E3E3,$1111
+   cpx     $12
+   sbc     $12
+   inc     $12
+   smb6    $12
+   inx
+   sbc     #$12
+   nop
+   .byte   $EB
+   cpx     $3456
+   sbc     $3456
+   inc     $3456
+   bbs6    $12,*+122
+   beq     *+122
+   sbc     ($12),y
+   sbc     ($12)
+   tai     $3333,$F3F3,$1111
+   .byte   $F4
+   sbc     $12,x
+   inc     $12,x
+   smb7    $12
+   sed
+   sbc     $3456,y
+   plx
+   .byte   $FB
+   .byte   $FC
+   sbc     $3456,x
+   inc     $3456,x
+   bbs7    $12,*+122
diff --git a/test/asm/m740-opcodes.s b/test/asm/m740-opcodes.s
new file mode 100644 (file)
index 0000000..df6d714
--- /dev/null
@@ -0,0 +1,260 @@
+.setcpu "65C02"
+; copy of 65c02, comments note changes to the m740 according to
+; http://documentation.renesas.com/doc/products/mpumcu/rej09b0322_740sm.pdf
+
+   brk
+   ora     ($12,x)
+   .byte   $02,$00,$00 ; jsr zp,ind
+   .byte   $03,$00,$00 ; bbs 0,a
+   tsb     $12         ; .byte $04
+   ora     $12
+   asl     $12
+   rmb0    $12         ; bbs 0,zp
+   php
+   ora     #$12
+   asl     a
+   .byte   $0B,$00,$00 ; seb 0,a
+   tsb     $3456       ; .byte $0c
+   ora     $3456
+   asl     $3456
+   bbr0    $12,*+122   ; seb 0,zp
+   bpl     *+122
+   ora     ($12),y
+   ora     ($12)       ; clt
+   .byte   $13,$00,$00 ; bbc 0,a
+   trb     $12         ; .byte $14
+   ora     $12,x
+   asl     $12,x
+   rmb1    $12         ; bbc 0,zp
+   clc
+   ora     $3456,y
+   inc     a
+   .byte   $1B,$00,$00 ; clb 0,a
+   trb     $3456       ; .byte $1c
+   ora     $3456,x
+   asl     $3456,x
+   bbr1    $12,*+122   ; clb 0,zp
+   jsr     $3456
+   and     ($12,x)
+   .byte   $22,$00,$00 ; jsr sp
+   .byte   $23,$00,$00 ; bbs 1,a
+   bit     $12
+   and     $12
+   rol     $12
+   rmb2    $12         ; bbs 1,zp
+   plp
+   and     #$12
+   rol     a
+   .byte   $2B,$00,$00 ; seb 1,a
+   bit     $3456
+   and     $3456
+   rol     $3456
+   bbr2    $12,*+122   ; seb 1,zp
+   bmi     *+122
+   and     ($12),y
+   and     ($12)       ; set
+   .byte   $33,$00,$00 ; bbc 1,a
+   bit     $12,x       ; .byte $34
+   and     $12,x
+   rol     $12,x
+   rmb3    $12         ; bbc 1,zp
+   sec
+   and     $3456,y
+   dec     a
+   .byte   $3B,$00,$00 ; clb 1,a
+   bit     $3456,x     ; ldm zp
+   and     $3456,x
+   rol     $3456,x
+   bbr3    $12,*+122   ; clb 1,zp
+   rti
+   eor     ($12,x)
+   .byte   $42,$00,$00 ; stp
+   .byte   $43,$00,$00 ; bbs 2,a
+   .byte   $44,$00,$00 ; com zp
+   eor     $12
+   lsr     $12
+   rmb4    $12         ; bbs 2,zp
+   pha
+   eor     #$12
+   lsr     a
+   .byte   $4B,$00,$00 ; seb 2,a
+   jmp     $3456
+   eor     $3456
+   lsr     $3456
+   bbr4    $12,*+122   ; seb 2,zp
+   bvc     *+122
+   eor     ($12),y
+   eor     ($12)       ; .byte $52
+   .byte   $53,$00,$00 ; bbc 2,a
+   .byte   $54,$00,$00
+   eor     $12,x
+   lsr     $12,x
+   rmb5    $12         ; bbc 2,zp
+   cli
+   eor     $3456,y
+   phy
+   .byte   $5B,$00,$00 ; clb 2,a
+   .byte   $5C,$00,$00
+   eor     $3456,x
+   lsr     $3456,x
+   bbr5    $12,*+122   ; clb 2,zp
+   rts
+   adc     ($12,x)
+   .byte   $62,$00,$00 ; mul zp,x
+   .byte   $63,$00,$00 ; bbs 3,a
+   stz     $12         ; tst zp
+   adc     $12
+   ror     $12
+   rmb6    $12         ; bbs 3,zp
+   pla
+   adc     #$12
+   ror     a
+   .byte   $6B,$00,$00 ; seb 3,a
+   jmp     ($3456)
+   adc     $3456
+   ror     $3456
+   bbr6    $12,*+122   ; seb 3,zp
+   bvs     *+122
+   adc     ($12),y
+   adc     ($12)       ; .byte $72
+   .byte   $73,$00,$00 ; bbc 3,a
+   stz     $12,x       ; .byte $74
+   adc     $12,x
+   ror     $12,x
+   rmb7    $12         ; bbc 3,zp
+   sei
+   adc     $3456,y
+   ply
+   .byte   $7B,$00,$00 ; clb 3,a
+   jmp     ($3456,x)   ; .byte $7c
+   adc     $3456,x
+   ror     $3456,x
+   bbr7    $12,*+122   ; clb 3,zp
+   bra     *+122
+   sta     ($12,x)
+   .byte   $82,$00,$00 ; rrf zp
+   .byte   $83,$00,$00 ; bbs 4,a
+   sty     $12
+   sta     $12
+   stx     $12
+   smb0    $12         ; bbs 4,zp
+   dey
+   bit     #$12
+   txa
+   .byte   $8B,$00,$00 ; seb 4,a
+   sty     $3456
+   sta     $3456
+   stx     $3456
+   bbs0    $12,*+122   ; seb 4,zp
+   bcc     *+122
+   sta     ($12),y
+   sta     ($12)       ; .byte $92
+   .byte   $93,$00,$00 ; bbc 4,a
+   sty     $12,x
+   sta     $12,x
+   stx     $12,y
+   smb1    $12         ; bbc 4,zp
+   tya
+   sta     $3456,y
+   txs
+   .byte   $9B,$00,$00 ; clb 4,a
+   stz     $3456       ; .byte $9c
+   sta     $3456,x
+   stz     $3456,x     ; .byte $9e
+   bbs1    $12,*+122   ; clb 4,zp
+   ldy     #$12
+   lda     ($12,x)
+   ldx     #$12
+   .byte   $A3,$00,$00 ; bbs 5,a
+   ldy     $12
+   lda     $12
+   ldx     $12
+   smb2    $12         ; bbs 5,zp
+   tay
+   lda     #$12
+   tax
+   .byte   $AB,$00,$00 ; seb 5,a
+   ldy     $3456
+   lda     $3456
+   ldx     $3456
+   bbs2    $12,*+122   ; seb 5,zp
+   bcs     *+122
+   lda     ($12),y
+   lda     ($12)       ; .byte $b2
+   .byte   $B3,$00,$00 ; bbc 5,a
+   ldy     $12,x
+   lda     $12,x
+   ldx     $12,y
+   smb3    $12         ; bbc 5,zp
+   clv
+   lda     $3456,y
+   tsx
+   .byte   $BB,$00,$00 ; clb 5,a
+   ldy     $3456,x
+   lda     $3456,x
+   ldx     $3456,y
+   bbs3    $12,*+122   ; clb 5,zp
+   cpy     #$12
+   cmp     ($12,x)
+   .byte   $C2,$00,$00 ; wit
+   .byte   $C3,$00,$00 ; bbs 6,a
+   cpy     $12
+   cmp     $12
+   dec     $12
+   smb4    $12         ; bbs 6,zp
+   iny
+   cmp     #$12
+   dex
+   .byte   $CB,$00,$00 ; seb 6,a
+   cpy     $3456
+   cmp     $3456
+   dec     $3456
+   bbs4    $12,*+122   ; seb 6,zp
+   bne     *+122
+   cmp     ($12),y
+   cmp     ($12)       ; .byte $d2
+   .byte   $D3,$00,$00 ; bbc 6,a
+   .byte   $D4,$00,$00
+   cmp     $12,x
+   dec     $12,x
+   smb5    $12         ; bbc 6,zp
+   cld
+   cmp     $3456,y
+   phx
+   .byte   $DB,$00,$00 ; clb 6,a
+   .byte   $DC,$00,$00
+   cmp     $3456,x
+   dec     $3456,x
+   bbs5    $12,*+122   ; clb 6,zp
+   cpx     #$12
+   sbc     ($12,x)
+   .byte   $E2,$00,$00 ; div zp,x
+   .byte   $E3,$00,$00 ; bbs 7,a
+   cpx     $12
+   sbc     $12
+   inc     $12
+   smb6    $12         ; bbs 7,zp
+   inx
+   sbc     #$12
+   nop
+   .byte   $EB,$00,$00 ; seb 7,a
+   cpx     $3456
+   sbc     $3456
+   inc     $3456
+   bbs6    $12,*+122   ; seb 7,zp
+   beq     *+122
+   sbc     ($12),y
+   sbc     ($12)       ; .byte $f2
+   .byte   $F3,$00,$00 ; bbc 7,a
+   .byte   $F4,$00,$00
+   sbc     $12,x
+   inc     $12,x
+   smb7    $12         ; bbc 7,zp
+   sed
+   sbc     $3456,y
+   plx
+   .byte   $FB,$00,$00 ; clb 7,a
+   .byte   $FC,$00,$00
+   sbc     $3456,x
+   inc     $3456,x
+   bbs7    $12,*+122   ; clb 7,zp
diff --git a/test/assembler/.gitignore b/test/assembler/.gitignore
deleted file mode 100644 (file)
index c0c74a3..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-*.o
-*.bin
-*.lst
diff --git a/test/assembler/4510-cpudetect.ref b/test/assembler/4510-cpudetect.ref
deleted file mode 100644 (file)
index 515557c..0000000
Binary files a/test/assembler/4510-cpudetect.ref and /dev/null differ
diff --git a/test/assembler/4510-opcodes.ref b/test/assembler/4510-opcodes.ref
deleted file mode 100644 (file)
index b65b12e..0000000
Binary files a/test/assembler/4510-opcodes.ref and /dev/null differ
diff --git a/test/assembler/4510-opcodes.s b/test/assembler/4510-opcodes.s
deleted file mode 100644 (file)
index 3d68056..0000000
+++ /dev/null
@@ -1,278 +0,0 @@
-.setcpu "4510"
-
-   brk
-   ora ($05,x)
-   cle
-   see
-   tsb $02
-   ora $02
-   asl $02
-   rmb0 $02
-   php
-   ora #$01
-   asl
-   tsy
-   tsb $1234
-   ora $1234
-   asl $1234
-   bbr0 $02,*+$34
-
-   bpl *+$32
-   ora ($06),y
-   ora ($07),z
-   lbpl *+$3133 ; bpl *+$3133
-   trb $02
-   ora $03,x
-   asl $03,x
-   rmb1 $02
-   clc
-   ora $1456,y
-   inc
-   inz
-   trb $1234
-   ora $1345,x
-   asl $1345,x
-   bbr1 $02,*+$34
-
-   jsr $1234
-   and ($05,x)
-   jsr ($2345)
-   jsr ($2456,x)
-   bit $02
-   and $02
-   rol $02
-   rmb2 $02
-   plp
-   and #$01
-   rol
-   tys
-   bit $1234
-   and $1234
-   rol $1234
-   bbr2 $02,*+$34
-
-   bmi *+$32
-   and ($06),y
-   and ($07),z
-   lbmi *+$3133 ; bmi *+$3133
-   bit $03,x
-   and $03,x
-   rol $03,x
-   rmb3 $02
-   sec
-   and $1456,y
-   dec
-   dez
-   bit $1345,x
-   and $1345,x
-   rol $1345,x
-   bbr3 $02,*+$34
-
-   rti
-   eor ($05,x)
-   neg
-   asr
-   asr $02
-   eor $02
-   lsr $02
-   rmb4 $02
-   pha
-   eor #$01
-   lsr
-   taz
-   jmp $1234
-   eor $1234
-   lsr $1234
-   bbr4 $02,*+$34
-
-   bvc *+$32
-   eor ($06),y
-   eor ($07),z
-   lbvc *+$3133 ; bvc *+$3133
-   asr $03,x
-   eor $03,x
-   lsr $03,x
-   rmb5 $02
-   cli
-   eor $1456,y
-   phy
-   tab
-   map
-   eor $1345,x
-   lsr $1345,x
-   bbr5 $02,*+$34
-
-   rts
-   adc ($05,x)
-   rtn #$09
-   bsr *+$3133
-   stz $02
-   adc $02
-   ror $02
-   rmb6 $02
-   pla
-   adc #$01
-   ror
-   tza
-   jmp ($2345)
-   adc $1234
-   ror $1234
-   bbr6 $02,*+$34
-
-   bvs *+$32
-   adc ($06),y
-   adc ($07),z
-   lbvs *+$3133 ; bvs *+$3133
-   stz $03,x
-   adc $03,x
-   ror $03,x
-   rmb7 $02
-   sei
-   adc $1456,y
-   ply
-   tba
-   jmp ($2456,x)
-   adc $1345,x
-   ror $1345,x
-   bbr7 $02,*+$34
-
-   bra *+$32
-   sta ($05,x)
-   sta ($0f,s),y
-   sta ($0f,sp),y
-   lbra *+$3133 ; bra *+$3133
-   sty $02
-   sta $02
-   stx $02
-   smb0 $02
-   dey
-   bit #$01
-   txa
-   sty $1345,x
-   sty $1234
-   sta $1234
-   stx $1234
-   bbs0 $02,*+$34
-
-   bcc *+$32
-   sta ($06),y
-   sta ($07),z
-   lbcc *+$3133 ; bcc *+$3133
-   sty $03,x
-   sta $03,x
-   stx $04,y
-   smb1 $02
-   tya
-   sta $1456,y
-   txs
-   stx $1456,y
-   stz $1234
-   sta $1345,x
-   stz $1345,x
-   bbs1 $02,*+$34
-
-   ldy #$01
-   lda ($05,x)
-   ldx #$01
-   ldz #$01
-   ldy $02
-   lda $02
-   ldx $02
-   smb2 $02
-   tay
-   lda #$01
-   tax
-   ldz $1234
-   ldy $1234
-   lda $1234
-   ldx $1234
-   bbs2 $02,*+$34
-
-   bcs *+$32
-   lda ($06),y
-   lda ($07),z
-   lbcs *+$3133 ; bcs *+$3133
-   ldy $03,x
-   lda $03,x
-   ldx $04,y
-   smb3 $02
-   clv
-   lda $1456,y
-   tsx
-   ldz $1345,x
-   ldy $1345,x
-   lda $1345,x
-   ldx $1456,y
-   bbs3 $02,*+$34
-
-   cpy #$01
-   cmp ($05,x)
-   cpz #$01
-   dew $02
-   cpy $02
-   cmp $02
-   dec $02
-   smb4 $02
-   iny
-   cmp #$01
-   dex
-   asw $1234
-   cpy $1234
-   cmp $1234
-   dec $1234
-   bbs4 $02,*+$34
-
-   bne *+$32
-   cmp ($06),y
-   cmp ($07),z
-   lbne *+$3133 ; bne *+$3133
-   cpz $02
-   cmp $03,x
-   dec $03,x
-   smb5 $02
-   cld
-   cmp $1456,y
-   phx
-   phz
-   cpz $1234
-   cmp $1345,x
-   dec $1345,x
-   bbs5 $02,*+$34
-
-   cpx #$01
-   sbc ($05,x)
-   lda ($0f,s),y
-   lda ($0f,sp),y
-   inw $02
-   cpx $02
-   sbc $02
-   inc $02
-   smb6 $02
-   inx
-   sbc #$01
-   eom
-   nop
-   row $1234
-   cpx $1234
-   sbc $1234
-   inc $1234
-   bbs6 $02,*+$34
-
-   beq *+$32
-   sbc ($06),y
-   sbc ($07),z
-   lbeq *+$3133 ; beq *+$3133
-   phd #$089a
-   phw #$089a
-   sbc $03,x
-   inc $03,x
-   smb7 $02
-   sed
-   sbc $1456,y
-   plx
-   plz
-   phd $1234
-   phw $1234
-   sbc $1345,x
-   inc $1345,x
-   bbs7 $02,*+$34
diff --git a/test/assembler/6502-cpudetect.ref b/test/assembler/6502-cpudetect.ref
deleted file mode 100644 (file)
index 9b0aeb1..0000000
Binary files a/test/assembler/6502-cpudetect.ref and /dev/null differ
diff --git a/test/assembler/6502-opcodes.ref b/test/assembler/6502-opcodes.ref
deleted file mode 100644 (file)
index c12fa8f..0000000
Binary files a/test/assembler/6502-opcodes.ref and /dev/null differ
diff --git a/test/assembler/6502-opcodes.s b/test/assembler/6502-opcodes.s
deleted file mode 100644 (file)
index 5cb94c2..0000000
+++ /dev/null
@@ -1,257 +0,0 @@
-.setcpu "6502"
-
-   brk
-   ora     ($12,x)
-   .byte   $02
-   .byte   $03
-   .byte   $04
-   ora     $12
-   asl     $12
-   .byte   $07
-   php
-   ora     #$12
-   asl     a
-   .byte   $0B
-   .byte   $0C
-   ora     $3456
-   asl     $3456
-   .byte   $0F
-   bpl     *+122
-   ora     ($12),y
-   .byte   $12
-   .byte   $13
-   .byte   $14
-   ora     $12,x
-   asl     $12,x
-   .byte   $17
-   clc
-   ora     $3456,y
-   .byte   $1A
-   .byte   $1B
-   .byte   $1C
-   ora     $3456,x
-   asl     $3456,x
-   .byte   $1F
-   jsr     $3456
-   and     ($12,x)
-   .byte   $22
-   .byte   $23
-   bit     $12
-   and     $12
-   rol     $12
-   .byte   $27
-   plp
-   and     #$12
-   rol     a
-   .byte   $2B
-   bit     $3456
-   and     $3456
-   rol     $3456
-   .byte   $2F
-   bmi     *+122
-   and     ($12),y
-   .byte   $32
-   .byte   $33
-   .byte   $34
-   and     $12,x
-   rol     $12,x
-   .byte   $37
-   sec
-   and     $3456,y
-   .byte   $3A
-   .byte   $3B
-   .byte   $3C
-   and     $3456,x
-   rol     $3456,x
-   .byte   $3F
-   rti
-   eor     ($12,x)
-   .byte   $42
-   .byte   $43
-   .byte   $44
-   eor     $12
-   lsr     $12
-   .byte   $47
-   pha
-   eor     #$12
-   lsr     a
-   .byte   $4B
-   jmp     $3456
-   eor     $3456
-   lsr     $3456
-   .byte   $4F
-   bvc     *+122
-   eor     ($12),y
-   .byte   $52
-   .byte   $53
-   .byte   $54
-   eor     $12,x
-   lsr     $12,x
-   .byte   $57
-   cli
-   eor     $3456,y
-   .byte   $5A
-   .byte   $5B
-   .byte   $5C
-   eor     $3456,x
-   lsr     $3456,x
-   .byte   $5F
-   rts
-   adc     ($12,x)
-   .byte   $62
-   .byte   $63
-   .byte   $64
-   adc     $12
-   ror     $12
-   .byte   $67
-   pla
-   adc     #$12
-   ror     a
-   .byte   $6B
-   jmp     ($3456)
-   adc     $3456
-   ror     $3456
-   .byte   $6F
-   bvs     *+122
-   adc     ($12),y
-   .byte   $72
-   .byte   $73
-   .byte   $74
-   adc     $12,x
-   ror     $12,x
-   .byte   $77
-   sei
-   adc     $3456,y
-   .byte   $7A
-   .byte   $7B
-   .byte   $7C
-   adc     $3456,x
-   ror     $3456,x
-   .byte   $7F
-   .byte   $80
-   sta     ($12,x)
-   .byte   $82
-   .byte   $83
-   sty     $12
-   sta     $12
-   stx     $12
-   .byte   $87
-   dey
-   .byte   $89
-   txa
-   .byte   $8B
-   sty     $3456
-   sta     $3456
-   stx     $3456
-   .byte   $8F
-   bcc     *+122
-   sta     ($12),y
-   .byte   $92
-   .byte   $93
-   sty     $12,x
-   sta     $12,x
-   stx     $12,y
-   .byte   $97
-   tya
-   sta     $3456,y
-   txs
-   .byte   $9B
-   .byte   $9C
-   sta     $3456,x
-   .byte   $9E
-   .byte   $9F
-   ldy     #$12
-   lda     ($12,x)
-   ldx     #$12
-   .byte   $A3
-   ldy     $12
-   lda     $12
-   ldx     $12
-   .byte   $A7
-   tay
-   lda     #$12
-   tax
-   .byte   $AB
-   ldy     $3456
-   lda     $3456
-   ldx     $3456
-   .byte   $AF
-   bcs     *+122
-   lda     ($12),y
-   .byte   $B2
-   .byte   $B3
-   ldy     $12,x
-   lda     $12,x
-   ldx     $12,y
-   .byte   $B7
-   clv
-   lda     $3456,y
-   tsx
-   .byte   $BB
-   ldy     $3456,x
-   lda     $3456,x
-   ldx     $3456,y
-   .byte   $BF
-   cpy     #$12
-   cmp     ($12,x)
-   .byte   $C2
-   .byte   $C3
-   cpy     $12
-   cmp     $12
-   dec     $12
-   .byte   $C7
-   iny
-   cmp     #$12
-   dex
-   .byte   $CB
-   cpy     $3456
-   cmp     $3456
-   dec     $3456
-   .byte   $CF
-   bne     *+122
-   cmp     ($12),y
-   .byte   $D2
-   .byte   $D3
-   .byte   $D4
-   cmp     $12,x
-   dec     $12,x
-   .byte   $D7
-   cld
-   cmp     $3456,y
-   .byte   $DA
-   .byte   $DB
-   .byte   $DC
-   cmp     $3456,x
-   dec     $3456,x
-   .byte   $DF
-   cpx     #$12
-   sbc     ($12,x)
-   .byte   $E2
-   .byte   $E3
-   cpx     $12
-   sbc     $12
-   inc     $12
-   .byte   $E7
-   inx
-   sbc     #$12
-   .byte   $EB
-   cpx     $3456
-   sbc     $3456
-   inc     $3456
-   .byte   $EF
-   beq     *+122
-   sbc     ($12),y
-   .byte   $F2
-   .byte   $F3
-   .byte   $F4
-   sbc     $12,x
-   inc     $12,x
-   .byte   $F7
-   sed
-   sbc     $3456,y
-   .byte   $FA
-   .byte   $FB
-   .byte   $FC
-   sbc     $3456,x
-   inc     $3456,x
-   .byte   $FF
diff --git a/test/assembler/6502x-cpudetect.ref b/test/assembler/6502x-cpudetect.ref
deleted file mode 100644 (file)
index 3434ecb..0000000
Binary files a/test/assembler/6502x-cpudetect.ref and /dev/null differ
diff --git a/test/assembler/6502x-opcodes.ref b/test/assembler/6502x-opcodes.ref
deleted file mode 100644 (file)
index f942bec..0000000
Binary files a/test/assembler/6502x-opcodes.ref and /dev/null differ
diff --git a/test/assembler/6502x-opcodes.s b/test/assembler/6502x-opcodes.s
deleted file mode 100644 (file)
index 5f21aeb..0000000
+++ /dev/null
@@ -1,258 +0,0 @@
-.setcpu "6502X"
-
-   brk
-   ora     ($12,x)
-   jam
-   slo     ($12,x)
-   nop     $12
-   ora     $12
-   asl     $12
-   slo     $12
-   php
-   ora     #$12
-   asl     a
-   anc     #$12
-   nop     $3456
-   ora     $3456
-   asl     $3456
-   slo     $3456
-   bpl     *+122
-   ora     ($12),y
-   .byte   $12         ; jam
-   slo     ($12),y
-   nop     $12,x
-   ora     $12,x
-   asl     $12,x
-   slo     $12,x
-   clc
-   ora     $3456,y
-   .byte   $1a         ; nop
-   slo     $3456,y
-   nop     $3456,x
-   ora     $3456,x
-   asl     $3456,x
-   slo     $3456,x
-   jsr     $3456
-   and     ($12,x)
-   .byte   $22         ; jam
-   rla     ($12,x)
-   bit     $12
-   and     $12
-   rol     $12
-   rla     $12
-   plp
-   and     #$12
-   rol     a
-   .byte   $2b         ; anc     #$12
-   bit     $3456
-   and     $3456
-   rol     $3456
-   rla     $3456
-   bmi     *+122
-   and     ($12),y
-   .byte   $32         ; jam
-   rla     ($12),y
-   .byte   $34,$12     ; nop     $12,x
-   and     $12,x
-   rol     $12,x
-   rla     $12,x
-   sec
-   and     $3456,y
-   .byte   $3a         ; nop
-   rla     $3456,y
-   .byte   $3c,$56,$34 ; nop     $3456,x
-   and     $3456,x
-   rol     $3456,x
-   rla     $3456,x
-   rti
-   eor     ($12,x)
-   .byte   $42         ; jam
-   sre     ($12,x)
-   .byte   $44,$12     ; nop     $12
-   eor     $12
-   lsr     $12
-   sre     $12
-   pha
-   eor     #$12
-   lsr     a
-   alr     #$12
-   jmp     $3456
-   eor     $3456
-   lsr     $3456
-   sre     $3456
-   bvc     *+122
-   eor     ($12),y
-   .byte   $52         ; jam
-   sre     ($12),y
-   .byte   $54,$12     ; nop     $12,x
-   eor     $12,x
-   lsr     $12,x
-   sre     $12,x
-   cli
-   eor     $3456,y
-   .byte   $5a         ; nop
-   sre     $3456,y
-   nop     $3456,x
-   eor     $3456,x
-   lsr     $3456,x
-   sre     $3456,x
-   rts
-   adc     ($12,x)
-   .byte   $62         ; jam
-   rra     ($12,x)
-   .byte   $64,$12     ; nop     $12
-   adc     $12
-   ror     $12
-   rra     $12
-   pla
-   adc     #$12
-   ror     a
-   arr     #$12
-   jmp     ($3456)
-   adc     $3456
-   ror     $3456
-   rra     $3456
-   bvs     *+122
-   adc     ($12),y
-   .byte   $72         ; jam
-   rra     ($12),y
-   .byte   $74,$12     ; nop     $12,x
-   adc     $12,x
-   ror     $12,x
-   rra     $12,x
-   sei
-   adc     $3456,y
-   .byte   $7a         ; nop
-   rra     $3456,y
-   .byte   $7c,$56,$34 ; nop     $3456,x
-   adc     $3456,x
-   ror     $3456,x
-   rra     $3456,x
-   nop     #$12
-   sta     ($12,x)
-   .byte   $82,$12     ; nop     #$12
-   sax     ($12,x)
-   sty     $12
-   sta     $12
-   stx     $12
-   sax     $12
-   dey
-   .byte   $89,$12     ; nop     #$12
-   txa
-   .byte   $8b,$12     ; xaa     #$12
-   sty     $3456
-   sta     $3456
-   stx     $3456
-   sax     $3456
-   bcc     *+122
-   sta     ($12),y
-   .byte   $92     ; jam
-   .byte   $93,$12 ; ahx     ($12),y
-   sty     $12,x
-   sta     $12,x
-   stx     $12,y
-   sax     $12,y
-   tya
-   sta     $3456,y
-   txs
-   tas     $3456,y
-   shy     $3456,x
-   sta     $3456,x
-   shx     $3456,y
-   .byte   $9f,$56,$34 ;  ahx     $3456,y
-   ldy     #$12
-   lda     ($12,x)
-   ldx     #$12
-   lax     ($12,x)
-   ldy     $12
-   lda     $12
-   ldx     $12
-   lax     $12
-   tay
-   lda     #$12
-   tax
-   lax     #$12
-   ldy     $3456
-   lda     $3456
-   ldx     $3456
-   lax     $3456
-   bcs     *+122
-   lda     ($12),y
-   .byte   $b2     ; jam
-   lax     ($12),y
-   ldy     $12,x
-   lda     $12,x
-   ldx     $12,y
-   lax     $12,y
-   clv
-   lda     $3456,y
-   tsx
-   las     $3456,y
-   ldy     $3456,x
-   lda     $3456,x
-   ldx     $3456,y
-   lax     $3456,y
-   cpy     #$12
-   cmp     ($12,x)
-   .byte   $c2,$12     ; nop     #$12
-   dcp     ($12,x)
-   cpy     $12
-   cmp     $12
-   dec     $12
-   dcp     $12
-   iny
-   cmp     #$12
-   dex
-   axs     #$12
-   cpy     $3456
-   cmp     $3456
-   dec     $3456
-   dcp     $3456
-   bne     *+122
-   cmp     ($12),y
-   .byte   $d2         ; jam
-   dcp     ($12),y
-   .byte   $d4,$12     ; nop     $12,x
-   cmp     $12,x
-   dec     $12,x
-   dcp     $12,x
-   cld
-   cmp     $3456,y
-   .byte   $da         ; nop
-   dcp     $3456,y
-   .byte   $dc,$56,$34 ; nop     $3456,x
-   cmp     $3456,x
-   dec     $3456,x
-   dcp     $3456,x
-   cpx     #$12
-   sbc     ($12,x)
-   .byte   $e2,$12     ; nop     #$12
-   isc     ($12,x)
-   cpx     $12
-   sbc     $12
-   inc     $12
-   isc     $12
-   inx
-   sbc     #$12
-   nop
-   .byte   $eb         ; nop
-   cpx     $3456
-   sbc     $3456
-   inc     $3456
-   isc     $3456
-   beq     *+122
-   sbc     ($12),y
-   .byte   $f2         ; jam
-   isc     ($12),y
-   .byte   $f4,$12     ; nop     $12,x
-   sbc     $12,x
-   inc     $12,x
-   isc     $12,x
-   sed
-   sbc     $3456,y
-   .byte   $fa         ; nop
-   isc     $3456,y
-   .byte   $fc,$56,$34 ; nop     $3456,x
-   sbc     $3456,x
-   inc     $3456,x
-   isc     $3456,x
diff --git a/test/assembler/65816-cpudetect.ref b/test/assembler/65816-cpudetect.ref
deleted file mode 100644 (file)
index 4f6e767..0000000
Binary files a/test/assembler/65816-cpudetect.ref and /dev/null differ
diff --git a/test/assembler/65c02-cpudetect.ref b/test/assembler/65c02-cpudetect.ref
deleted file mode 100644 (file)
index 9f790d5..0000000
Binary files a/test/assembler/65c02-cpudetect.ref and /dev/null differ
diff --git a/test/assembler/65c02-opcodes.ref b/test/assembler/65c02-opcodes.ref
deleted file mode 100644 (file)
index 2d44045..0000000
Binary files a/test/assembler/65c02-opcodes.ref and /dev/null differ
diff --git a/test/assembler/65c02-opcodes.s b/test/assembler/65c02-opcodes.s
deleted file mode 100644 (file)
index 09c3f04..0000000
+++ /dev/null
@@ -1,258 +0,0 @@
-.setcpu "65C02"
-
-   brk
-   ora     ($12,x)
-   .byte   $02
-   .byte   $03
-   tsb     $12
-   ora     $12
-   asl     $12
-   rmb0    $12
-   php
-   ora     #$12
-   asl     a
-   .byte   $0B
-   tsb     $3456
-   ora     $3456
-   asl     $3456
-   bbr0    $12,*+122
-   bpl     *+122
-   ora     ($12),y
-   ora     ($12)
-   .byte   $13
-   trb     $12
-   ora     $12,x
-   asl     $12,x
-   rmb1    $12
-   clc
-   ora     $3456,y
-   inc     a
-   .byte   $1B
-   trb     $3456
-   ora     $3456,x
-   asl     $3456,x
-   bbr1    $12,*+122
-   jsr     $3456
-   and     ($12,x)
-   .byte   $22
-   .byte   $23
-   bit     $12
-   and     $12
-   rol     $12
-   rmb2    $12
-   plp
-   and     #$12
-   rol     a
-   .byte   $2B
-   bit     $3456
-   and     $3456
-   rol     $3456
-   bbr2    $12,*+122
-   bmi     *+122
-   and     ($12),y
-   and     ($12)
-   .byte   $33
-   bit     $12,x
-   and     $12,x
-   rol     $12,x
-   rmb3    $12
-   sec
-   and     $3456,y
-   dec     a
-   .byte   $3B
-   bit     $3456,x
-   and     $3456,x
-   rol     $3456,x
-   bbr3    $12,*+122
-   rti
-   eor     ($12,x)
-   .byte   $42
-   .byte   $43
-   .byte   $44
-   eor     $12
-   lsr     $12
-   rmb4    $12
-   pha
-   eor     #$12
-   lsr     a
-   .byte   $4B
-   jmp     $3456
-   eor     $3456
-   lsr     $3456
-   bbr4    $12,*+122
-   bvc     *+122
-   eor     ($12),y
-   eor     ($12)
-   .byte   $53
-   .byte   $54
-   eor     $12,x
-   lsr     $12,x
-   rmb5    $12
-   cli
-   eor     $3456,y
-   phy
-   .byte   $5B
-   .byte   $5C
-   eor     $3456,x
-   lsr     $3456,x
-   bbr5    $12,*+122
-   rts
-   adc     ($12,x)
-   .byte   $62
-   .byte   $63
-   stz     $12
-   adc     $12
-   ror     $12
-   rmb6    $12
-   pla
-   adc     #$12
-   ror     a
-   .byte   $6B
-   jmp     ($3456)
-   adc     $3456
-   ror     $3456
-   bbr6    $12,*+122
-   bvs     *+122
-   adc     ($12),y
-   adc     ($12)
-   .byte   $73
-   stz     $12,x
-   adc     $12,x
-   ror     $12,x
-   rmb7    $12
-   sei
-   adc     $3456,y
-   ply
-   .byte   $7B
-   jmp     ($3456,x)
-   adc     $3456,x
-   ror     $3456,x
-   bbr7    $12,*+122
-   bra     *+122
-   sta     ($12,x)
-   .byte   $82
-   .byte   $83
-   sty     $12
-   sta     $12
-   stx     $12
-   smb0    $12
-   dey
-   bit     #$12
-   txa
-   .byte   $8B
-   sty     $3456
-   sta     $3456
-   stx     $3456
-   bbs0    $12,*+122
-   bcc     *+122
-   sta     ($12),y
-   sta     ($12)
-   .byte   $93
-   sty     $12,x
-   sta     $12,x
-   stx     $12,y
-   smb1    $12
-   tya
-   sta     $3456,y
-   txs
-   .byte   $9B
-   stz     $3456
-   sta     $3456,x
-   stz     $3456,x
-   bbs1    $12,*+122
-   ldy     #$12
-   lda     ($12,x)
-   ldx     #$12
-   .byte   $A3
-   ldy     $12
-   lda     $12
-   ldx     $12
-   smb2    $12
-   tay
-   lda     #$12
-   tax
-   .byte   $AB
-   ldy     $3456
-   lda     $3456
-   ldx     $3456
-   bbs2    $12,*+122
-   bcs     *+122
-   lda     ($12),y
-   lda     ($12)
-   .byte   $B3
-   ldy     $12,x
-   lda     $12,x
-   ldx     $12,y
-   smb3    $12
-   clv
-   lda     $3456,y
-   tsx
-   .byte   $BB
-   ldy     $3456,x
-   lda     $3456,x
-   ldx     $3456,y
-   bbs3    $12,*+122
-   cpy     #$12
-   cmp     ($12,x)
-   .byte   $C2
-   .byte   $C3
-   cpy     $12
-   cmp     $12
-   dec     $12
-   smb4    $12
-   iny
-   cmp     #$12
-   dex
-   .byte   $CB
-   cpy     $3456
-   cmp     $3456
-   dec     $3456
-   bbs4    $12,*+122
-   bne     *+122
-   cmp     ($12),y
-   cmp     ($12)
-   .byte   $D3
-   .byte   $D4
-   cmp     $12,x
-   dec     $12,x
-   smb5    $12
-   cld
-   cmp     $3456,y
-   phx
-   .byte   $DB
-   .byte   $DC
-   cmp     $3456,x
-   dec     $3456,x
-   bbs5    $12,*+122
-   cpx     #$12
-   sbc     ($12,x)
-   .byte   $E2
-   .byte   $E3
-   cpx     $12
-   sbc     $12
-   inc     $12
-   smb6    $12
-   inx
-   sbc     #$12
-   nop
-   .byte   $EB
-   cpx     $3456
-   sbc     $3456
-   inc     $3456
-   bbs6    $12,*+122
-   beq     *+122
-   sbc     ($12),y
-   sbc     ($12)
-   .byte   $F3
-   .byte   $F4
-   sbc     $12,x
-   inc     $12,x
-   smb7    $12
-   sed
-   sbc     $3456,y
-   plx
-   .byte   $FB
-   .byte   $FC
-   sbc     $3456,x
-   inc     $3456,x
-   bbs7    $12,*+122
diff --git a/test/assembler/65sc02-cpudetect.ref b/test/assembler/65sc02-cpudetect.ref
deleted file mode 100644 (file)
index 4e11bd7..0000000
Binary files a/test/assembler/65sc02-cpudetect.ref and /dev/null differ
diff --git a/test/assembler/65sc02-opcodes.ref b/test/assembler/65sc02-opcodes.ref
deleted file mode 100644 (file)
index d22fe66..0000000
Binary files a/test/assembler/65sc02-opcodes.ref and /dev/null differ
diff --git a/test/assembler/65sc02-opcodes.s b/test/assembler/65sc02-opcodes.s
deleted file mode 100644 (file)
index aa53991..0000000
+++ /dev/null
@@ -1,258 +0,0 @@
-.setcpu "65SC02"
-
-   brk
-   ora     ($12,x)
-   .byte   $02
-   .byte   $03
-   tsb     $12
-   ora     $12
-   asl     $12
-   .byte   $07
-   php
-   ora     #$12
-   asl     a
-   .byte   $0B
-   tsb     $3456
-   ora     $3456
-   asl     $3456
-   .byte   $0F
-   bpl     *+122
-   ora     ($12),y
-   ora     ($12)
-   .byte   $13
-   trb     $12
-   ora     $12,x
-   asl     $12,x
-   .byte   $17
-   clc
-   ora     $3456,y
-   inc     a
-   .byte   $1B
-   trb     $3456
-   ora     $3456,x
-   asl     $3456,x
-   .byte   $1F
-   jsr     $3456
-   and     ($12,x)
-   .byte   $22
-   .byte   $23
-   bit     $12
-   and     $12
-   rol     $12
-   .byte   $27
-   plp
-   and     #$12
-   rol     a
-   .byte   $2B
-   bit     $3456
-   and     $3456
-   rol     $3456
-   .byte   $2F
-   bmi     *+122
-   and     ($12),y
-   and     ($12)
-   .byte   $33
-   bit     $12,x
-   and     $12,x
-   rol     $12,x
-   .byte   $37
-   sec
-   and     $3456,y
-   dec     a
-   .byte   $3B
-   bit     $3456,x
-   and     $3456,x
-   rol     $3456,x
-   .byte   $3F
-   rti
-   eor     ($12,x)
-   .byte   $42
-   .byte   $43
-   .byte   $44
-   eor     $12
-   lsr     $12
-   .byte   $47
-   pha
-   eor     #$12
-   lsr     a
-   .byte   $4B
-   jmp     $3456
-   eor     $3456
-   lsr     $3456
-   .byte   $4F
-   bvc     *+122
-   eor     ($12),y
-   eor     ($12)
-   .byte   $53
-   .byte   $54
-   eor     $12,x
-   lsr     $12,x
-   .byte   $57
-   cli
-   eor     $3456,y
-   phy
-   .byte   $5B
-   .byte   $5C
-   eor     $3456,x
-   lsr     $3456,x
-   .byte   $5F
-   rts
-   adc     ($12,x)
-   .byte   $62
-   .byte   $63
-   stz     $12
-   adc     $12
-   ror     $12
-   .byte   $67
-   pla
-   adc     #$12
-   ror     a
-   .byte   $6B
-   jmp     ($3456)
-   adc     $3456
-   ror     $3456
-   .byte   $6F
-   bvs     *+122
-   adc     ($12),y
-   adc     ($12)
-   .byte   $73
-   stz     $12,x
-   adc     $12,x
-   ror     $12,x
-   .byte   $77
-   sei
-   adc     $3456,y
-   ply
-   .byte   $7B
-   jmp     ($3456,x)
-   adc     $3456,x
-   ror     $3456,x
-   .byte   $7F
-   bra     *+122
-   sta     ($12,x)
-   .byte   $82
-   .byte   $83
-   sty     $12
-   sta     $12
-   stx     $12
-   .byte   $87
-   dey
-   bit     #$12
-   txa
-   .byte   $8B
-   sty     $3456
-   sta     $3456
-   stx     $3456
-   .byte   $8F
-   bcc     *+122
-   sta     ($12),y
-   sta     ($12)
-   .byte   $93
-   sty     $12,x
-   sta     $12,x
-   stx     $12,y
-   .byte   $97
-   tya
-   sta     $3456,y
-   txs
-   .byte   $9B
-   stz     $3456
-   sta     $3456,x
-   stz     $3456,x
-   .byte   $9F
-   ldy     #$12
-   lda     ($12,x)
-   ldx     #$12
-   .byte   $A3
-   ldy     $12
-   lda     $12
-   ldx     $12
-   .byte   $A7
-   tay
-   lda     #$12
-   tax
-   .byte   $AB
-   ldy     $3456
-   lda     $3456
-   ldx     $3456
-   .byte   $AF
-   bcs     *+122
-   lda     ($12),y
-   lda     ($12)
-   .byte   $B3
-   ldy     $12,x
-   lda     $12,x
-   ldx     $12,y
-   .byte   $B7
-   clv
-   lda     $3456,y
-   tsx
-   .byte   $BB
-   ldy     $3456,x
-   lda     $3456,x
-   ldx     $3456,y
-   .byte   $BF
-   cpy     #$12
-   cmp     ($12,x)
-   .byte   $C2
-   .byte   $C3
-   cpy     $12
-   cmp     $12
-   dec     $12
-   .byte   $C7
-   iny
-   cmp     #$12
-   dex
-   .byte   $CB
-   cpy     $3456
-   cmp     $3456
-   dec     $3456
-   .byte   $CF
-   bne     *+122
-   cmp     ($12),y
-   cmp     ($12)
-   .byte   $D3
-   .byte   $D4
-   cmp     $12,x
-   dec     $12,x
-   .byte   $D7
-   cld
-   cmp     $3456,y
-   phx
-   .byte   $DB
-   .byte   $DC
-   cmp     $3456,x
-   dec     $3456,x
-   .byte   $DF
-   cpx     #$12
-   sbc     ($12,x)
-   .byte   $E2
-   .byte   $E3
-   cpx     $12
-   sbc     $12
-   inc     $12
-   .byte   $E7
-   inx
-   sbc     #$12
-   nop
-   .byte   $EB
-   cpx     $3456
-   sbc     $3456
-   inc     $3456
-   .byte   $EF
-   beq     *+122
-   sbc     ($12),y
-   sbc     ($12)
-   .byte   $F3
-   .byte   $F4
-   sbc     $12,x
-   inc     $12,x
-   .byte   $F7
-   sed
-   sbc     $3456,y
-   plx
-   .byte   $FB
-   .byte   $FC
-   sbc     $3456,x
-   inc     $3456,x
-   .byte   $FF
diff --git a/test/assembler/Makefile b/test/assembler/Makefile
deleted file mode 100644 (file)
index 5d38847..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-
-# makefile for the assembler regression tests
-
-BINDIR = ../../bin
-WORKDIR := ../../testwrk
-
-BASE_TARGETS  = 6502 6502x 65sc02 65c02
-BASE_TARGETS += 4510 huc6280
-
-OPCODE_TARGETS = $(BASE_TARGETS)
-CPUDETECT_TARGETS = $(BASE_TARGETS)
-
-CPUDETECT_TARGETS += 65816
-
-# default target defined later
-all:
-
-# generate opcode targets and expand target list
-define opcode
-OPCODE_TARGETLIST += $$(WORKDIR)/$(1)-opcodes.bin
-$$(WORKDIR)/$(1)-opcodes.bin: $(1)-opcodes.s
-       @$$(BINDIR)/cl65 --cpu $(1) -t none -l $$(WORKDIR)/$(1)-opcodes.lst --obj-path $$(WORKDIR) -o $$@ $$<
-       @diff -q $(1)-opcodes.ref $$@ || (cat $$(WORKDIR)/$(1)-opcodes.lst ; exit 1)
-       @echo ca65 --cpu $(1) opcodes ok
-       @rm -f $(1)-opcodes.o #workaround for #168
-endef
-$(foreach target,$(OPCODE_TARGETS),$(eval $(call opcode,$(target))))
-
-# generate cpudetect targets and expand target list
-define cpudetect
-CPUDETECT_TARGETLIST += $$(WORKDIR)/$(1)-cpudetect.bin
-$$(WORKDIR)/$(1)-cpudetect.bin: cpudetect.s
-       @$$(BINDIR)/cl65 --cpu $(1) -t none -l $$(WORKDIR)/$(1)-cpudetect.lst --obj-path $$(WORKDIR) -o $$@ $$<
-       @diff -q $(1)-cpudetect.ref $$@ || (cat $$(WORKDIR)/$(1)-cpudetect.lst ; exit 1)
-       @echo ca65 --cpu $(1) cpudetect ok
-       @rm -f cpudetect.o #workaround for #168
-endef
-$(foreach target,$(CPUDETECT_TARGETS),$(eval $(call cpudetect,$(target))))
-
-# now that all targets have been generated, get to the manual ones
-all: $(OPCODE_TARGETLIST) $(CPUDETECT_TARGETLIST)
-       @#
-
-.PHONY: all $(OPCODE_TARGETLIST) $(CPUDETECT_TARGETLIST)
-
diff --git a/test/assembler/README b/test/assembler/README
deleted file mode 100644 (file)
index a2b1e9a..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-
-Assembler Testcases
-===================
-
-Opcode Tests:
--------------
-
-These testcases are inspired by the ones now removed from test/assembler.
-The main purpose is to have each possible opcode generated at least once,
-either by an assembly instruction or a ".byte"-placeholder. Typically
-generated by disassembling a binary dump that contains data in the form
-of the pattern that each opcode is stated once in order followed by easy
-to recognise:
-
-00 00 EA 00
-01 00 EA 00
-02 00 EA 00
-[...]
-fe 00 EA 00
-ff 00 EA 00
-
-The disassembly is then put in a better readable form by replacing the
-leftover dummy opcode parameters with something more recognizable.
-
-The testcases for 6502, 6502x, 65sc02, 65c02, 4510, and huc6280 have been
-put together by Sven Oliver ("SvOlli") Moll, as well as a template for the
-m740 instructions set.
-
-Still to do is to find a way to implement an opcode testcase for the 65816
-processor, since it's capable of executing instructions with an 8-bit and
-a 16-bit operator alike, only distinguished by one processor flag.
-
-
-CPU detect Tests
-----------------
-
-These tests all assemble the same file "cpudetect.s" which contains several
-conditionals for several CPUs, only using every option known to the "--cpu"
-commandline switch of ca65/cl65.
-
-
-Reference (".ref") Files
-------------------------
-
-A hint on creating these files: when running the test, it will fail due to
-the missing ".ref" file. Review the output of the ".lst" very pedantic, then
-copy the ".bin" to the ".ref" file.
-
diff --git a/test/assembler/cpudetect.s b/test/assembler/cpudetect.s
deleted file mode 100644 (file)
index adad7c1..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-
-.macpack cpu
-
-; step 1: try to assemble an instruction that's exclusive to this set
-;         (when possible)
-
-.ifp02
-   lda #$ea
-.endif
-
-.ifpsc02
-   jmp ($1234,x)
-.endif
-
-.ifpc02
-   rmb0 $12
-.endif
-
-.ifp816
-   xba
-.endif
-
-.ifp4510
-   taz
-.endif
-
-
-; step 2: check for bitwise compatibility of instructions sets
-;         (made verbose for better reading with hexdump/hd(1))
-
-.if (.cpu .bitand CPU_ISET_NONE)
-   .byte 0,"CPU_ISET_NONE"
-.endif
-
-.if (.cpu .bitand CPU_ISET_6502)
-   .byte 0,"CPU_ISET_6502"
-.endif
-
-.if (.cpu .bitand CPU_ISET_6502X)
-   .byte 0,"CPU_ISET_6502X"
-.endif
-
-.if (.cpu .bitand CPU_ISET_65SC02)
-   .byte 0,"CPU_ISET_65SC02"
-.endif
-
-.if (.cpu .bitand CPU_ISET_65C02)
-   .byte 0,"CPU_ISET_65C02"
-.endif
-
-.if (.cpu .bitand CPU_ISET_65816)
-   .byte 0,"CPU_ISET_65816"
-.endif
-
-.if (.cpu .bitand CPU_ISET_SWEET16)
-   .byte 0,"CPU_ISET_SWEET16"
-.endif
-
-.if (.cpu .bitand CPU_ISET_HUC6280)
-   .byte 0,"CPU_ISET_HUC6280"
-.endif
-
-.if (.cpu .bitand CPU_ISET_4510)
-   .byte 0,"CPU_ISET_4510"
-.endif
-
diff --git a/test/assembler/huc6280-cpudetect.ref b/test/assembler/huc6280-cpudetect.ref
deleted file mode 100644 (file)
index 646e0f4..0000000
Binary files a/test/assembler/huc6280-cpudetect.ref and /dev/null differ
diff --git a/test/assembler/huc6280-opcodes.ref b/test/assembler/huc6280-opcodes.ref
deleted file mode 100644 (file)
index 33f5b29..0000000
Binary files a/test/assembler/huc6280-opcodes.ref and /dev/null differ
diff --git a/test/assembler/huc6280-opcodes.s b/test/assembler/huc6280-opcodes.s
deleted file mode 100644 (file)
index bd3ad5c..0000000
+++ /dev/null
@@ -1,258 +0,0 @@
-.setcpu "huc6280"
-
-   brk
-   ora     ($12,x)
-   sxy
-   st0     #$12
-   tsb     $12
-   ora     $12
-   asl     $12
-   rmb0    $12
-   php
-   ora     #$12
-   asl     a
-   .byte   $0B
-   tsb     $3456
-   ora     $3456
-   asl     $3456
-   bbr0    $12,*+122
-   bpl     *+122
-   ora     ($12),y
-   ora     ($12)
-   st1     #$12
-   trb     $12
-   ora     $12,x
-   asl     $12,x
-   rmb1    $12
-   clc
-   ora     $3456,y
-   inc     a
-   .byte   $1B
-   trb     $3456
-   ora     $3456,x
-   asl     $3456,x
-   bbr1    $12,*+122
-   jsr     $3456
-   and     ($12,x)
-   sax
-   st2     #$12
-   bit     $12
-   and     $12
-   rol     $12
-   rmb2    $12
-   plp
-   and     #$12
-   rol     a
-   .byte   $2B
-   bit     $3456
-   and     $3456
-   rol     $3456
-   bbr2    $12,*+122
-   bmi     *+122
-   and     ($12),y
-   and     ($12)
-   .byte   $33
-   bit     $12,x
-   and     $12,x
-   rol     $12,x
-   rmb3    $12
-   sec
-   and     $3456,y
-   dec     a
-   .byte   $3B
-   bit     $3456,x
-   and     $3456,x
-   rol     $3456,x
-   bbr3    $12,*+122
-   rti
-   eor     ($12,x)
-   say
-   tma     #$02
-   bsr     *+122
-   eor     $12
-   lsr     $12
-   rmb4    $12
-   pha
-   eor     #$12
-   lsr     a
-   .byte   $4B
-   jmp     $3456
-   eor     $3456
-   lsr     $3456
-   bbr4    $12,*+122
-   bvc     *+122
-   eor     ($12),y
-   eor     ($12)
-   tam     #$12
-   csl
-   eor     $12,x
-   lsr     $12,x
-   rmb5    $12
-   cli
-   eor     $3456,y
-   phy
-   .byte   $5B
-   .byte   $5C
-   eor     $3456,x
-   lsr     $3456,x
-   bbr5    $12,*+122
-   rts
-   adc     ($12,x)
-   cla
-   .byte   $63
-   stz     $12
-   adc     $12
-   ror     $12
-   rmb6    $12
-   pla
-   adc     #$12
-   ror     a
-   .byte   $6B
-   jmp     ($3456)
-   adc     $3456
-   ror     $3456
-   bbr6    $12,*+122
-   bvs     *+122
-   adc     ($12),y
-   adc     ($12)
-   tii     $3333,$7373,$1111
-   stz     $12,x
-   adc     $12,x
-   ror     $12,x
-   rmb7    $12
-   sei
-   adc     $3456,y
-   ply
-   .byte   $7B
-   jmp     ($3456,x)
-   adc     $3456,x
-   ror     $3456,x
-   bbr7    $12,*+122
-   bra     *+122
-   sta     ($12,x)
-   clx
-   tst     #$12,$EA
-   sty     $12
-   sta     $12
-   stx     $12
-   smb0    $12
-   dey
-   bit     #$12
-   txa
-   .byte   $8B
-   sty     $3456
-   sta     $3456
-   stx     $3456
-   bbs0    $12,*+122
-   bcc     *+122
-   sta     ($12),y
-   sta     ($12)
-   tst     #$12,$EAEA
-   sty     $12,x
-   sta     $12,x
-   stx     $12,y
-   smb1    $12
-   tya
-   sta     $3456,y
-   txs
-   .byte   $9B
-   stz     $3456
-   sta     $3456,x
-   stz     $3456,x
-   bbs1    $12,*+122
-   ldy     #$12
-   lda     ($12,x)
-   ldx     #$12
-   tst     #$12,$EA,x
-   ldy     $12
-   lda     $12
-   ldx     $12
-   smb2    $12
-   tay
-   lda     #$12
-   tax
-   .byte   $AB
-   ldy     $3456
-   lda     $3456
-   ldx     $3456
-   bbs2    $12,*+122
-   bcs     *+122
-   lda     ($12),y
-   lda     ($12)
-   tst     #$12,$EAEA,x
-   ldy     $12,x
-   lda     $12,x
-   ldx     $12,y
-   smb3    $12
-   clv
-   lda     $3456,y
-   tsx
-   .byte   $BB
-   ldy     $3456,x
-   lda     $3456,x
-   ldx     $3456,y
-   bbs3    $12,*+122
-   cpy     #$12
-   cmp     ($12,x)
-   cly
-   tdd     $3333,$C3C3,$1111
-   cpy     $12
-   cmp     $12
-   dec     $12
-   smb4    $12
-   iny
-   cmp     #$12
-   dex
-   .byte   $CB
-   cpy     $3456
-   cmp     $3456
-   dec     $3456
-   bbs4    $12,*+122
-   bne     *+122
-   cmp     ($12),y
-   cmp     ($12)
-   tin     $3333,$D3D3,$1111
-   .byte   $D4
-   cmp     $12,x
-   dec     $12,x
-   smb5    $12
-   cld
-   cmp     $3456,y
-   phx
-   .byte   $DB
-   .byte   $DC
-   cmp     $3456,x
-   dec     $3456,x
-   bbs5    $12,*+122
-   cpx     #$12
-   sbc     ($12,x)
-   .byte   $E2
-   tia     $3333,$E3E3,$1111
-   cpx     $12
-   sbc     $12
-   inc     $12
-   smb6    $12
-   inx
-   sbc     #$12
-   nop
-   .byte   $EB
-   cpx     $3456
-   sbc     $3456
-   inc     $3456
-   bbs6    $12,*+122
-   beq     *+122
-   sbc     ($12),y
-   sbc     ($12)
-   tai     $3333,$F3F3,$1111
-   .byte   $F4
-   sbc     $12,x
-   inc     $12,x
-   smb7    $12
-   sed
-   sbc     $3456,y
-   plx
-   .byte   $FB
-   .byte   $FC
-   sbc     $3456,x
-   inc     $3456,x
-   bbs7    $12,*+122
diff --git a/test/assembler/m740-opcodes.s b/test/assembler/m740-opcodes.s
deleted file mode 100644 (file)
index df6d714..0000000
+++ /dev/null
@@ -1,260 +0,0 @@
-.setcpu "65C02"
-; copy of 65c02, comments note changes to the m740 according to
-; http://documentation.renesas.com/doc/products/mpumcu/rej09b0322_740sm.pdf
-
-   brk
-   ora     ($12,x)
-   .byte   $02,$00,$00 ; jsr zp,ind
-   .byte   $03,$00,$00 ; bbs 0,a
-   tsb     $12         ; .byte $04
-   ora     $12
-   asl     $12
-   rmb0    $12         ; bbs 0,zp
-   php
-   ora     #$12
-   asl     a
-   .byte   $0B,$00,$00 ; seb 0,a
-   tsb     $3456       ; .byte $0c
-   ora     $3456
-   asl     $3456
-   bbr0    $12,*+122   ; seb 0,zp
-   bpl     *+122
-   ora     ($12),y
-   ora     ($12)       ; clt
-   .byte   $13,$00,$00 ; bbc 0,a
-   trb     $12         ; .byte $14
-   ora     $12,x
-   asl     $12,x
-   rmb1    $12         ; bbc 0,zp
-   clc
-   ora     $3456,y
-   inc     a
-   .byte   $1B,$00,$00 ; clb 0,a
-   trb     $3456       ; .byte $1c
-   ora     $3456,x
-   asl     $3456,x
-   bbr1    $12,*+122   ; clb 0,zp
-   jsr     $3456
-   and     ($12,x)
-   .byte   $22,$00,$00 ; jsr sp
-   .byte   $23,$00,$00 ; bbs 1,a
-   bit     $12
-   and     $12
-   rol     $12
-   rmb2    $12         ; bbs 1,zp
-   plp
-   and     #$12
-   rol     a
-   .byte   $2B,$00,$00 ; seb 1,a
-   bit     $3456
-   and     $3456
-   rol     $3456
-   bbr2    $12,*+122   ; seb 1,zp
-   bmi     *+122
-   and     ($12),y
-   and     ($12)       ; set
-   .byte   $33,$00,$00 ; bbc 1,a
-   bit     $12,x       ; .byte $34
-   and     $12,x
-   rol     $12,x
-   rmb3    $12         ; bbc 1,zp
-   sec
-   and     $3456,y
-   dec     a
-   .byte   $3B,$00,$00 ; clb 1,a
-   bit     $3456,x     ; ldm zp
-   and     $3456,x
-   rol     $3456,x
-   bbr3    $12,*+122   ; clb 1,zp
-   rti
-   eor     ($12,x)
-   .byte   $42,$00,$00 ; stp
-   .byte   $43,$00,$00 ; bbs 2,a
-   .byte   $44,$00,$00 ; com zp
-   eor     $12
-   lsr     $12
-   rmb4    $12         ; bbs 2,zp
-   pha
-   eor     #$12
-   lsr     a
-   .byte   $4B,$00,$00 ; seb 2,a
-   jmp     $3456
-   eor     $3456
-   lsr     $3456
-   bbr4    $12,*+122   ; seb 2,zp
-   bvc     *+122
-   eor     ($12),y
-   eor     ($12)       ; .byte $52
-   .byte   $53,$00,$00 ; bbc 2,a
-   .byte   $54,$00,$00
-   eor     $12,x
-   lsr     $12,x
-   rmb5    $12         ; bbc 2,zp
-   cli
-   eor     $3456,y
-   phy
-   .byte   $5B,$00,$00 ; clb 2,a
-   .byte   $5C,$00,$00
-   eor     $3456,x
-   lsr     $3456,x
-   bbr5    $12,*+122   ; clb 2,zp
-   rts
-   adc     ($12,x)
-   .byte   $62,$00,$00 ; mul zp,x
-   .byte   $63,$00,$00 ; bbs 3,a
-   stz     $12         ; tst zp
-   adc     $12
-   ror     $12
-   rmb6    $12         ; bbs 3,zp
-   pla
-   adc     #$12
-   ror     a
-   .byte   $6B,$00,$00 ; seb 3,a
-   jmp     ($3456)
-   adc     $3456
-   ror     $3456
-   bbr6    $12,*+122   ; seb 3,zp
-   bvs     *+122
-   adc     ($12),y
-   adc     ($12)       ; .byte $72
-   .byte   $73,$00,$00 ; bbc 3,a
-   stz     $12,x       ; .byte $74
-   adc     $12,x
-   ror     $12,x
-   rmb7    $12         ; bbc 3,zp
-   sei
-   adc     $3456,y
-   ply
-   .byte   $7B,$00,$00 ; clb 3,a
-   jmp     ($3456,x)   ; .byte $7c
-   adc     $3456,x
-   ror     $3456,x
-   bbr7    $12,*+122   ; clb 3,zp
-   bra     *+122
-   sta     ($12,x)
-   .byte   $82,$00,$00 ; rrf zp
-   .byte   $83,$00,$00 ; bbs 4,a
-   sty     $12
-   sta     $12
-   stx     $12
-   smb0    $12         ; bbs 4,zp
-   dey
-   bit     #$12
-   txa
-   .byte   $8B,$00,$00 ; seb 4,a
-   sty     $3456
-   sta     $3456
-   stx     $3456
-   bbs0    $12,*+122   ; seb 4,zp
-   bcc     *+122
-   sta     ($12),y
-   sta     ($12)       ; .byte $92
-   .byte   $93,$00,$00 ; bbc 4,a
-   sty     $12,x
-   sta     $12,x
-   stx     $12,y
-   smb1    $12         ; bbc 4,zp
-   tya
-   sta     $3456,y
-   txs
-   .byte   $9B,$00,$00 ; clb 4,a
-   stz     $3456       ; .byte $9c
-   sta     $3456,x
-   stz     $3456,x     ; .byte $9e
-   bbs1    $12,*+122   ; clb 4,zp
-   ldy     #$12
-   lda     ($12,x)
-   ldx     #$12
-   .byte   $A3,$00,$00 ; bbs 5,a
-   ldy     $12
-   lda     $12
-   ldx     $12
-   smb2    $12         ; bbs 5,zp
-   tay
-   lda     #$12
-   tax
-   .byte   $AB,$00,$00 ; seb 5,a
-   ldy     $3456
-   lda     $3456
-   ldx     $3456
-   bbs2    $12,*+122   ; seb 5,zp
-   bcs     *+122
-   lda     ($12),y
-   lda     ($12)       ; .byte $b2
-   .byte   $B3,$00,$00 ; bbc 5,a
-   ldy     $12,x
-   lda     $12,x
-   ldx     $12,y
-   smb3    $12         ; bbc 5,zp
-   clv
-   lda     $3456,y
-   tsx
-   .byte   $BB,$00,$00 ; clb 5,a
-   ldy     $3456,x
-   lda     $3456,x
-   ldx     $3456,y
-   bbs3    $12,*+122   ; clb 5,zp
-   cpy     #$12
-   cmp     ($12,x)
-   .byte   $C2,$00,$00 ; wit
-   .byte   $C3,$00,$00 ; bbs 6,a
-   cpy     $12
-   cmp     $12
-   dec     $12
-   smb4    $12         ; bbs 6,zp
-   iny
-   cmp     #$12
-   dex
-   .byte   $CB,$00,$00 ; seb 6,a
-   cpy     $3456
-   cmp     $3456
-   dec     $3456
-   bbs4    $12,*+122   ; seb 6,zp
-   bne     *+122
-   cmp     ($12),y
-   cmp     ($12)       ; .byte $d2
-   .byte   $D3,$00,$00 ; bbc 6,a
-   .byte   $D4,$00,$00
-   cmp     $12,x
-   dec     $12,x
-   smb5    $12         ; bbc 6,zp
-   cld
-   cmp     $3456,y
-   phx
-   .byte   $DB,$00,$00 ; clb 6,a
-   .byte   $DC,$00,$00
-   cmp     $3456,x
-   dec     $3456,x
-   bbs5    $12,*+122   ; clb 6,zp
-   cpx     #$12
-   sbc     ($12,x)
-   .byte   $E2,$00,$00 ; div zp,x
-   .byte   $E3,$00,$00 ; bbs 7,a
-   cpx     $12
-   sbc     $12
-   inc     $12
-   smb6    $12         ; bbs 7,zp
-   inx
-   sbc     #$12
-   nop
-   .byte   $EB,$00,$00 ; seb 7,a
-   cpx     $3456
-   sbc     $3456
-   inc     $3456
-   bbs6    $12,*+122   ; seb 7,zp
-   beq     *+122
-   sbc     ($12),y
-   sbc     ($12)       ; .byte $f2
-   .byte   $F3,$00,$00 ; bbc 7,a
-   .byte   $F4,$00,$00
-   sbc     $12,x
-   inc     $12,x
-   smb7    $12         ; bbc 7,zp
-   sed
-   sbc     $3456,y
-   plx
-   .byte   $FB,$00,$00 ; clb 7,a
-   .byte   $FC,$00,$00
-   sbc     $3456,x
-   inc     $3456,x
-   bbs7    $12,*+122   ; clb 7,zp
diff --git a/test/dasm/4510-disass.s b/test/dasm/4510-disass.s
new file mode 100644 (file)
index 0000000..96ed641
--- /dev/null
@@ -0,0 +1,298 @@
+.setcpu "4510"
+
+ZP = $12
+ABS = $2345
+
+start:
+   brk
+   ora (ZP,x)
+   cle
+   see
+   tsb ZP
+   ora ZP
+   asl ZP
+   rmb0 ZP
+   php
+   ora #$01
+   asl
+   tsy
+   tsb ABS
+   ora ABS
+   asl ABS
+   bbr0 ZP,label1
+
+label1:
+   bpl label2
+   ora (ZP),y
+   ora (ZP),z
+   lbpl start ; bpl start
+   trb ZP
+   ora ZP,x
+   asl ZP,x
+   rmb1 ZP
+   clc
+   ora ABS,y
+   inc
+   inz
+   trb ABS
+   ora ABS,x
+   asl ABS,x
+   bbr1 ZP,label2
+
+label2:
+   jsr ABS
+   and (ZP,x)
+   jsr ($2345)
+   jsr ($2456,x)
+   bit ZP
+   and ZP
+   rol ZP
+   rmb2 ZP
+   plp
+   and #$01
+   rol
+   tys
+   bit ABS
+   and ABS
+   rol ABS
+   bbr2 ZP,label3
+
+label3:
+   bmi label4
+   and (ZP),y
+   and (ZP),z
+   lbmi start ; bmi start
+   bit ZP,x
+   and ZP,x
+   rol ZP,x
+   rmb3 ZP
+   sec
+   and ABS,y
+   dec
+   dez
+   bit ABS,x
+   and ABS,x
+   rol ABS,x
+   bbr3 ZP,label4
+
+label4:
+   rti
+   eor (ZP,x)
+   neg
+   asr
+   asr ZP
+   eor ZP
+   lsr ZP
+   rmb4 ZP
+   pha
+   eor #$01
+   lsr
+   taz
+   jmp ABS
+   eor ABS
+   lsr ABS
+   bbr4 ZP,label5
+
+label5:
+   bvc label6
+   eor (ZP),y
+   eor (ZP),z
+   lbvc start ; bvc start
+   asr ZP,x
+   eor ZP,x
+   lsr ZP,x
+   rmb5 ZP
+   cli
+   eor ABS,y
+   phy
+   tab
+   map
+   eor ABS,x
+   lsr ABS,x
+   bbr5 ZP,label6
+
+label6:
+   rts
+   adc (ZP,x)
+   rtn #$09
+   bsr start
+   stz ZP
+   adc ZP
+   ror ZP
+   rmb6 ZP
+   pla
+   adc #$01
+   ror
+   tza
+   jmp ($2345)
+   adc ABS
+   ror ABS
+   bbr6 ZP,label7
+
+label7:
+   bvs label8
+   adc (ZP),y
+   adc (ZP),z
+   lbvs start ; bvs start
+   stz ZP,x
+   adc ZP,x
+   ror ZP,x
+   rmb7 ZP
+   sei
+   adc ABS,y
+   ply
+   tba
+   jmp ($2456,x)
+   adc ABS,x
+   ror ABS,x
+   bbr7 ZP,label8
+
+label8:
+   bra label9
+   sta (ZP,x)
+   sta ($0f,sp),y
+   lbra start ; bra start
+   sty ZP
+   sta ZP
+   stx ZP
+   smb0 ZP
+   dey
+   bit #$01
+   txa
+   sty ABS,x
+   sty ABS
+   sta ABS
+   stx ABS
+   bbs0 ZP,label9
+
+label9:
+   bcc labelA
+   sta (ZP),y
+   sta (ZP),z
+   lbcc start ; bcc start
+   sty ZP,x
+   sta ZP,x
+   stx ZP,y
+   smb1 ZP
+   tya
+   sta ABS,y
+   txs
+   stx ABS,y
+   stz ABS
+   sta ABS,x
+   stz ABS,x
+   bbs1 ZP,labelA
+
+labelA:
+   ldy #$01
+   lda (ZP,x)
+   ldx #$01
+   ldz #$01
+   ldy ZP
+   lda ZP
+   ldx ZP
+   smb2 ZP
+   tay
+   lda #$01
+   tax
+   ldz ABS
+   ldy ABS
+   lda ABS
+   ldx ABS
+   bbs2 ZP,labelB
+
+labelB:
+   bcs labelC
+   lda (ZP),y
+   lda (ZP),z
+   lbcs start ; bcs start
+   ldy ZP,x
+   lda ZP,x
+   ldx ZP,y
+   smb3 ZP
+   clv
+   lda ABS,y
+   tsx
+   ldz ABS,x
+   ldy ABS,x
+   lda ABS,x
+   ldx ABS,y
+   bbs3 ZP,labelC
+
+labelC:
+   cpy #$01
+   cmp (ZP,x)
+   cpz #$01
+   dew ZP
+   cpy ZP
+   cmp ZP
+   dec ZP
+   smb4 ZP
+   iny
+   cmp #$01
+   dex
+   asw ABS
+   cpy ABS
+   cmp ABS
+   dec ABS
+   bbs4 ZP,labelD
+
+labelD:
+   bne labelE
+   cmp (ZP),y
+   cmp (ZP),z
+   lbne start ; bne start
+   cpz ZP
+   cmp ZP,x
+   dec ZP,x
+   smb5 ZP
+   cld
+   cmp ABS,y
+   phx
+   phz
+   cpz ABS
+   cmp ABS,x
+   dec ABS,x
+   bbs5 ZP,labelE
+
+labelE:
+   cpx #$01
+   sbc (ZP,x)
+   lda ($0f,sp),y
+   inw ZP
+   cpx ZP
+   sbc ZP
+   inc ZP
+   smb6 ZP
+   inx
+   sbc #$01
+   eom
+   nop
+   row ABS
+   cpx ABS
+   sbc ABS
+   inc ABS
+   bbs6 ZP,labelF
+
+labelF:
+   beq labelG
+   sbc (ZP),y
+   sbc (ZP),z
+   lbeq start ; beq start
+   phw #$089a
+   sbc ZP,x
+   inc ZP,x
+   smb7 ZP
+   sed
+   sbc ABS,y
+   plx
+   plz
+   phd ABS
+   phw ABS
+   sbc ABS,x
+   inc ABS,x
+   bbs7 ZP,labelG
+
+labelG:
+   brk
+
diff --git a/test/dasm/Makefile b/test/dasm/Makefile
new file mode 100644 (file)
index 0000000..d707114
--- /dev/null
@@ -0,0 +1,69 @@
+# Makefile for the disassembler regression tests
+
+ifneq ($(shell echo),)
+  CMD_EXE = 1
+endif
+
+ifdef CMD_EXE
+  EXE = .exe
+  MKDIR = mkdir $(subst /,\,$1)
+  RMDIR = -rmdir /s /q $(subst /,\,$1)
+  DEL = del /f $(subst /,\,$1)
+else
+  EXE =
+  MKDIR = mkdir -p $1
+  RMDIR = $(RM) -r $1
+  DEL = $(RM) $1
+endif
+
+ifdef QUIET
+  .SILENT:
+endif
+
+CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
+DA65 := $(if $(wildcard ../../bin/da65*),../../bin/da65,da65)
+
+WORKDIR = ../../testwrk/dasm
+
+DIFF = $(WORKDIR)/bdiff$(EXE)
+
+CC = gcc
+CFLAGS = -O2
+
+START = --start-addr 0x8000
+
+.PHONY: all clean
+
+SOURCES := $(wildcard *.s)
+CPUS = $(foreach src,$(SOURCES),$(src:%-disass.s=%))
+BINS = $(foreach cpu,$(CPUS),$(WORKDIR)/$(cpu)-reass.bin)
+
+# default target defined later
+all: $(BINS)
+
+$(WORKDIR):
+       $(call MKDIR,$(WORKDIR))
+
+$(DIFF): ../bdiff.c | $(WORKDIR)
+       $(CC) $(CFLAGS) -o $@ $<
+
+define DISASS_template
+
+$(WORKDIR)/$1-disass.bin: $1-disass.s | $(WORKDIR)
+       $(CL65) --cpu $1 -t none $(START) -o $$@ $$<
+
+$(WORKDIR)/$1-reass.s: $(WORKDIR)/$1-disass.bin
+       $(DA65) --cpu $1 $(START) -o $$@ $$<
+
+$(WORKDIR)/$1-reass.bin: $(WORKDIR)/$1-reass.s $(DIFF)
+       $(if $(QUIET),echo dasm/$1-reass.bin)
+       $(CL65) --cpu $1 -t none $(START) -o $$@ $$<
+       $(DIFF) $$@ $(WORKDIR)/$1-disass.bin
+
+endef # DISASS_template
+
+$(foreach cpu,$(CPUS),$(eval $(call DISASS_template,$(cpu))))
+
+clean:
+       @$(call RMDIR,$(WORKDIR))
+       @$(call DEL,$(SOURCES:.s=.o))
diff --git a/test/disassembler/4510-disass.s b/test/disassembler/4510-disass.s
deleted file mode 100644 (file)
index 96ed641..0000000
+++ /dev/null
@@ -1,298 +0,0 @@
-.setcpu "4510"
-
-ZP = $12
-ABS = $2345
-
-start:
-   brk
-   ora (ZP,x)
-   cle
-   see
-   tsb ZP
-   ora ZP
-   asl ZP
-   rmb0 ZP
-   php
-   ora #$01
-   asl
-   tsy
-   tsb ABS
-   ora ABS
-   asl ABS
-   bbr0 ZP,label1
-
-label1:
-   bpl label2
-   ora (ZP),y
-   ora (ZP),z
-   lbpl start ; bpl start
-   trb ZP
-   ora ZP,x
-   asl ZP,x
-   rmb1 ZP
-   clc
-   ora ABS,y
-   inc
-   inz
-   trb ABS
-   ora ABS,x
-   asl ABS,x
-   bbr1 ZP,label2
-
-label2:
-   jsr ABS
-   and (ZP,x)
-   jsr ($2345)
-   jsr ($2456,x)
-   bit ZP
-   and ZP
-   rol ZP
-   rmb2 ZP
-   plp
-   and #$01
-   rol
-   tys
-   bit ABS
-   and ABS
-   rol ABS
-   bbr2 ZP,label3
-
-label3:
-   bmi label4
-   and (ZP),y
-   and (ZP),z
-   lbmi start ; bmi start
-   bit ZP,x
-   and ZP,x
-   rol ZP,x
-   rmb3 ZP
-   sec
-   and ABS,y
-   dec
-   dez
-   bit ABS,x
-   and ABS,x
-   rol ABS,x
-   bbr3 ZP,label4
-
-label4:
-   rti
-   eor (ZP,x)
-   neg
-   asr
-   asr ZP
-   eor ZP
-   lsr ZP
-   rmb4 ZP
-   pha
-   eor #$01
-   lsr
-   taz
-   jmp ABS
-   eor ABS
-   lsr ABS
-   bbr4 ZP,label5
-
-label5:
-   bvc label6
-   eor (ZP),y
-   eor (ZP),z
-   lbvc start ; bvc start
-   asr ZP,x
-   eor ZP,x
-   lsr ZP,x
-   rmb5 ZP
-   cli
-   eor ABS,y
-   phy
-   tab
-   map
-   eor ABS,x
-   lsr ABS,x
-   bbr5 ZP,label6
-
-label6:
-   rts
-   adc (ZP,x)
-   rtn #$09
-   bsr start
-   stz ZP
-   adc ZP
-   ror ZP
-   rmb6 ZP
-   pla
-   adc #$01
-   ror
-   tza
-   jmp ($2345)
-   adc ABS
-   ror ABS
-   bbr6 ZP,label7
-
-label7:
-   bvs label8
-   adc (ZP),y
-   adc (ZP),z
-   lbvs start ; bvs start
-   stz ZP,x
-   adc ZP,x
-   ror ZP,x
-   rmb7 ZP
-   sei
-   adc ABS,y
-   ply
-   tba
-   jmp ($2456,x)
-   adc ABS,x
-   ror ABS,x
-   bbr7 ZP,label8
-
-label8:
-   bra label9
-   sta (ZP,x)
-   sta ($0f,sp),y
-   lbra start ; bra start
-   sty ZP
-   sta ZP
-   stx ZP
-   smb0 ZP
-   dey
-   bit #$01
-   txa
-   sty ABS,x
-   sty ABS
-   sta ABS
-   stx ABS
-   bbs0 ZP,label9
-
-label9:
-   bcc labelA
-   sta (ZP),y
-   sta (ZP),z
-   lbcc start ; bcc start
-   sty ZP,x
-   sta ZP,x
-   stx ZP,y
-   smb1 ZP
-   tya
-   sta ABS,y
-   txs
-   stx ABS,y
-   stz ABS
-   sta ABS,x
-   stz ABS,x
-   bbs1 ZP,labelA
-
-labelA:
-   ldy #$01
-   lda (ZP,x)
-   ldx #$01
-   ldz #$01
-   ldy ZP
-   lda ZP
-   ldx ZP
-   smb2 ZP
-   tay
-   lda #$01
-   tax
-   ldz ABS
-   ldy ABS
-   lda ABS
-   ldx ABS
-   bbs2 ZP,labelB
-
-labelB:
-   bcs labelC
-   lda (ZP),y
-   lda (ZP),z
-   lbcs start ; bcs start
-   ldy ZP,x
-   lda ZP,x
-   ldx ZP,y
-   smb3 ZP
-   clv
-   lda ABS,y
-   tsx
-   ldz ABS,x
-   ldy ABS,x
-   lda ABS,x
-   ldx ABS,y
-   bbs3 ZP,labelC
-
-labelC:
-   cpy #$01
-   cmp (ZP,x)
-   cpz #$01
-   dew ZP
-   cpy ZP
-   cmp ZP
-   dec ZP
-   smb4 ZP
-   iny
-   cmp #$01
-   dex
-   asw ABS
-   cpy ABS
-   cmp ABS
-   dec ABS
-   bbs4 ZP,labelD
-
-labelD:
-   bne labelE
-   cmp (ZP),y
-   cmp (ZP),z
-   lbne start ; bne start
-   cpz ZP
-   cmp ZP,x
-   dec ZP,x
-   smb5 ZP
-   cld
-   cmp ABS,y
-   phx
-   phz
-   cpz ABS
-   cmp ABS,x
-   dec ABS,x
-   bbs5 ZP,labelE
-
-labelE:
-   cpx #$01
-   sbc (ZP,x)
-   lda ($0f,sp),y
-   inw ZP
-   cpx ZP
-   sbc ZP
-   inc ZP
-   smb6 ZP
-   inx
-   sbc #$01
-   eom
-   nop
-   row ABS
-   cpx ABS
-   sbc ABS
-   inc ABS
-   bbs6 ZP,labelF
-
-labelF:
-   beq labelG
-   sbc (ZP),y
-   sbc (ZP),z
-   lbeq start ; beq start
-   phw #$089a
-   sbc ZP,x
-   inc ZP,x
-   smb7 ZP
-   sed
-   sbc ABS,y
-   plx
-   plz
-   phd ABS
-   phw ABS
-   sbc ABS,x
-   inc ABS,x
-   bbs7 ZP,labelG
-
-labelG:
-   brk
-
diff --git a/test/disassembler/Makefile b/test/disassembler/Makefile
deleted file mode 100644 (file)
index 2621b0c..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-
-# makefile for the disassembler regression tests
-
-BINDIR = ../../bin
-WORKDIR := ../../testwrk
-
-#BASE_TARGETS  = 6502 6502x 65sc02 65c02
-#BASE_TARGETS += 4510 huc6280
-BASE_TARGETS  = 4510
-
-START = --start-addr 0x8000
-
-DISASS_TARGETS = $(BASE_TARGETS)
-
-# default target defined later
-all:
-
-# generate opcode targets and expand target list
-define disass
-DISASS_TARGETLIST += $$(WORKDIR)/$(1)-reass.bin $$(WORKDIR)/$(1)-reass.s $$(WORKDIR)/$(1)-disass.bin
-
-$$(WORKDIR)/$(1)-disass.bin: $(1)-disass.s
-       @$$(BINDIR)/cl65 --cpu $(1) -t none $(START) --obj-path $$(WORKDIR) -o $$@ $$<
-       @rm -f $(1)-disass.o #workaround for #168
-
-$$(WORKDIR)/$(1)-reass.s: $$(WORKDIR)/$(1)-disass.bin
-       @$$(BINDIR)/da65 --cpu $(1) $(START) -o $$@ $$<
-
-$$(WORKDIR)/$(1)-reass.bin: $$(WORKDIR)/$(1)-reass.s
-       @$$(BINDIR)/cl65 --cpu $(1) -t none $(START) --obj-path $$(WORKDIR) -o $$@ $$<
-       @rm -f $(1)-reass.o #workaround for #168
-       @cmp $$@ $$(WORKDIR)/$(1)-disass.bin
-       @echo da65 --cpu $(1) ok
-endef
-$(foreach target,$(DISASS_TARGETS),$(eval $(call disass,$(target))))
-
-# now that all targets have been generated, get to the manual ones
-all: $(DISASS_TARGETLIST)
-       @#
-
-.PHONY: all $(DISASS_TARGETLIST)
-
index bc4226acbf04a7564ea81612dedef92e20924b3b..4b05ca5db63f47fd838bdfcca25e57febd207910 100644 (file)
@@ -1,29 +1,42 @@
-# makefile for the tests that MUST NOT compile
+# Makefile for the tests that MUST NOT compile
 
 ifneq ($(shell echo),)
-  CMD_EXE := 1
+  CMD_EXE = 1
 endif
 
 ifdef CMD_EXE
-  NOT := - # Hack
-  DEL = -del /f $(subst /,\,$1)
+  S = $(subst /,\,/)
+  NOT = - # Hack
+  NULLDEV = nul:
+  MKDIR = mkdir $(subst /,\,$1)
+  RMDIR = -rmdir /s /q $(subst /,\,$1)
 else
-  NOT := !
-  DEL = $(RM) $1
+  S = /
+  NOT = !
+  NULLDEV = /dev/null
+  MKDIR = mkdir -p $1
+  RMDIR = $(RM) -r $1
 endif
 
-CC65 := $(if $(wildcard ../../bin/cc65*),../../bin/cc65,cc65)
+ifdef QUIET
+  .SILENT:
+  NULLERR = 2>$(NULLDEV)
+endif
+
+CC65 := $(if $(wildcard ../../bin/cc65*),..$S..$Sbin$Scc65,cc65)
 
-WORKDIR := ../../testwrk
+WORKDIR = ../../testwrk/err
 
 .PHONY: all clean
 
-TESTS := $(patsubst %.c,$(WORKDIR)/%.s,$(wildcard *.c))
+SOURCES := $(wildcard *.c)
+TESTS = $(patsubst %.c,$(WORKDIR)/%.s,$(SOURCES))
 
 all: $(TESTS)
 
 $(WORKDIR)/%.s: %.c
-       $(NOT) $(CC65) -o $@ $<
+       $(if $(QUIET),echo err/$*.s)
+       $(NOT) $(CC65) -o $@ $< $(NULLERR)
 
 clean:
-       @$(call DEL,$(TESTS))
+       @$(call RMDIR,$(WORKDIR))
diff --git a/test/err/duplicate-global-static.c b/test/err/duplicate-global-static.c
new file mode 100644 (file)
index 0000000..6aa27f5
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+  !!DESCRIPTION!! global duplicated with static variable
+  !!ORIGIN!!      cc65 regression tests
+  !!LICENCE!!     Public Domain
+  !!AUTHOR!!      Piotr Fusik
+*/
+
+/*
+  see: https://github.com/cc65/cc65/issues/191
+*/
+
+int n = 0;
+static int n = 0;           /* should give an error */
+
+int main(void)
+{
+    return n;
+}
diff --git a/test/err/duplicate-global.c b/test/err/duplicate-global.c
new file mode 100644 (file)
index 0000000..bd4fcc2
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+  !!DESCRIPTION!! duplicate globals
+  !!ORIGIN!!      cc65 regression tests
+  !!LICENCE!!     Public Domain
+  !!AUTHOR!!      Piotr Fusik
+*/
+
+/*
+  see: https://github.com/cc65/cc65/issues/191
+*/
+
+#pragma warn(error, on)
+
+int n = 0;
+int n = 0;           /* should give an error */
+
+int main(void)
+{
+    return n;
+}
diff --git a/test/err/duplicate-static-global.c b/test/err/duplicate-static-global.c
new file mode 100644 (file)
index 0000000..6e5e70a
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+  !!DESCRIPTION!! static duplicated with global variable
+  !!ORIGIN!!      cc65 regression tests
+  !!LICENCE!!     Public Domain
+  !!AUTHOR!!      Piotr Fusik
+*/
+
+/*
+  see: https://github.com/cc65/cc65/issues/191
+*/
+
+static int n = 0;
+int n = 0;           /* should give an error */
+
+int main(void)
+{
+    return n;
+}
diff --git a/test/err/duplicate-static.c b/test/err/duplicate-static.c
new file mode 100644 (file)
index 0000000..394cc1e
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+  !!DESCRIPTION!! duplicate static variables
+  !!ORIGIN!!      cc65 regression tests
+  !!LICENCE!!     Public Domain
+  !!AUTHOR!!      Piotr Fusik
+*/
+
+/*
+  see: https://github.com/cc65/cc65/issues/191
+*/
+
+#pragma warn(error, on)
+
+static int n = 0;
+static int n = 0;           /* should give an error */
+
+int main(void)
+{
+    return n;
+}
diff --git a/test/err/void-empty.c b/test/err/void-empty.c
new file mode 100644 (file)
index 0000000..9009182
--- /dev/null
@@ -0,0 +1,9 @@
+/*
+  !!DESCRIPTION!! Uninitialized void variables
+  !!ORIGIN!!      cc65 regression tests
+  !!LICENCE!!     Public Domain
+  !!AUTHOR!!      Greg King
+*/
+
+void test;
+const void list;
diff --git a/test/err/void-size2.c b/test/err/void-size2.c
new file mode 100644 (file)
index 0000000..3d4f133
--- /dev/null
@@ -0,0 +1,11 @@
+/*
+  !!DESCRIPTION!! Size of void cast
+  !!ORIGIN!!      cc65 regression tests
+  !!LICENCE!!     Public Domain
+  !!AUTHOR!!      Greg King
+*/
+
+unsigned test (void)
+{
+    return sizeof ((void)12345);
+}
index 918316c6c852daf1614f2a66be71bd7d7581dc66..39a9a38686326deada73c800a3754e6c55d905a2 100644 (file)
@@ -1,63 +1,96 @@
-
-# makefile for the remaining tests that need special care in one way or another
+# Makefile for the remaining tests that need special care in one way or another
 
 ifneq ($(shell echo),)
-  CMD_EXE := 1
+  CMD_EXE = 1
 endif
 
 ifdef CMD_EXE
-  S := $(subst /,\,/)
-  NOT := - # Hack
-  DEL = -del /f $(subst /,\,$1)
+  S = $(subst /,\,/)
+  NOT = - # Hack
+  EXE = .exe
+  NULLDEV = nul:
+  MKDIR = mkdir $(subst /,\,$1)
+  RMDIR = -rmdir /s /q $(subst /,\,$1)
+  DEL = del /f $(subst /,\,$1)
 else
-  S := /
-  NOT := !
+  S = /
+  NOT = !
+  EXE =
+  NULLDEV = /dev/null
+  MKDIR = mkdir -p $1
+  RMDIR = $(RM) -r $1
   DEL = $(RM) $1
 endif
 
-CC65FLAGS := -t sim6502
-SIM65FLAGS := -x 200000000
+ifdef QUIET
+  .SILENT:
+  NULLOUT = >$(NULLDEV)
+  NULLERR = 2>$(NULLDEV)
+endif
+
+SIM65FLAGS = -x 200000000
 
-CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
+CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65)
 SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65)
 
-WORKDIR := ..$S..$Stestwrk
-DIFF := $(WORKDIR)/bdiff
+WORKDIR = ..$S..$Stestwrk$Smisc
+
+OPTIONS = g O Os Osi Osir Oi Oir Or
+
+DIFF = $(WORKDIR)$Sbdiff$(EXE)
+
+CC = gcc
+CFLAGS = -O2
 
 .PHONY: all clean
 
 SOURCES := $(wildcard *.c)
-TESTS := $(foreach option,. .o. .os. .osi. .osir. .oi. .oir. .or.,$(SOURCES:%.c=$(WORKDIR)/%$(option)prg))
+TESTS  = $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).6502.prg))
+TESTS += $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).65c02.prg))
 
 all: $(TESTS)
 
+$(WORKDIR):
+       $(call MKDIR,$(WORKDIR))
+
+$(DIFF): ../bdiff.c | $(WORKDIR)
+       $(CC) $(CFLAGS) -o $@ $<
+
+define PRG_template
+
 # should compile, but then hangs in an endless loop
-$(WORKDIR)/endless%prg: endless.c
-       $(CL65) $(subst .,,$(*:.o%=-O%)) $(CC65FLAGS) $< -o $@
-       $(NOT) $(SIM65) $(SIM65FLAGS) $@
+$(WORKDIR)/endless.$1.$2.prg: endless.c | $(WORKDIR)
+       $(if $(QUIET),echo misc/endless.$1.$2.prg)
+       $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
+       $(NOT) $(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT) $(NULLERR)
 
 # these need reference data that can't be generated by a host-compiled program,
 # in a useful way
-$(WORKDIR)/limits%prg: limits.c
-       $(CL65) $(subst .,,$(*:.o%=-O%)) $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/limits.out
-       $(DIFF) $(WORKDIR)/limits.out limits.ref
+$(WORKDIR)/limits.$1.$2.prg: limits.c $(DIFF)
+       $(if $(QUIET),echo misc/limits.$1.$2.prg)
+       $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
+       $(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/limits.$1.out
+       $(DIFF) $(WORKDIR)/limits.$1.out limits.ref
 
 # the rest are tests that fail currently for one reason or another
-$(WORKDIR)/fields%prg: fields.c
-       @echo "FIXME: " $@ "currently will fail."
-       $(CL65) $(subst .,,$(*:.o%=-O%)) $(CC65FLAGS) $< -o $@
-       -$(SIM65) $(SIM65FLAGS) $@
-$(WORKDIR)/sitest%prg: sitest.c
-       @echo "FIXME: " $@ "currently will fail."
-       -$(CL65) $(subst .,,$(*:.o%=-O%)) $(CC65FLAGS) $< -o $@
-#      -$(SIM65) $(SIM65FLAGS) $@
-$(WORKDIR)/cc65141011%prg: cc65141011.c
-       @echo "FIXME: " $@ "currently can fail."
-       $(CL65) $(subst .,,$(*:.o%=-O%)) $(CC65FLAGS) $< -o $@
-       -$(SIM65) $(SIM65FLAGS) $@
+$(WORKDIR)/fields.$1.$2.prg: fields.c | $(WORKDIR)
+       @echo "FIXME: " $$@ "currently will fail."
+       $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
+       -$(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT)
+$(WORKDIR)/sitest.$1.$2.prg: sitest.c | $(WORKDIR)
+       @echo "FIXME: " $$@ "currently will fail."
+       -$(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
+#      -$(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT)
+$(WORKDIR)/cc65141011.$1.$2.prg: cc65141011.c | $(WORKDIR)
+       @echo "FIXME: " $$@ "currently can fail."
+       $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
+       -$(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT)
+
+endef # PRG_template
+
+$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),6502)))
+$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),65c02)))
 
 clean:
-       @$(call DEL,$(TESTS))
+       @$(call RMDIR,$(WORKDIR))
        @$(call DEL,$(SOURCES:.c=.o))
-       @$(call DEL,$(SOURCES:%.c=$(WORKDIR)/%.out))
index 09dd96d4425455f290c50a165751835c50d64576..c986513b85821c1d76e486ac74fd156eaa879f57 100644 (file)
@@ -1,96 +1,94 @@
-
-# makefile for the regression tests that generate output which has to be
+# Makefile for the regression tests that generate output which has to be
 # compared with reference output
 
 ifneq ($(shell echo),)
-  CMD_EXE := 1
+  CMD_EXE = 1
 endif
 
 ifdef CMD_EXE
-  S := $(subst /,\,/)
-  DEL = -del /f $(subst /,\,$1)
+  S = $(subst /,\,/)
+  EXE = .exe
+  NULLDEV = nul:
+  MKDIR = mkdir $(subst /,\,$1)
+  RMDIR = -rmdir /s /q $(subst /,\,$1)
+  DEL = del /f $(subst /,\,$1)
 else
-  S := /
+  S = /
+  EXE =
+  NULLDEV = /dev/null
+  MKDIR = mkdir -p $1
+  RMDIR = $(RM) -r $1
   DEL = $(RM) $1
 endif
 
-CC65FLAGS := -t sim6502
-SIM65FLAGS := -x 200000000
+ifdef QUIET
+  .SILENT:
+  NULLERR = 2>$(NULLDEV)
+endif
+
+SIM65FLAGS = -x 200000000
 
-CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
+CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65)
 SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65)
 
-WORKDIR := ..$S..$Stestwrk
-DIFF := $(WORKDIR)/bdiff
+WORKDIR = ..$S..$Stestwrk$Sref
+
+OPTIONS = g O Os Osi Osir Oi Oir Or
 
-CC := gcc
-CFLAGS := -O2 -Wall -W -Wextra -fwrapv -fno-strict-overflow
+DIFF = $(WORKDIR)$Sbdiff$(EXE)
+
+CC = gcc
+CFLAGS = -O2 -Wall -W -Wextra -funsigned-char -fwrapv -fno-strict-overflow
 
 .PHONY: all clean
 
 SOURCES := $(wildcard *.c)
-REFS := $(SOURCES:%.c=$(WORKDIR)/%.ref)
-TESTS := $(foreach option,. .o. .os. .osi. .osir. .oi. .oir. .or.,$(SOURCES:%.c=$(WORKDIR)/%$(option)prg))
+REFS = $(SOURCES:%.c=$(WORKDIR)/%.ref)
+TESTS  = $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).6502.prg))
+TESTS += $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).65c02.prg))
 
 all: $(REFS) $(TESTS)
 
-$(WORKDIR)/%.ref: %.c
-       $(CC) $(CFLAGS) $< -o $(WORKDIR)/$*.host
+$(WORKDIR):
+       $(call MKDIR,$(WORKDIR))
+
+$(WORKDIR)/%.ref: %.c | $(WORKDIR)
+       $(if $(QUIET),echo ref/$*.host)
+       $(CC) $(CFLAGS) -o $(WORKDIR)/$*.host $< $(NULLERR)
        $(WORKDIR)$S$*.host > $@
 
+$(DIFF): ../bdiff.c | $(WORKDIR)
+       $(CC) $(CFLAGS) -o $@ $<
+
 # Some files have "K & R"-style syntax.  Therefore, some forward
 # function-declarations don't match the later function definitions.
 # Those programs fail when fastcall is used; but, the cdecl calling convention
 # tolerates those conflicts.  Therefore, make their functions default to cdecl.
 #
-$(WORKDIR)/init%prg: CC65FLAGS += -Wc --all-cdecl
-$(WORKDIR)/switch.%rg: CC65FLAGS += -Wc --all-cdecl
-$(WORKDIR)/yacc.%rg: CC65FLAGS += -Wc --all-cdecl
-$(WORKDIR)/yaccdbg%prg: CC65FLAGS += -Wc --all-cdecl
-
-$(WORKDIR)/%.prg: %.c $(WORKDIR)/%.ref
-       $(CL65) $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
-       $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
-
-$(WORKDIR)/%.o.prg: %.c $(WORKDIR)/%.ref
-       $(CL65) -O $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
-       $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
-
-$(WORKDIR)/%.os.prg: %.c $(WORKDIR)/%.ref
-       $(CL65) -Os $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
-       $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
-
-$(WORKDIR)/%.osi.prg: %.c $(WORKDIR)/%.ref
-       $(CL65) -Osi $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
-       $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
-
-$(WORKDIR)/%.osir.prg: %.c $(WORKDIR)/%.ref
-       $(CL65) -Osir $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
-       $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
-
-$(WORKDIR)/%.oi.prg: %.c $(WORKDIR)/%.ref
-       $(CL65) -Oi $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
-       $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
-
-$(WORKDIR)/%.oir.prg: %.c $(WORKDIR)/%.ref
-       $(CL65) -Oir $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
-       $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
-
-$(WORKDIR)/%.or.prg: %.c $(WORKDIR)/%.ref
-       $(CL65) -Or $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@ > $(WORKDIR)/$*.out
-       $(DIFF) $(WORKDIR)/$*.out $(WORKDIR)/$*.ref
+$(WORKDIR)/init.%.prg   \
+$(WORKDIR)/switch.%.prg \
+$(WORKDIR)/yacc.%.prg   \
+$(WORKDIR)/yaccdbg.%.prg: CC65FLAGS += -Wc --all-cdecl
+
+# "yaccdbg.c" includes "yacc.c".
+# yaccdbg's built files must depend on both of them.
+#
+$(WORKDIR)/yaccdbg.ref:   yacc.c
+$(WORKDIR)/yaccdbg.%.prg: yacc.c
+
+define PRG_template
+
+$(WORKDIR)/%.$1.$2.prg: %.c $(WORKDIR)/%.ref $(DIFF)
+       $(if $(QUIET),echo ref/$$*.$1.$2.prg)
+       $(CL65) -t sim$2 $$(CC65FLAGS) -$1 -o $$@ $$< $(NULLERR)
+       $(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/$$*.out
+       $(DIFF) $(WORKDIR)/$$*.out $(WORKDIR)/$$*.ref
+
+endef # PRG_template
+
+$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),6502)))
+$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),65c02)))
 
 clean:
-       @$(call DEL,$(TESTS))
+       @$(call RMDIR,$(WORKDIR))
        @$(call DEL,$(SOURCES:.c=.o))
-       @$(call DEL,$(SOURCES:%.c=$(WORKDIR)/%.out))
-       @$(call DEL,$(SOURCES:%.c=$(WORKDIR)/%.ref))
-       @$(call DEL,$(SOURCES:%.c=$(WORKDIR)/%.host))
index 68a0198e161ee37b4f976adfa32b6c5c6fad9c24..8fcc951a6ee2f44b07ec63564e9103b8282048fb 100644 (file)
@@ -1,38 +1,38 @@
-/*\r
-  !!DESCRIPTION!! div/mod test\r
-  !!ORIGIN!!\r
-  !!LICENCE!!     public domain\r
-*/\r
-\r
-#include <stdio.h>\r
-\r
-void printc(signed char a,signed char b){\r
-signed char x=a/b,y=a%b,z=a*b;\r
-       printf("%3d,%3d is %3d,%3d,%3d\n",a,b,x,y,z);\r
-}\r
-void prints(short a,short b){\r
-short x=a/b,y=a%b,z=a*b;\r
-       printf("%3d,%3d is %3d,%3d,%3d\n",a,b,x,y,z);\r
-}\r
-void printl(long a,long b){\r
-long x=a/b,y=a%b,z=a*b;\r
-       printf("%3ld,%3ld is %3ld,%3ld,%3ld\n",a,b,x,y,z);\r
-}\r
-\r
-int main(void) {\r
-       printl( 3,-2);\r
-       printl(-3,-2);\r
-       printl(-3, 2);\r
-       printl( 3, 2);\r
-       printf("-\n");\r
-       prints( 3,-2);\r
-       prints(-3,-2);\r
-       prints(-3, 2);\r
-       prints( 3, 2);\r
-       printf("-\n");\r
-       printc( 3,-2);\r
-       printc(-3,-2);\r
-       printc(-3, 2);\r
-       printc( 3, 2);\r
+/*
+  !!DESCRIPTION!! div/mod test
+  !!ORIGIN!!
+  !!LICENCE!!     public domain
+*/
+
+#include <stdio.h>
+
+void printc(signed char a,signed char b){
+signed char x=a/b,y=a%b,z=a*b;
+       printf("%3d,%3d is %3d,%3d,%3d\n",a,b,x,y,z);
+}
+void prints(short a,short b){
+short x=a/b,y=a%b,z=a*b;
+       printf("%3d,%3d is %3d,%3d,%3d\n",a,b,x,y,z);
+}
+void printl(long a,long b){
+long x=a/b,y=a%b,z=a*b;
+       printf("%3ld,%3ld is %3ld,%3ld,%3ld\n",a,b,x,y,z);
+}
+
+int main(void) {
+       printl( 3,-2);
+       printl(-3,-2);
+       printl(-3, 2);
+       printl( 3, 2);
+       printf("-\n");
+       prints( 3,-2);
+       prints(-3,-2);
+       prints(-3, 2);
+       prints( 3, 2);
+       printf("-\n");
+       printc( 3,-2);
+       printc(-3,-2);
+       printc(-3, 2);
+       printc( 3, 2);
        return 0;
-}\r
+}
index 5a581675318dc39af59782ce50ee09a94b810d9f..44cd544fd77d5128c5423278bd20d05041f854e7 100644 (file)
@@ -1,95 +1,95 @@
-/*\r
-  !!DESCRIPTION!! variable initialization\r
-  !!ORIGIN!!      LCC 4.1 Testsuite\r
-  !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC\r
-*/\r
-\r
-#include "common.h"\r
-/* todo: add back conditional stuff here ! */\r
-\r
-typedef struct { int codes[3]; char name[6]; } Word;\r
-\r
-#ifdef NO_IMPLICIT_FUNC_PROTOTYPES\r
-\r
-#ifdef NO_OLD_FUNC_DECL\r
-f();\r
-void g(Word *p);\r
-h();\r
-#else\r
-f();\r
-g();\r
-h();\r
-#endif\r
-\r
-#endif\r
-\r
-/*\r
-Word words[] = {\r
-        1, 2, 3,"if",\r
-       { { 4, 5 }, { 'f', 'o', 'r' } },\r
-        6, 7, 8, {"else"},\r
-        { { 9, 10, 11,}, 'w', 'h', 'i', 'l', 'e', },\r
-        { 0 },\r
-}, *wordlist = words;\r
-*/\r
-\r
-Word words[] = {\r
-        {{1, 2, 3},"if"},\r
-       { { 4, 5 }, { 'f', 'o', 'r' } },\r
-        {{6, 7, 8}, "else"},\r
-        { { 9, 10, 11}, {'w', 'h', 'i', 'l', 'e', }},\r
-        {{ 0 }},\r
-}, *wordlist = words;\r
-\r
-/*int x[][5] = { 1, 2, 3, 4, 0, { 5, 6 }, { 7 } };*/\r
-int x[][5] = { {1, 2, 3, 4, 0 }, { 5, 6 }, { 7 } };\r
-int *y[] = { x[0], x[1], x[2], 0 };\r
-\r
-main()\r
-{\r
-       int i, j;\r
-\r
-       for (i = 0; y[i]; i++) {\r
-               for (j = 0; y[i][j]; j++)\r
-                       printf(" %d", y[i][j]);\r
-               printf("\n");\r
-       }\r
-       f();\r
-       g(wordlist);\r
-       return 0;\r
-}\r
-\r
-f() {\r
-       static char *keywords[] = {"if", "for", "else", "while", 0, };\r
-       char **p;\r
-\r
-       for (p = keywords; *p; p++)\r
-               printf("%s\n", *p);\r
-}\r
-\r
-#ifdef NO_OLD_FUNC_DECL\r
-void g(Word *p)\r
-#else\r
-g(p)\r
-Word *p;\r
-#endif\r
-{\r
-       int i;\r
-\r
-       for ( ; p->codes[0]; p++) {\r
-               for (i = 0; i < sizeof p->codes/sizeof(p->codes[0]); i++)\r
-                       printf("%d ", p->codes[i]);\r
-               printf("%s\n", p->name);\r
-       }\r
-       h();\r
-}\r
-\r
-h()\r
-{\r
-       int i;\r
-\r
-       for (i = 0; i < sizeof(words)/sizeof(Word); i++)\r
-               printf("%d %d %d %s\n", words[i].codes[0],\r
-                       words[i].codes[1], words[i].codes[2],\r
-                       &words[i].name[0]);\r
-}\r
+/*
+  !!DESCRIPTION!! variable initialization
+  !!ORIGIN!!      LCC 4.1 Testsuite
+  !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
+*/
+
+#include "common.h"
+/* todo: add back conditional stuff here ! */
+
+typedef struct { int codes[3]; char name[6]; } Word;
+
+#ifdef NO_IMPLICIT_FUNC_PROTOTYPES
+
+#ifdef NO_OLD_FUNC_DECL
+f();
+void g(Word *p);
+h();
+#else
+f();
+g();
+h();
+#endif
+
+#endif
+
+/*
+Word words[] = {
+        1, 2, 3,"if",
+       { { 4, 5 }, { 'f', 'o', 'r' } },
+        6, 7, 8, {"else"},
+        { { 9, 10, 11,}, 'w', 'h', 'i', 'l', 'e', },
+        { 0 },
+}, *wordlist = words;
+*/
+
+Word words[] = {
+        {{1, 2, 3},"if"},
+       { { 4, 5 }, { 'f', 'o', 'r' } },
+        {{6, 7, 8}, "else"},
+        { { 9, 10, 11}, {'w', 'h', 'i', 'l', 'e', }},
+        {{ 0 }},
+}, *wordlist = words;
+
+/*int x[][5] = { 1, 2, 3, 4, 0, { 5, 6 }, { 7 } };*/
+int x[][5] = { {1, 2, 3, 4, 0 }, { 5, 6 }, { 7 } };
+int *y[] = { x[0], x[1], x[2], 0 };
+
+main()
+{
+       int i, j;
+
+       for (i = 0; y[i]; i++) {
+               for (j = 0; y[i][j]; j++)
+                       printf(" %d", y[i][j]);
+               printf("\n");
+       }
+       f();
+       g(wordlist);
+       return 0;
+}
+
+f() {
+       static char *keywords[] = {"if", "for", "else", "while", 0, };
+       char **p;
+
+       for (p = keywords; *p; p++)
+               printf("%s\n", *p);
+}
+
+#ifdef NO_OLD_FUNC_DECL
+void g(Word *p)
+#else
+g(p)
+Word *p;
+#endif
+{
+       int i;
+
+       for ( ; p->codes[0]; p++) {
+               for (i = 0; i < sizeof p->codes/sizeof(p->codes[0]); i++)
+                       printf("%d ", p->codes[i]);
+               printf("%s\n", p->name);
+       }
+       h();
+}
+
+h()
+{
+       int i;
+
+       for (i = 0; i < sizeof(words)/sizeof(Word); i++)
+               printf("%d %d %d %s\n", words[i].codes[0],
+                       words[i].codes[1], words[i].codes[2],
+                       &words[i].name[0]);
+}
index d8c064ef3fbbfc36991fb4dbe36c3d6ef45273a0..29f9e3de40ac27327a646be5d5341bff02691f38 100644 (file)
-/*\r
-  !!DESCRIPTION!! pointer test\r
-  !!ORIGIN!!\r
-  !!LICENCE!!     public domain\r
-*/\r
-\r
-#include "common.h"\r
-#include <stdio.h>\r
-\r
-/*\r
-  check behaviour on incompletely declared arrays\r
-*/\r
-\r
-char i1[];\r
-\r
-void test1(void) {\r
-int a;\r
-\r
-       a=sizeof(i1[0]);\r
-       printf("%04x - ",a);\r
-       if(sizeof(i1[0])==sizeof(char)) {\r
-               /* gcc gives size of element */\r
-               printf("sizeof(i1[0]) gives size of element\n");\r
-       }\r
-       if(sizeof(i1[0])==sizeof(char*)) {\r
-               printf("sizeof(i1[0]) gives size of pointer to element\n");\r
-       }\r
-}\r
-\r
-/*\r
-  check behaviour on string init\r
-*/\r
-\r
-char t1[]="abcde";\r
-char t2[]={"abcde"};\r
-\r
-char *t3="abcde";\r
-char *t4={"abcde"};\r
-\r
-void test2(void) {\r
-char c1,c2,c3,c4;\r
-int i,e=0;\r
-       for(i=0;i<5;i++){\r
-               c1=t1[i];c2=t2[i];c3=t3[i];c4=t4[i];\r
-/*             printf("%02x %02x %02x %02x\n",c1,c2,c3,c4); */\r
-               printf("%c %c %c %c\n",c1,c2,c3,c4);\r
-               if(!((c1==c2)&(c1==c3)&(c1==c4))) e=1;\r
-       }\r
-       if(e) printf("test2 failed.\n");\r
-       else printf("test2 ok.\n");\r
-}\r
-\r
-/*\r
-  check behaviour on extern-declarations inside functions\r
-*/\r
-\r
-typedef struct {\r
-  char *name;\r
-  void *func;\r
-} A3;\r
-\r
-#ifdef NO_SLOPPY_STRUCT_INIT\r
-A3 a3[] = {\r
-  { "test3", (void*) NULL },\r
-  { "test3", (void*) NULL },\r
-};\r
-#else\r
-/*gcc warning: missing braces around initializer (near initialization for `a3[0]')\r
-  this type of struct-initialization seems to be kinda common */\r
-A3 a3[] = {\r
-    "test3", (void*) NULL  ,\r
-    "test3", (void*) NULL  ,\r
-};\r
-#endif\r
-\r
-void test3a(A3 *list, int number){\r
-       printf("%s %d\n",list->name,number);\r
-}\r
-\r
-static void test31(void)\r
-{\r
-    extern A3 a3[];\r
-    test3a(a3, -1);\r
-}\r
-\r
-#if 0\r
-/* this variation compiles and works with cc65, but gives an error with gcc :=P */\r
-static void test32(void)\r
-{\r
-    extern A3 *a3;\r
-    test3a(a3, -1);\r
-}\r
-#endif\r
-\r
-static void test30(void)\r
-{\r
-    test3a(a3, -1);\r
-}\r
-\r
-/*\r
-  todo: add test on function pointers in the form of (*func)(arg) ...\r
-  cc65 seems to have problems here aswell ;/\r
-*/\r
-\r
-int main(void) {\r
-       test1();\r
-       test2();\r
-       test30();\r
-       test31();\r
-/*     test32(); */\r
-       return 0;\r
-}\r
+/*
+  !!DESCRIPTION!! pointer test
+  !!ORIGIN!!
+  !!LICENCE!!     public domain
+*/
+
+#include "common.h"
+#include <stdio.h>
+
+/*
+  check behaviour on incompletely declared arrays
+*/
+
+char i1[];
+
+void test1(void) {
+int a;
+
+       a=sizeof(i1[0]);
+       printf("%04x - ",a);
+       if(sizeof(i1[0])==sizeof(char)) {
+               /* gcc gives size of element */
+               printf("sizeof(i1[0]) gives size of element\n");
+       }
+       if(sizeof(i1[0])==sizeof(char*)) {
+               printf("sizeof(i1[0]) gives size of pointer to element\n");
+       }
+}
+
+/*
+  check behaviour on string init
+*/
+
+char t1[]="abcde";
+char t2[]={"abcde"};
+
+char *t3="abcde";
+char *t4={"abcde"};
+
+void test2(void) {
+char c1,c2,c3,c4;
+int i,e=0;
+       for(i=0;i<5;i++){
+               c1=t1[i];c2=t2[i];c3=t3[i];c4=t4[i];
+/*             printf("%02x %02x %02x %02x\n",c1,c2,c3,c4); */
+               printf("%c %c %c %c\n",c1,c2,c3,c4);
+               if(!((c1==c2)&(c1==c3)&(c1==c4))) e=1;
+       }
+       if(e) printf("test2 failed.\n");
+       else printf("test2 ok.\n");
+}
+
+/*
+  check behaviour on extern-declarations inside functions
+*/
+
+typedef struct {
+  char *name;
+  void *func;
+} A3;
+
+#ifdef NO_SLOPPY_STRUCT_INIT
+A3 a3[] = {
+  { "test3", (void*) NULL },
+  { "test3", (void*) NULL },
+};
+#else
+/*gcc warning: missing braces around initializer (near initialization for `a3[0]')
+  this type of struct-initialization seems to be kinda common */
+A3 a3[] = {
+    "test3", (void*) NULL  ,
+    "test3", (void*) NULL  ,
+};
+#endif
+
+void test3a(A3 *list, int number){
+       printf("%s %d\n",list->name,number);
+}
+
+static void test31(void)
+{
+    extern A3 a3[];
+    test3a(a3, -1);
+}
+
+#if 0
+/* this variation compiles and works with cc65, but gives an error with gcc :=P */
+static void test32(void)
+{
+    extern A3 *a3;
+    test3a(a3, -1);
+}
+#endif
+
+static void test30(void)
+{
+    test3a(a3, -1);
+}
+
+/*
+  todo: add test on function pointers in the form of (*func)(arg) ...
+  cc65 seems to have problems here aswell ;/
+*/
+
+int main(void) {
+       test1();
+       test2();
+       test30();
+       test31();
+/*     test32(); */
+       return 0;
+}
index e75cfe71efa6c957c3fe7c3d2d71b7f4f65201a9..7a9bcecd7b820fc14807a324ef5427d5261d4519 100644 (file)
-/*\r
-  !!DESCRIPTION!! switch test\r
-  !!ORIGIN!!\r
-  !!LICENCE!!     public domain\r
-*/\r
-\r
-/*#define STANDALONE*/\r
-\r
-#include <stdio.h>\r
-\r
+/*
+  !!DESCRIPTION!! switch test
+  !!ORIGIN!!
+  !!LICENCE!!     public domain
+*/
+
+/*#define STANDALONE*/
+
+#include <stdio.h>
+
 void testlimits(int i) {
-       printf("%d:",i);\r
-\r
+       printf("%d:",i);
+
        switch(i) {
-               case -1:        /* works */\r
-               /* case 0xffff: */ /* 'range error' (-1) */\r
-\r
-                       printf("-1\n");\r
-                       break;\r
-               /* max int */\r
-\r
-/*              case 0x7fff:   */         /* works */\r
-               case 32767:                /* works */\r
-               /* case 32768: */          /* 'range error' (correct for that one!) */\r
-\r
-                       printf("max\n");\r
-                       break;\r
-               /* min int */\r
-\r
-               case -32768:               /* 'warning. constant is long' */\r
-               /* case 0x8000: */             /* 'range error' */\r
-               /* case -32769: */         /* 'range error' (correct for that one!) */\r
-                       printf("min\n");\r
-                       break;\r
-       }\r
-       printf("\n");\r
-}\r
-\r
-void testdefault1(unsigned char i) {\r
-/* we want a signed char */\r
-#ifdef REFCC\r
-\r
-#ifdef REFCC_UNSIGNED_CHARS\r
-signed char k;\r
-#else\r
-char k;\r
-#endif\r
-       \r
-#else\r
-       \r
-#ifdef UNSIGNED_CHARS\r
-signed char k;\r
-#else\r
-char k;\r
-#endif\r
-\r
-#endif\r
-\r
-       for(;i<254;) {\r
-               k = i;\r
-               printf(">%d\n",i);i++;\r
-               switch(k) {\r
-               case 1:\r
-                       break;\r
-               case 2:\r
-                       break;\r
-               case 3:\r
-                       break;\r
-               case 4:\r
-                       break;\r
-               case 5:\r
-                       break;\r
-               case 6:\r
-                       break;\r
-               case 7:\r
-                       break;\r
-               case 8:\r
-                       break;\r
-               case 9:\r
-                       break;\r
-               case 10:\r
-                       break;\r
-               case 11:\r
-                       break;\r
-               case 12:\r
-                       break;\r
-               case 13:\r
-                       break;\r
-               case 14:\r
-                       break;\r
-               case 15:\r
-                       break;\r
-               case 17:\r
-                       break;\r
-               /* triggers bug ? */\r
-               /* gcc warning: case label value exceeds maximum value for type */\r
-               /* cc65 error: range error */\r
-\r
-               /*\r
-               case 170:\r
-                       break;\r
-               */\r
-               case 18:\r
-                       break;\r
-               case 19:\r
-                       break;\r
-               case 20:\r
-                       break;\r
-               case 21:\r
-                       break;\r
-               case 22:\r
-                       break;\r
-               case 23:\r
-                       break;\r
-               case 24:\r
-                       switch(k) {\r
-                               case 1:\r
-                                       break;\r
-                               case 2:\r
-                                       break;\r
-                               case 3:\r
-                                       break;\r
-                               case 4:\r
-                               case 5:\r
-                               break;\r
-                               case 6:\r
-                               case 7:\r
-                                       break;\r
-                               case 8:\r
-                               case 9:\r
-                                       break;\r
-                               }\r
-                       break;\r
-               case 100:\r
-                       break;\r
-               default:\r
-                       printf(">>>default\n");\r
-                       /* triggers bug if this break; is missing? */\r
-                       /* break; */\r
-               }\r
-       }\r
-}\r
-\r
-void testdefault2(unsigned char i) {\r
-/* we want a unsigned char */\r
-#ifdef REFCC\r
-\r
-#ifdef REFCC_UNSIGNED_CHARS\r
-char k;\r
-#else\r
-unsigned char k;\r
-#endif\r
-       \r
-#else\r
-       \r
-#ifdef UNSIGNED_CHARS\r
-char k;\r
-#else\r
-unsigned char k;\r
-#endif\r
-\r
-#endif\r
-\r
-       for(;i<254;) {\r
-               k = i;\r
-               printf(">%d\n",i);i++;\r
-               switch(k) {\r
-               case 1:\r
-                       break;\r
-               case 2:\r
-                       break;\r
-               case 3:\r
-                       break;\r
-               case 4:\r
-                       break;\r
-               case 5:\r
-                       break;\r
-               case 6:\r
-                       break;\r
-               case 7:\r
-                       break;\r
-               case 8:\r
-                       break;\r
-               case 9:\r
-                       break;\r
-               case 10:\r
-                       break;\r
-               case 11:\r
-                       break;\r
-               case 12:\r
-                       break;\r
-               case 13:\r
-                       break;\r
-               case 14:\r
-                       break;\r
-               case 15:\r
-                       break;\r
-               case 17:\r
-                       break;\r
-               /* triggers bug ? */\r
-\r
-               case 170:\r
-                       break;\r
-               \r
-               case 18:\r
-                       break;\r
-               case 19:\r
-                       break;\r
-               case 20:\r
-                       break;\r
-               case 21:\r
-                       break;\r
-               case 22:\r
-                       break;\r
-               case 23:\r
-                       break;\r
-               case 24:\r
-                       switch(k) {\r
-                               case 1:\r
-                                       break;\r
-                               case 2:\r
-                                       break;\r
-                               case 3:\r
-                                       break;\r
-                               case 4:\r
-                               case 5:\r
-                               break;\r
-                               case 6:\r
-                               case 7:\r
-                                       break;\r
-                               case 8:\r
-                               case 9:\r
-                                       break;\r
-                               }\r
-                       break;\r
-               case 100:\r
-                       break;\r
-               default:\r
-                       printf(">>>default\n");\r
-                       /* triggers bug if this break; is missing? */\r
-                       /* break; */\r
-               }\r
-       }\r
+               case -1:        /* works */
+               /* case 0xffff: */ /* 'range error' (-1) */
+
+                       printf("-1\n");
+                       break;
+               /* max int */
+
+/*              case 0x7fff:   */         /* works */
+               case 32767:                /* works */
+               /* case 32768: */          /* 'range error' (correct for that one!) */
+
+                       printf("max\n");
+                       break;
+               /* min int */
+
+               case -32768:               /* 'warning. constant is long' */
+               /* case 0x8000: */             /* 'range error' */
+               /* case -32769: */         /* 'range error' (correct for that one!) */
+                       printf("min\n");
+                       break;
+       }
+       printf("\n");
+}
+
+void testdefault1(unsigned char i) {
+/* we want a signed char */
+#ifdef REFCC
+
+#ifdef REFCC_UNSIGNED_CHARS
+signed char k;
+#else
+char k;
+#endif
+       
+#else
+       
+#ifdef UNSIGNED_CHARS
+signed char k;
+#else
+char k;
+#endif
+
+#endif
+
+       for(;i<254;) {
+               k = i;
+               printf(">%d\n",i);i++;
+               switch(k) {
+               case 1:
+                       break;
+               case 2:
+                       break;
+               case 3:
+                       break;
+               case 4:
+                       break;
+               case 5:
+                       break;
+               case 6:
+                       break;
+               case 7:
+                       break;
+               case 8:
+                       break;
+               case 9:
+                       break;
+               case 10:
+                       break;
+               case 11:
+                       break;
+               case 12:
+                       break;
+               case 13:
+                       break;
+               case 14:
+                       break;
+               case 15:
+                       break;
+               case 17:
+                       break;
+               /* triggers bug ? */
+               /* gcc warning: case label value exceeds maximum value for type */
+               /* cc65 error: range error */
+
+               /*
+               case 170:
+                       break;
+               */
+               case 18:
+                       break;
+               case 19:
+                       break;
+               case 20:
+                       break;
+               case 21:
+                       break;
+               case 22:
+                       break;
+               case 23:
+                       break;
+               case 24:
+                       switch(k) {
+                               case 1:
+                                       break;
+                               case 2:
+                                       break;
+                               case 3:
+                                       break;
+                               case 4:
+                               case 5:
+                               break;
+                               case 6:
+                               case 7:
+                                       break;
+                               case 8:
+                               case 9:
+                                       break;
+                               }
+                       break;
+               case 100:
+                       break;
+               default:
+                       printf(">>>default\n");
+                       /* triggers bug if this break; is missing? */
+                       /* break; */
+               }
+       }
+}
+
+void testdefault2(unsigned char i) {
+/* we want a unsigned char */
+#ifdef REFCC
+
+#ifdef REFCC_UNSIGNED_CHARS
+char k;
+#else
+unsigned char k;
+#endif
+       
+#else
+       
+#ifdef UNSIGNED_CHARS
+char k;
+#else
+unsigned char k;
+#endif
+
+#endif
+
+       for(;i<254;) {
+               k = i;
+               printf(">%d\n",i);i++;
+               switch(k) {
+               case 1:
+                       break;
+               case 2:
+                       break;
+               case 3:
+                       break;
+               case 4:
+                       break;
+               case 5:
+                       break;
+               case 6:
+                       break;
+               case 7:
+                       break;
+               case 8:
+                       break;
+               case 9:
+                       break;
+               case 10:
+                       break;
+               case 11:
+                       break;
+               case 12:
+                       break;
+               case 13:
+                       break;
+               case 14:
+                       break;
+               case 15:
+                       break;
+               case 17:
+                       break;
+               /* triggers bug ? */
+
+               case 170:
+                       break;
+               
+               case 18:
+                       break;
+               case 19:
+                       break;
+               case 20:
+                       break;
+               case 21:
+                       break;
+               case 22:
+                       break;
+               case 23:
+                       break;
+               case 24:
+                       switch(k) {
+                               case 1:
+                                       break;
+                               case 2:
+                                       break;
+                               case 3:
+                                       break;
+                               case 4:
+                               case 5:
+                               break;
+                               case 6:
+                               case 7:
+                                       break;
+                               case 8:
+                               case 9:
+                                       break;
+                               }
+                       break;
+               case 100:
+                       break;
+               default:
+                       printf(">>>default\n");
+                       /* triggers bug if this break; is missing? */
+                       /* break; */
+               }
+       }
 }
 
 int main(void) {
-       testlimits(32767);\r
-       testlimits(-32768);\r
-       testlimits(-1);\r
-       \r
-       testdefault1(1);\r
-       testdefault1(2);\r
-       testdefault1(3);\r
-       testdefault1(4);\r
-       \r
-       testdefault2(1);\r
-       testdefault2(2);\r
-       testdefault2(3);\r
-       testdefault2(4);\r
-\r
-       return 0;\r
-}\r
+       testlimits(32767);
+       testlimits(-32768);
+       testlimits(-1);
+       
+       testdefault1(1);
+       testdefault1(2);
+       testdefault1(3);
+       testdefault1(4);
+       
+       testdefault2(1);
+       testdefault2(2);
+       testdefault2(3);
+       testdefault2(4);
+
+       return 0;
+}
index 11fd33b3829c615b41da580fa1bf2a5640b1f66d..3d61fdbd0d5b6bcf4fca13696625cdf078066b79 100644 (file)
 /*
-  !!DESCRIPTION!! varargs test\r
-  !!ORIGIN!!\r
-  !!LICENCE!!     public domain\r
-*/\r
-\r
-#include <stdlib.h>\r
-#include <stdio.h>\r
-#include <stdarg.h>\r
-\r
-void chk0(char *format,...);\r
-void chk1(int fd,char *format,...);\r
-\r
-#if 0\r
-// old workaround for broken varargs\r
-\r
-void chk0(char *format,...){\r
-    __asm__ ("pha");    // save argument size\r
-    {\r
-//va_list ap;\r
-char *ap;\r
-char *_format;\r
-static char string[0x100];\r
-\r
-//    va_start(ap,format);\r
-    __asm__ ("pla");       // restore argument size\r
-    __asm__ ("ldx #$00");  // clear hibyte of AX\r
-    ap=__AX__;\r
-    ap+=(char*)&format;\r
-    // get value of format\r
-    ap-=2;\r
-    _format=*((char**)ap);\r
-\r
-//    vsprintf(string,format,ap);\r
-    vsprintf(&string[0],_format,ap);\r
-    printf("format:%s,string:%s\n",_format,string);\r
-//    va_end(ap);\r
-\r
-    }\r
-}\r
-\r
-void chk1(int fd,char *format,...){\r
-    __asm__ ("pha");    // save argument size\r
-    {\r
-//va_list ap;\r
-char *ap;\r
-char *_format;\r
-int _fd;\r
-static char string[0x100];\r
-\r
-//    va_start(ap,format);\r
-    __asm__ ("pla");       // restore argument size\r
-    __asm__ ("ldx #$00");  // clear hibyte of AX\r
-    ap=__AX__;\r
-    ap+=(char*)&format;\r
-    // get value of fd\r
-    ap-=2;\r
-    _fd=*((int*)ap);\r
-    // get value of format\r
-    ap-=2;\r
-    _format=*((char**)ap);\r
-\r
-//    vsprintf(string,format,ap);\r
-    vsprintf(&string[0],_format,ap);\r
-    printf("fd:%d,format:%s,string:%s\n",_fd,_format,string);\r
-//    va_end(ap);\r
-\r
-    }\r
-}\r
-\r
-#endif\r
-\r
-void chk0(char *format,...){\r
-va_list ap;\r
-static char string[0x100];\r
-    va_start(ap,format);\r
-    vsprintf(string,format,ap);\r
-    printf("format:%s,string:%s\n",format,string);\r
-    va_end(ap);\r
-}\r
-\r
-void chk1(int fd,char *format,...){\r
-va_list ap;\r
-static char string[0x100];\r
-\r
-    va_start(ap,format);\r
-\r
-    vsprintf(string,format,ap);\r
-       printf("fd:%d,format:%s,string:%s\n",fd,format,string);\r
-    va_end(ap);\r
+  !!DESCRIPTION!! varargs test
+  !!ORIGIN!!
+  !!LICENCE!!     public domain
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+void chk0(char *format,...);
+void chk1(int fd,char *format,...);
+
+#if 0
+// old workaround for broken varargs
+
+void chk0(char *format,...){
+    __asm__ ("pha");    // save argument size
+    {
+//va_list ap;
+char *ap;
+char *_format;
+static char string[0x100];
+
+//    va_start(ap,format);
+    __asm__ ("pla");       // restore argument size
+    __asm__ ("ldx #$00");  // clear hibyte of AX
+    ap=__AX__;
+    ap+=(char*)&format;
+    // get value of format
+    ap-=2;
+    _format=*((char**)ap);
+
+//    vsprintf(string,format,ap);
+    vsprintf(&string[0],_format,ap);
+    printf("format:%s,string:%s\n",_format,string);
+//    va_end(ap);
+
+    }
+}
+
+void chk1(int fd,char *format,...){
+    __asm__ ("pha");    // save argument size
+    {
+//va_list ap;
+char *ap;
+char *_format;
+int _fd;
+static char string[0x100];
+
+//    va_start(ap,format);
+    __asm__ ("pla");       // restore argument size
+    __asm__ ("ldx #$00");  // clear hibyte of AX
+    ap=__AX__;
+    ap+=(char*)&format;
+    // get value of fd
+    ap-=2;
+    _fd=*((int*)ap);
+    // get value of format
+    ap-=2;
+    _format=*((char**)ap);
+
+//    vsprintf(string,format,ap);
+    vsprintf(&string[0],_format,ap);
+    printf("fd:%d,format:%s,string:%s\n",_fd,_format,string);
+//    va_end(ap);
+
+    }
 }
 
-int main(int argc,char **argv) {\r
-    printf("varargs test\n");\r
-\r
-    printf("\nchk0/0:\n");chk0("chk0 %s","arg0");\r
-    printf("\nchk0/1:\n");chk0("chk0 %s %s","arg0","arg1");\r
-    printf("\nchk0/2:\n");chk0("chk0 %s %s %s","arg0","arg1","arg2");\r
-\r
-    printf("\nchk1/0:\n");chk1(0xfd,"chk1 %s","arg0");\r
-    printf("\nchk1/1:\n");chk1(0xfd,"chk1 %s %s","arg0","arg1");\r
-    printf("\nchk1/2:\n");chk1(0xfd,"chk1 %s %s %s","arg0","arg1","arg2");\r
-\r
+#endif
+
+void chk0(char *format,...){
+va_list ap;
+static char string[0x100];
+    va_start(ap,format);
+    vsprintf(string,format,ap);
+    printf("format:%s,string:%s\n",format,string);
+    va_end(ap);
+}
+
+void chk1(int fd,char *format,...){
+va_list ap;
+static char string[0x100];
+
+    va_start(ap,format);
+
+    vsprintf(string,format,ap);
+       printf("fd:%d,format:%s,string:%s\n",fd,format,string);
+    va_end(ap);
+}
+
+int main(int argc,char **argv) {
+    printf("varargs test\n");
+
+    printf("\nchk0/0:\n");chk0("chk0 %s","arg0");
+    printf("\nchk0/1:\n");chk0("chk0 %s %s","arg0","arg1");
+    printf("\nchk0/2:\n");chk0("chk0 %s %s %s","arg0","arg1","arg2");
+
+    printf("\nchk1/0:\n");chk1(0xfd,"chk1 %s","arg0");
+    printf("\nchk1/1:\n");chk1(0xfd,"chk1 %s %s","arg0","arg1");
+    printf("\nchk1/2:\n");chk1(0xfd,"chk1 %s %s %s","arg0","arg1","arg2");
+
     return 0;
-}\r
+}
index 5768f80d00b5fb5708c8db6aa58018ecb0e68882..ab72e24c0881e48868e4d35c6160464b6ae7e3d0 100644 (file)
@@ -562,13 +562,13 @@ yylook()
                }
 
 # ifdef LEXDEBUG
-               if((*(lsp-1)-yysvec-1)<0)
+               if (lsp == yylstate)
                {
                        fprintf(yyout,"yylook:  stopped (end)\n");
                }
                else
                {
-                       fprintf(yyout,"yylook:  stopped at %d with\n",*(lsp-1)-yysvec-1);
+                       fprintf(yyout,"yylook:  stopped at %d with:\n",*(lsp-1)-(yysvec+1));
                }
 # endif
                while (lsp-- > yylstate)
@@ -594,7 +594,7 @@ yylook()
                                yyleng = yylastch-yytext+1;
                                yytext[yyleng] = 0;
 # ifdef LEXDEBUG
-                               fprintf(yyout,"\nyylook:  match action %d\n",*yyfnd);
+                               fprintf(yyout,"yylook:  match action %d\n",*yyfnd);
                                fprintf(yyout,"yylook:  done loops: %d\n",testbreak);
 # endif
                                return(*yyfnd++);
index 4ad8160efbb2080a183229445dd790cc3bb814f8..1981b36fe3fef0c0c21297afd35bd744b971c05d 100644 (file)
@@ -1,70 +1,78 @@
-
-# makefile for the regression tests that return an error code on failure
+# Makefile for the regression tests that return an error code on failure
 
 ifneq ($(shell echo),)
-  CMD_EXE := 1
+  CMD_EXE = 1
 endif
 
 ifdef CMD_EXE
-  DEL = -del /f $(subst /,\,$1)
+  S = $(subst /,\,/)
+  NULLDEV = nul:
+  MKDIR = mkdir $(subst /,\,$1)
+  RMDIR = -rmdir /s /q $(subst /,\,$1)
+  DEL = del /f $(subst /,\,$1)
 else
+  S = /
+  NULLDEV = /dev/null
+  MKDIR = mkdir -p $1
+  RMDIR = $(RM) -r $1
   DEL = $(RM) $1
 endif
 
-CC65FLAGS := -t sim6502
-SIM65FLAGS := -x 200000000
+ifdef QUIET
+  .SILENT:
+  NULLOUT = >$(NULLDEV)
+  NULLERR = 2>$(NULLDEV)
+endif
+
+SIM65FLAGS = -x 200000000
 
-CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
-SIM65 := $(if $(wildcard ../../bin/sim65*),../../bin/sim65,sim65)
+CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65)
+SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65)
 
-WORKDIR := ../../testwrk
+WORKDIR = ../../testwrk/val
+
+OPTIONS = g O Os Osi Osir Oi Oir Or
 
 .PHONY: all clean
 
 SOURCES := $(wildcard *.c)
-TESTS := $(foreach option,. .o. .os. .osi. .osir. .oi. .oir. .or.,$(SOURCES:%.c=$(WORKDIR)/%$(option)prg))
+TESTS := $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).6502.prg))
+TESTS += $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).65c02.prg))
+
+# FIXME: These tests fail when built with optimizations for the 65c02
+TESTS := $(filter-out $(WORKDIR)/compare7.O%.65c02.prg,$(TESTS))
+TESTS := $(filter-out $(WORKDIR)/compare8.O%.65c02.prg,$(TESTS))
+TESTS := $(filter-out $(WORKDIR)/compare9.O%.65c02.prg,$(TESTS))
+TESTS := $(filter-out $(WORKDIR)/compare10.O%.65c02.prg,$(TESTS))
+TESTS := $(filter-out $(WORKDIR)/or1.O%.65c02.prg,$(TESTS))
 
 all: $(TESTS)
 
+$(WORKDIR):
+       $(call MKDIR,$(WORKDIR))
+
 # Some files have "K & R"-style syntax.  Therefore, some forward
 # function-declarations don't match the later function definitions.
 # Those programs fail when fastcall is used; but, the cdecl calling convention
 # tolerates those conflicts.  Therefore, make their functions default to cdecl.
 #
-$(WORKDIR)/cq4%prg $(WORKDIR)/cq71.%rg $(WORKDIR)/cq81%prg $(WORKDIR)/cq84%prg: CC65FLAGS += -Wc --all-cdecl
-
-$(WORKDIR)/%.prg: %.c
-       $(CL65) $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@
-
-$(WORKDIR)/%.o.prg: %.c
-       $(CL65) -O $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@
-
-$(WORKDIR)/%.os.prg: %.c
-       $(CL65) -Os $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@
-
-$(WORKDIR)/%.osi.prg: %.c
-       $(CL65) -Osi $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@
+$(WORKDIR)/cq4.%.prg  \
+$(WORKDIR)/cq71.%.prg \
+$(WORKDIR)/cq81.%.prg \
+$(WORKDIR)/cq84.%.prg: CC65FLAGS += -Wc --all-cdecl
 
-$(WORKDIR)/%.osir.prg: %.c
-       $(CL65) -Osir $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@
+define PRG_template
 
-$(WORKDIR)/%.oi.prg: %.c
-       $(CL65) -Oi $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@
+$(WORKDIR)/%.$1.$2.prg: %.c | $(WORKDIR)
+       $(if $(QUIET),echo val/$$*.$1.$2.prg)
+       $(CL65) -t sim$2 $$(CC65FLAGS) -$1 -o $$@ $$< $(NULLERR)
+       $(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT)
 
-$(WORKDIR)/%.oir.prg: %.c
-       $(CL65) -Oir $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@
+endef # PRG_template
 
-$(WORKDIR)/%.or.prg: %.c
-       $(CL65) -Or $(CC65FLAGS) $< -o $@
-       $(SIM65) $(SIM65FLAGS) $@
+$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),6502)))
+$(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),65c02)))
 
 clean:
-       @$(call DEL,$(TESTS))
+       @$(call RMDIR,$(WORKDIR))
        @$(call DEL,$(SOURCES:.c=.o))
diff --git a/test/val/static-fwd-decl.c b/test/val/static-fwd-decl.c
new file mode 100644 (file)
index 0000000..420640d
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+  !!DESCRIPTION!! static forward declarations
+  !!ORIGIN!!      cc65 regression tests
+  !!LICENCE!!     Public Domain
+  !!AUTHOR!!      Bob Andrews
+*/
+
+/*
+  see: https://github.com/cc65/cc65/issues/204
+*/
+
+#pragma warn(error, on)
+
+typedef struct _DIRMENU
+{
+    const char *name;
+    struct _DIRMENU *dest;
+} DIRMENU; 
+
+static DIRMENU rmenu;
+
+static DIRMENU lmenu = {
+    "left",
+    &rmenu
+};
+
+static DIRMENU rmenu = {
+    "right",
+    &lmenu
+};
+
+int main(void)
+{
+    return lmenu.dest == &rmenu && rmenu.dest == &lmenu ? 0 : 1;
+}
diff --git a/test/val/void-size1.c b/test/val/void-size1.c
new file mode 100644 (file)
index 0000000..0c2dcca
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+  !!DESCRIPTION!! Getting the size of a void-type variable (cc65 extension)
+  !!ORIGIN!!      cc65 regression tests
+  !!LICENCE!!     Public Domain
+  !!AUTHOR!!      Greg King
+*/
+
+static const void list1 = {
+    (char)1,
+    (char)2,
+    (char)3,
+    (char)4,
+    (char)5,
+    (char)6,
+    (char)7,
+    (char)8,
+    (char)9,
+    (char)0
+};
+
+static void list2 = {
+    1,
+    2,
+    3,
+    4,
+    5,
+    6,
+    7,
+    8,
+    9,
+    0
+};
+
+void list3 = {
+    (char)1,
+    (char)2,
+    (char)3,
+    (char)4,
+    &list1,
+    (char)6,
+    (char)7,
+    (char)8,
+    (char)9,
+    &list2
+};
+
+/* We know that the expression is constant; don't tell us. */
+
+#pragma warn (const-comparison, off)
+
+int main (void)
+{
+    return sizeof list1 != 10
+        || sizeof list2 != 20
+        || sizeof list3 != 12;
+}
index 04c5998786eb1cddb1b1c5f4c56af9ab5b82afd3..ae1931e64df042ede5534102349a44ed596a98a4 100644 (file)
@@ -1,59 +1,55 @@
 /*
-** testprogram for ANTIC instructions as defined in "_antic.h"
+** test program for ANTIC instructions as defined in "_antic.h"
 **
 ** 23-Feb-2017, Christian Krueger
 */
 
 #include <conio.h>
 #include <atari.h>
-#include <peekpoke.h>
-#include <string.h>
 
-// code is only for testing purposes, as screen and display list are not aligned
+// code is only for testing purposes, as screen and display list are not aligned,
 // and jumps not set!
 
 unsigned char DummyScreen[400];
 
 void DisplayList = {
-       DL_BLK1,
-       DL_BLK2,
-       DL_BLK3,
-       DL_BLK4,
-       DL_BLK5,
-       DL_BLK6,
-       DL_BLK7,
-       DL_DLI(DL_BLK8),
-       DL_LMS(DL_CHR40x8x1),
-       DummyScreen,
-       DL_HSCROL(DL_CHR40x10x1),
-       DL_VSCROL(DL_CHR40x8x4),
-       DL_CHR40x16x4,
-       DL_LMS(DL_HSCROL(DL_VSCROL(DL_DLI(DL_CHR20x8x2)))),
-       DummyScreen+120,
-       DL_CHR20x16x2,
-       DL_MAP40x8x4,
-       DL_MAP80x4x2,
-       DL_MAP80x4x4,
-       DL_MAP160x2x2,
-       DL_MAP160x1x2,
-       DL_MAP160x2x4,
-       DL_MAP160x1x4,
-       DL_MAP320x1x1, 
-       DL_JVB,
-       DL_JMP
+    DL_BLK1,
+    DL_BLK2,
+    DL_BLK3,
+    DL_BLK4,
+    DL_BLK5,
+    DL_BLK6,
+    DL_BLK7,
+    DL_DLI(DL_BLK8),
+    DL_LMS(DL_CHR40x8x1),
+    DummyScreen,
+    DL_HSCROL(DL_CHR40x10x1),
+    DL_VSCROL(DL_CHR40x8x4),
+    DL_CHR40x16x4,
+    DL_LMS(DL_HSCROL(DL_VSCROL(DL_DLI(DL_CHR20x8x2)))),
+    DummyScreen+120,
+    DL_CHR20x16x2,
+    DL_MAP40x8x4,
+    DL_MAP80x4x2,
+    DL_MAP80x4x4,
+    DL_MAP160x2x2,
+    DL_MAP160x1x2,
+    DL_MAP160x2x4,
+    DL_MAP160x1x4,
+    DL_MAP320x1x1,
+    DL_JVB,
+    DL_JMP
 };
 
-unsigned char dlend = 0;
 
+/* We know that the sizeof expression is constant; don't tell us. */
+
+#pragma warn (const-comparison, off)
 
 int
 main(void)
 {
-    // unfortunately "sizeof()" doesn't work with void data
-    // (Error: Size of data type is unknown)
-    // so we trick with the addresses at front and end...
-
-    int returnValue = (((unsigned int)&dlend-(unsigned int)&DisplayList) != 28);  // assure only one byte per instruction!
+    int returnValue = (sizeof DisplayList != 28);       // assure only one byte per instruction!
 
     clrscr();
     if (returnValue)
@@ -66,4 +62,3 @@ main(void)
 
     return returnValue;
 }
-
index 2daf5aa062f03928eca6789225557aabe7685e82..f9db3f641a8f19a8fed601e1e8376dbbb29c521a 100644 (file)
-/* mul-test.c -- Test the multiplication operator. */\r
-\r
-#include <time.h>\r
-#include <conio.h>\r
-#include <ctype.h>\r
-\r
-\r
-/* Number of elements in the progress bar. Use a power of 2, to avoid the\r
-** multiplication (which is about to be tested).\r
-*/\r
-#define BAR_ELEMENTS    32U\r
-\r
-#if defined(__CBM__)\r
-static const unsigned char revers_bar[8] = {\r
-    0, 0, 0, 0, 0, 1, 1, 1\r
-};\r
-static const unsigned char small_bar[8] = {\r
-    ' ', 0xa5, 0xb4, 0xb5, 0xa1, 0xb6, 0xaa, 0xa7\r
-};\r
-\r
-#elif defined(__ATARI__)\r
-#endif\r
-\r
-/* Screen co-ordinates for the progress meter */\r
-static unsigned char Width, Height;\r
-static unsigned char X, Y;\r
-\r
-static void ProgressMeter (unsigned Val)\r
-/* Print the progress bar. */\r
-{\r
-    gotoxy (X, Y);\r
-    cprintf (" %5lu/65536\r\n", (unsigned long) Val);\r
-    revers (1);\r
-    cclear (Val / (unsigned)(65536U / BAR_ELEMENTS));\r
-\r
-/* Commodore and Atari computers can show eight times greater precision. */\r
-#if defined(__CBM__)\r
-    Val = (Val / (unsigned)(65536U / BAR_ELEMENTS / 8)) % 8;\r
-    revers (revers_bar[Val]);\r
-    cputc (small_bar[Val]);\r
-\r
-#elif defined(__ATARI__)\r
-#endif\r
-\r
-    revers (0);\r
-}\r
-\r
-\r
-\r
-int main(void)\r
-{\r
-    char C;\r
-\r
-    /* Clock variables */\r
-    clock_t Ticks;\r
-    clock_t Wait;\r
-    unsigned Days;\r
-    unsigned Hours;\r
-    unsigned Minu;\r
-    unsigned Sec;\r
-    unsigned Milli;\r
-\r
-    /* Actual test variables */\r
-    register unsigned lhs = 0;\r
-    register unsigned rhs = 0;\r
-    register unsigned res;\r
-\r
-    /* Clear the screen, and output an informational message. */\r
-    clrscr ();\r
-    screensize (&Width, &Height);\r
-    cprintf ("This program does an exhaustive test of\r\n"\r
-             "the multiplication routine. It runs for\r\n"\r
-             "several days; so, please wait very\r\n"\r
-             "patiently (or, speed up your emulator).\r\n"\r
-             "\n"\r
-             "Progress: ");\r
-\r
-    /* Remember the current position for the progress bar */\r
-    X = wherex ();\r
-    Y = wherey ();\r
-\r
-    /* Mark the maximum limit of the bar. */\r
-    revers (1);\r
-    cputcxy (BAR_ELEMENTS, Y, ' ');\r
-    cputcxy (BAR_ELEMENTS, Y + 1, ' ');\r
-    revers (0);\r
-\r
-/* [Targets that have clock() will define CLOCKS_PER_SEC.] */\r
-#ifdef CLOCKS_PER_SEC\r
-\r
-    /* Start timing the test. */\r
-    Ticks = clock();\r
-#endif\r
-\r
-    do {\r
-\r
-        /* Update the progress bar */\r
-        ProgressMeter (lhs);\r
-\r
-/* Enable this to test the progress-meter code.\r
-** (And, run emulators at their maximun speed.)\r
-*/\r
-#if 0\r
-        continue;\r
-#endif\r
-\r
-        /* Do one row of tests */\r
-        res = 0;\r
-        do {\r
-            if (lhs * rhs != res) {\r
-#ifdef CLOCKS_PER_SEC\r
-                Wait = clock ();\r
-#endif\r
-                gotoxy (0, Y+3);\r
-                cprintf ("Error on %u * %u: %u != %u\r\n", lhs, rhs, lhs * rhs, res);\r
-                cprintf ("Press a key -- 'Q' to quit. ");\r
-                cursor (1);\r
-                C = toupper (cgetc ());\r
-                cclearxy (0, Y+3, Width);\r
-                cclearxy (0, Y+4, Width);\r
-\r
-#ifdef CLOCKS_PER_SEC\r
-\r
-                /* Don't time the user's interaction. */\r
-                Ticks += clock () - Wait;\r
-#endif\r
-\r
-                if (C == 'Q') {\r
-                    goto Done;\r
-                }\r
-            }\r
-\r
-            if (kbhit () && toupper (cgetc ()) == 'Q') {\r
-                goto Done;\r
-            }\r
-\r
-            res += lhs;\r
-        } while (++rhs != 0);\r
-\r
-    } while (++lhs != 0);\r
-\r
-Done:\r
-#ifdef CLOCKS_PER_SEC\r
-\r
-    /* Calculate the time used */\r
-    Ticks = clock() - Ticks;\r
-    Milli = ((Ticks % CLOCKS_PER_SEC) * 1000) / CLOCKS_PER_SEC;\r
-    Sec = (unsigned) (Ticks / CLOCKS_PER_SEC);\r
-    Minu = Sec / 60;\r
-    Hours = Minu / 60;\r
-    Days = Hours / 24;\r
-    Hours %= 24;\r
-    Minu %= 60;\r
-    Sec %= 60;\r
-\r
-    /* Print the time used */\r
-    gotoxy (0, Y+3);\r
-    cprintf ("Time used:\r\n"\r
-             " %u days,\r\n"\r
-             " %u hours,\r\n"\r
-             " %u minutes,\r\n"\r
-             " %u.%03u seconds.\n", Days, Hours, Minu, Sec, Milli);\r
-#endif\r
-\r
-    cprintf ("\rTap a key, to exit. ");\r
-    cgetc();\r
-    return 0;\r
-}\r
-\r
-\r
+/* mul-test.c -- Test the multiplication operator. */
+
+#include <time.h>
+#include <conio.h>
+#include <ctype.h>
+
+
+/* Number of elements in the progress bar. Use a power of 2, to avoid the
+** multiplication (which is about to be tested).
+*/
+#define BAR_ELEMENTS    32U
+
+#if defined(__CBM__)
+static const unsigned char revers_bar[8] = {
+    0, 0, 0, 0, 0, 1, 1, 1
+};
+static const unsigned char small_bar[8] = {
+    ' ', 0xa5, 0xb4, 0xb5, 0xa1, 0xb6, 0xaa, 0xa7
+};
+
+#elif defined(__ATARI__)
+#endif
+
+/* Screen co-ordinates for the progress meter */
+static unsigned char Width, Height;
+static unsigned char X, Y;
+
+static void ProgressMeter (unsigned Val)
+/* Print the progress bar. */
+{
+    gotoxy (X, Y);
+    cprintf (" %5lu/65536\r\n", (unsigned long) Val);
+    revers (1);
+    cclear (Val / (unsigned)(65536U / BAR_ELEMENTS));
+
+/* Commodore and Atari computers can show eight times greater precision. */
+#if defined(__CBM__)
+    Val = (Val / (unsigned)(65536U / BAR_ELEMENTS / 8)) % 8;
+    revers (revers_bar[Val]);
+    cputc (small_bar[Val]);
+
+#elif defined(__ATARI__)
+#endif
+
+    revers (0);
+}
+
+
+
+int main(void)
+{
+    char C;
+
+    /* Clock variables */
+    clock_t Ticks;
+    clock_t Wait;
+    unsigned Days;
+    unsigned Hours;
+    unsigned Minu;
+    unsigned Sec;
+    unsigned Milli;
+
+    /* Actual test variables */
+    register unsigned lhs = 0;
+    register unsigned rhs = 0;
+    register unsigned res;
+
+    /* Clear the screen, and output an informational message. */
+    clrscr ();
+    screensize (&Width, &Height);
+    cprintf ("This program does an exhaustive test of\r\n"
+             "the multiplication routine. It runs for\r\n"
+             "several days; so, please wait very\r\n"
+             "patiently (or, speed up your emulator).\r\n"
+             "\n"
+             "Progress: ");
+
+    /* Remember the current position for the progress bar */
+    X = wherex ();
+    Y = wherey ();
+
+    /* Mark the maximum limit of the bar. */
+    revers (1);
+    cputcxy (BAR_ELEMENTS, Y, ' ');
+    cputcxy (BAR_ELEMENTS, Y + 1, ' ');
+    revers (0);
+
+/* [Targets that have clock() will define CLOCKS_PER_SEC.] */
+#ifdef CLOCKS_PER_SEC
+
+    /* Start timing the test. */
+    Ticks = clock();
+#endif
+
+    do {
+
+        /* Update the progress bar */
+        ProgressMeter (lhs);
+
+/* Enable this to test the progress-meter code.
+** (And, run emulators at their maximun speed.)
+*/
+#if 0
+        continue;
+#endif
+
+        /* Do one row of tests */
+        res = 0;
+        do {
+            if (lhs * rhs != res) {
+#ifdef CLOCKS_PER_SEC
+                Wait = clock ();
+#endif
+                gotoxy (0, Y+3);
+                cprintf ("Error on %u * %u: %u != %u\r\n", lhs, rhs, lhs * rhs, res);
+                cprintf ("Press a key -- 'Q' to quit. ");
+                cursor (1);
+                C = toupper (cgetc ());
+                cclearxy (0, Y+3, Width);
+                cclearxy (0, Y+4, Width);
+
+#ifdef CLOCKS_PER_SEC
+
+                /* Don't time the user's interaction. */
+                Ticks += clock () - Wait;
+#endif
+
+                if (C == 'Q') {
+                    goto Done;
+                }
+            }
+
+            if (kbhit () && toupper (cgetc ()) == 'Q') {
+                goto Done;
+            }
+
+            res += lhs;
+        } while (++rhs != 0);
+
+    } while (++lhs != 0);
+
+Done:
+#ifdef CLOCKS_PER_SEC
+
+    /* Calculate the time used */
+    Ticks = clock() - Ticks;
+    Milli = ((Ticks % CLOCKS_PER_SEC) * 1000) / CLOCKS_PER_SEC;
+    Sec = (unsigned) (Ticks / CLOCKS_PER_SEC);
+    Minu = Sec / 60;
+    Hours = Minu / 60;
+    Days = Hours / 24;
+    Hours %= 24;
+    Minu %= 60;
+    Sec %= 60;
+
+    /* Print the time used */
+    gotoxy (0, Y+3);
+    cprintf ("Time used:\r\n"
+             " %u days,\r\n"
+             " %u hours,\r\n"
+             " %u minutes,\r\n"
+             " %u.%03u seconds.\n", Days, Hours, Minu, Sec, Milli);
+#endif
+
+    cprintf ("\rTap a key, to exit. ");
+    cgetc();
+    return 0;
+}
+
+