From c0d2643952b36a593777ca673238f69a8f1d7135 Mon Sep 17 00:00:00 2001 From: Sven Oliver Moll Date: Wed, 7 Sep 2016 19:44:11 +0200 Subject: [PATCH] added 4510 cpu detection to getcpu.s --- include/6502.h | 1 + libsrc/common/getcpu.s | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/6502.h b/include/6502.h index 6c104c83a..31398e5c1 100644 --- a/include/6502.h +++ b/include/6502.h @@ -50,6 +50,7 @@ typedef unsigned size_t; #define CPU_6502 0 #define CPU_65C02 1 #define CPU_65816 2 +#define CPU_4510 3 unsigned char getcpu (void); /* Detect the CPU the program is running on */ diff --git a/libsrc/common/getcpu.s b/libsrc/common/getcpu.s index b7954f52f..1e60a5d39 100644 --- a/libsrc/common/getcpu.s +++ b/libsrc/common/getcpu.s @@ -12,6 +12,7 @@ ; - carry clear and 0 in A for a NMOS 6502 CPU ; - carry set and 1 in A for some CMOS 6502 CPU ; - carry set and 2 in A for a 65816 +; - carry set and 3 in A for a 4510 ; ; This function uses a $1A opcode which is a INA on the 816 and ignored ; (interpreted as a NOP) on a NMOS 6502. There are several CMOS versions @@ -22,16 +23,24 @@ _getcpu: lda #0 - inc a ; .byte $1A + inc a ; .byte $1A ; nop on nmos, inc on every cmos cmp #1 bcc @L9 -; This is at least a 65C02, check for a 65816 +; This is at least a 65C02, check for a 4510 + + .byte $42,$ea ; neg on 4510, nop #$ea on 65c02, wdm $ea on 65816 + cmp #1 + bne @L8 + +; check for 65816; after 4510, because $eb there is row (rotate word) xba ; .byte $eb, put $01 in B accu dec a ; .byte $3a, A=$00 if 65C02 xba ; .byte $eb, get $01 back if 65816 inc a ; .byte $1a, make $01/$02 + .byte $2c ; bit instruction to skip next command +@L8: lda #3 ; CPU_4510 constant @L9: ldx #0 ; Load high byte of word rts