added first CPU specific optimizations
This commit is contained in:
1 parent
5b2c28b281
commit
55e2512fe2
12 files changed
+198
-7
No files matched your search
@@ -4,6 +4,10 @@
|
||||
//
|
||||
|
||||
|
||||
#define CONFIG_CPU_MOS_6502
|
||||
// #define CONFIG_CPU_WDC_65C02
|
||||
// #define CONFIG_CPU_WDC_65816
|
||||
|
||||
#define CONFIG_MEMORY_MODEL_38K
|
||||
// #define CONFIG_MEMORY_MODEL_60K
|
||||
|
||||
@@ -17,3 +21,4 @@
|
||||
// #define CONFIG_SID_D5XX
|
||||
|
||||
#define CONFIG_DOS_WEDGE
|
||||
#define CONFIG_BCD_SAFE_INTERRUPTS
|
||||
@@ -4,6 +4,10 @@
|
||||
//
|
||||
|
||||
|
||||
#define CONFIG_CPU_MOS_6502
|
||||
// #define CONFIG_CPU_WDC_65C02
|
||||
// #define CONFIG_CPU_WDC_65816
|
||||
|
||||
// #define CONFIG_MEMORY_MODEL_38K
|
||||
#define CONFIG_MEMORY_MODEL_60K
|
||||
|
||||
@@ -17,3 +21,4 @@
|
||||
// #define CONFIG_SID_D5XX
|
||||
|
||||
#define CONFIG_DOS_WEDGE
|
||||
#define CONFIG_BCD_SAFE_INTERRUPTS
|
||||
@@ -4,6 +4,10 @@
|
||||
//
|
||||
|
||||
|
||||
#define CONFIG_CPU_MOS_6502
|
||||
// #define CONFIG_CPU_WDC_65C02
|
||||
// #define CONFIG_CPU_WDC_65816
|
||||
|
||||
#define CONFIG_MEMORY_MODEL_38K
|
||||
// #define CONFIG_MEMORY_MODEL_60K
|
||||
|
||||
@@ -17,3 +21,4 @@
|
||||
#define CONFIG_SID_D5XX
|
||||
|
||||
#define CONFIG_DOS_WEDGE
|
||||
#define CONFIG_BCD_SAFE_INTERRUPTS
|
||||
@@ -0,0 +1,61 @@
|
||||
|
||||
// Various configuration dependent aliases/macros/checks
|
||||
|
||||
|
||||
|
||||
// Check that memory model configuration is correct
|
||||
|
||||
{
|
||||
.var selected = 0;
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_38K
|
||||
.eval selected++
|
||||
#endif
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
.eval selected++
|
||||
#endif
|
||||
|
||||
.if (selected != 1) .error "Please select exactly one CONFIG_MEMORY_MODEL_* option"
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Check that processor configuration is correct
|
||||
|
||||
{
|
||||
.var selected = 0;
|
||||
|
||||
#if CONFIG_CPU_MOS_6502
|
||||
.eval selected++
|
||||
#endif
|
||||
#if CONFIG_CPU_WDC_65C02
|
||||
.eval selected++
|
||||
#endif
|
||||
#if CONFIG_CPU_WDC_65816
|
||||
.eval selected++
|
||||
#endif
|
||||
|
||||
.if (selected != 1) .error "Please select exactly one CONFIG_CPU_* option"
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Handle processor configuration
|
||||
|
||||
#if CONFIG_CPU_WDC_65C02 || CONFIG_CPU_WDC_65816
|
||||
|
||||
#define HAS_BCD_SAFE_INTERRUPTS
|
||||
#define HAS_BCD_SAFE_RESET
|
||||
|
||||
.pseudocommand phx { .byte $DA }
|
||||
.pseudocommand phy { .byte $5A }
|
||||
.pseudocommand plx { .byte $FA }
|
||||
.pseudocommand ply { .byte $7A }
|
||||
|
||||
#endif
|
||||
|
||||
// Handle misc configuration entrues
|
||||
|
||||
#if CONFIG_BCD_SAFE_INTERRUPTS
|
||||
#define HAS_BCD_SAFE_INTERRUPTS
|
||||
#endif
|
||||
+29
-1
@@ -139,7 +139,13 @@ printf_retreat:
|
||||
rts
|
||||
|
||||
printf_printhexbyte:
|
||||
// Print the hex value in .A as two digits, idea by Haubitze
|
||||
|
||||
// Print the hex value in .A as two digits
|
||||
|
||||
#if HAS_BCD_SAFE_INTERRUPTS
|
||||
|
||||
// Idea by Haubitze
|
||||
|
||||
sed
|
||||
pha
|
||||
lsr
|
||||
@@ -155,3 +161,25 @@ printf_printhexbyte:
|
||||
adc #$30
|
||||
cld
|
||||
jmp JCHROUT
|
||||
|
||||
#else
|
||||
|
||||
pha
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
ora #$30
|
||||
cmp #$3A
|
||||
bcc !+
|
||||
adc #6
|
||||
!: jsr JCHROUT
|
||||
pla
|
||||
and #$0f
|
||||
ora #$30
|
||||
cmp #$3A
|
||||
bcc !+
|
||||
adc #6
|
||||
!: jmp JCHROUT
|
||||
|
||||
#endif
|
||||
@@ -11,10 +11,16 @@ return_from_interrupt:
|
||||
|
||||
// Restore registers and return
|
||||
// Sequence according to Compute's Mapping the 64 p73
|
||||
|
||||
#if CONFIG_CPU_MOS_6502
|
||||
pla
|
||||
tay
|
||||
pla
|
||||
tax
|
||||
#else
|
||||
ply
|
||||
plx
|
||||
#endif
|
||||
pla
|
||||
rti
|
||||
|
||||
@@ -6,10 +6,15 @@ default_nmi_handler:
|
||||
|
||||
// Save registers, sequence according to Compute's Mapping the Commodore 64, page 73
|
||||
pha
|
||||
#if CONFIG_CPU_MOS_6502
|
||||
txa
|
||||
pha
|
||||
tya
|
||||
pha
|
||||
#else
|
||||
phx
|
||||
phy
|
||||
#endif
|
||||
|
||||
// XXX: RS-232 support is not implemented
|
||||
|
||||
|
||||
@@ -10,12 +10,19 @@ irq_handler:
|
||||
|
||||
// Save registers, sequence according to Compute's Mapping the Commodore 64, page 73
|
||||
pha
|
||||
#if CONFIG_CPU_MOS_6502
|
||||
txa
|
||||
pha
|
||||
tya
|
||||
pha
|
||||
#else
|
||||
phx
|
||||
phy
|
||||
#endif
|
||||
|
||||
cld // clear decimal flag, to prevent possible problems
|
||||
#if CONFIG_CPU_MOS_6502 && CONFIG_BCD_SAFE_INTERRUPTS
|
||||
cld // clear decimal flag to allow using it without disabling interrupts
|
||||
#endif
|
||||
|
||||
// Check if caused by BRK
|
||||
tsx
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
nmi_handler:
|
||||
|
||||
sei // don't allow IRQ to interfere, see https://www.c64-wiki.com/wiki/Interrupt
|
||||
cld // clear decimal flag, to prevent possible problems
|
||||
|
||||
#if CONFIG_CPU_MOS_6502 && CONFIG_BCD_SAFE_INTERRUPTS
|
||||
cld // clear decimal flag to allow using it without disabling interrupts
|
||||
#endif
|
||||
|
||||
// Call interrupt routine (only if initialised)
|
||||
pha
|
||||
|
||||
+29
-1
@@ -139,7 +139,13 @@ printf_retreat:
|
||||
rts
|
||||
|
||||
printf_printhexbyte:
|
||||
// Print the hex value in .A as two digits, idea by Haubitze
|
||||
|
||||
// Print the hex value in .A as two digits
|
||||
|
||||
#if HAS_BCD_SAFE_INTERRUPTS
|
||||
|
||||
// Idea by Haubitze
|
||||
|
||||
sed
|
||||
pha
|
||||
lsr
|
||||
@@ -155,3 +161,25 @@ printf_printhexbyte:
|
||||
adc #$30
|
||||
cld
|
||||
jmp JCHROUT
|
||||
|
||||
#else
|
||||
|
||||
pha
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
ora #$30
|
||||
cmp #$3A
|
||||
bcc !+
|
||||
adc #6
|
||||
!: jsr JCHROUT
|
||||
pla
|
||||
and #$0f
|
||||
ora #$30
|
||||
cmp #$3A
|
||||
bcc !+
|
||||
adc #6
|
||||
!: jmp JCHROUT
|
||||
|
||||
#endif
|
||||
@@ -5,9 +5,10 @@
|
||||
reset_entry:
|
||||
|
||||
// The GPL program at https://github.com/Klaus2m5/6502_65C02_functional_tests/blob/master/6502_functional_test.a65
|
||||
// uses the following initial reset sequence
|
||||
// affirmed by c64 PRG p269
|
||||
cld
|
||||
// uses the following initial reset sequence, affirmed by c64 PRG p269
|
||||
#if !HAS_BCD_SAFE_RESET
|
||||
cld // for CPUs having undefined D flag after reset
|
||||
#endif
|
||||
ldx #$FF
|
||||
txs
|
||||
sei
|
||||
|
||||
Reference in new issue
Block a user