small 65C02 optimizations in many places
This commit is contained in:
1 parent
3e5c80bbf1
commit
ce8c84a20c
22 files changed
+103
-159
No files matched your search
@@ -51,7 +51,7 @@ Choose if your CPU supports the Western Design Center 65C02 instruction set, lik
|
||||
* CSG 65CE02
|
||||
* CSG 4510 - used in the Commodore 65 prototypes
|
||||
|
||||
It enables some speed/size code optimizations. Warning - this is untested!
|
||||
It enables some speed/size code optimizations.
|
||||
|
||||
### `CONFIG_CPU_WDC_65816`
|
||||
|
||||
@@ -60,7 +60,7 @@ Choose if your CPU supports the 16-bit Western Design Center 65816 instruction s
|
||||
* WDC 65C816 - used in the Flash 8 accelerator
|
||||
* WDC 65C816S - used in the SuperCPU accelerator
|
||||
|
||||
It enables some speed/size code optimizations. Warning - this is untested!
|
||||
It enables some speed/size code optimizations.
|
||||
|
||||
## Memory model
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
|
||||
//
|
||||
// Provide pseudocommands to make CPU optimizations easier
|
||||
//
|
||||
|
||||
|
||||
.pseudocommand _phx
|
||||
{
|
||||
#if CONFIG_CPU_WDC_65C02 || CONFIG_CPU_WDC_65816
|
||||
phx
|
||||
#else
|
||||
txa
|
||||
pha
|
||||
#endif
|
||||
}
|
||||
|
||||
.pseudocommand _phy
|
||||
{
|
||||
#if CONFIG_CPU_WDC_65C02 || CONFIG_CPU_WDC_65816
|
||||
phy
|
||||
#else
|
||||
tya
|
||||
pha
|
||||
#endif
|
||||
}
|
||||
|
||||
.pseudocommand _plx
|
||||
{
|
||||
#if CONFIG_CPU_WDC_65C02 || CONFIG_CPU_WDC_65816
|
||||
plx
|
||||
#else
|
||||
pla
|
||||
tax
|
||||
#endif
|
||||
}
|
||||
|
||||
.pseudocommand _ply
|
||||
{
|
||||
#if CONFIG_CPU_WDC_65C02 || CONFIG_CPU_WDC_65816
|
||||
ply
|
||||
#else
|
||||
pla
|
||||
tay
|
||||
#endif
|
||||
}
|
||||
@@ -7,9 +7,8 @@ STROUT:
|
||||
// Setup pointer
|
||||
sty FRESPC+1
|
||||
sta FRESPC+0
|
||||
|
||||
txa
|
||||
pha
|
||||
|
||||
_phx
|
||||
|
||||
// Get offset ready
|
||||
ldy #$00
|
||||
@@ -29,6 +28,6 @@ STROUT:
|
||||
iny
|
||||
bne !-
|
||||
!:
|
||||
pla
|
||||
pla // XXX can we use _plx here?
|
||||
tax
|
||||
rts
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
basic_do_error:
|
||||
// Save error number
|
||||
txa
|
||||
pha
|
||||
_phx
|
||||
|
||||
// Print ? at start
|
||||
jsr print_return
|
||||
@@ -11,8 +10,7 @@ basic_do_error:
|
||||
jsr JCHROUT
|
||||
|
||||
// Print main part of error message
|
||||
pla
|
||||
tax
|
||||
_plx
|
||||
jsr print_packed_message
|
||||
|
||||
// Print ERROR at end
|
||||
|
||||
+2
-14
@@ -98,15 +98,9 @@ list_not_quote:
|
||||
// Display a token
|
||||
|
||||
// Save registers
|
||||
#if CONFIG_CPU_MOS_6502
|
||||
tax
|
||||
pha
|
||||
tya
|
||||
pha
|
||||
#else
|
||||
phx
|
||||
phy
|
||||
#endif
|
||||
_phy
|
||||
|
||||
// Get pointer to compressed keyword list
|
||||
lda #<packed_keywords
|
||||
@@ -124,13 +118,7 @@ list_not_quote:
|
||||
ldy #$ff
|
||||
jsr packed_word_search
|
||||
|
||||
#if CONFIG_CPU_MOS_6502
|
||||
pla
|
||||
tay
|
||||
#else
|
||||
ply
|
||||
#endif
|
||||
|
||||
_ply
|
||||
pla
|
||||
|
||||
cmp #$8f
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
print_integer:
|
||||
|
||||
pha
|
||||
txa
|
||||
pha
|
||||
_phx
|
||||
|
||||
// Clear temporary output
|
||||
lda #$00
|
||||
|
||||
@@ -32,15 +32,13 @@ packed_message_search:
|
||||
|
||||
found_message_in_token_stream:
|
||||
// Now print each word in the message
|
||||
tya
|
||||
pha
|
||||
_phy
|
||||
lda packed_message_tokens,y
|
||||
cmp #$ff
|
||||
beq !+
|
||||
jsr print_packed_word
|
||||
jsr print_space
|
||||
pla
|
||||
tay
|
||||
_ply
|
||||
iny
|
||||
bne found_message_in_token_stream
|
||||
!:
|
||||
@@ -139,16 +137,14 @@ next_packed_word_char:
|
||||
tax
|
||||
|
||||
// Save Y so it doesn't get clobbered by CHROUT
|
||||
tya
|
||||
pha
|
||||
_phy
|
||||
|
||||
// X=1-14 = first 14 chars, so subtract one
|
||||
lda packed_message_chars-1,x
|
||||
jsr JCHROUT
|
||||
|
||||
// See if there is a char in the low nybl to print
|
||||
pla
|
||||
tay
|
||||
_ply
|
||||
lda (FRESPC),y
|
||||
and #$0f
|
||||
beq end_of_packed_word
|
||||
@@ -158,8 +154,7 @@ next_packed_word_char:
|
||||
has_lo_nybl_char:
|
||||
// We need to print the low nybl char as well
|
||||
tax
|
||||
tya
|
||||
pha
|
||||
_phy
|
||||
|
||||
// Skip lower nybls of $F or $0 in nybl packed
|
||||
// bytes, as these do not encode characters
|
||||
@@ -173,8 +168,7 @@ has_nybl:
|
||||
lda packed_message_chars-1,x
|
||||
jsr JCHROUT
|
||||
!:
|
||||
pla
|
||||
tay
|
||||
_ply
|
||||
// FALLTHROUGH
|
||||
|
||||
no_lo_nybl_char:
|
||||
@@ -204,8 +198,7 @@ next_is_literal_char:
|
||||
unpack_literal_char:
|
||||
// Output the literal char, and ready for next char
|
||||
iny
|
||||
tya
|
||||
pha
|
||||
_phy
|
||||
lda (FRESPC),y
|
||||
jsr JCHROUT
|
||||
pla
|
||||
@@ -222,7 +215,6 @@ is_uncommon_char:
|
||||
|
||||
// We need to print the low nybl char as well
|
||||
tax
|
||||
tya
|
||||
pha
|
||||
_phy
|
||||
|
||||
jmp has_nybl
|
||||
@@ -232,8 +232,7 @@ wedge_dos_clean_exit:
|
||||
wedge_dos_basic_error:
|
||||
pha
|
||||
jsr JCLALL
|
||||
pla
|
||||
tax
|
||||
_plx
|
||||
dex
|
||||
jmp do_basic_error
|
||||
|
||||
|
||||
@@ -14,8 +14,7 @@
|
||||
chkin_real:
|
||||
|
||||
// Store Y for preservation
|
||||
tya
|
||||
pha
|
||||
_phy
|
||||
|
||||
// Reset status
|
||||
jsr kernalstatus_reset
|
||||
@@ -59,6 +58,7 @@ chkin_set_device:
|
||||
// FALLTROUGH
|
||||
|
||||
// Common part for booth CHKIN and CKOUT
|
||||
// XXX add CPU-dependent optimizations here
|
||||
|
||||
chkinout_end:
|
||||
tax
|
||||
|
||||
+5
-10
@@ -44,8 +44,7 @@ chrin_done_fail:
|
||||
chrin_keyboard:
|
||||
|
||||
// Save X
|
||||
txa
|
||||
pha
|
||||
_phx
|
||||
|
||||
chrin_repeat:
|
||||
|
||||
@@ -65,8 +64,7 @@ chrin_repeat:
|
||||
// Return carriage return and clear pending input flag
|
||||
lda #$00
|
||||
sta CRSW
|
||||
pla
|
||||
tax
|
||||
_plx
|
||||
clc
|
||||
lda #$0d
|
||||
rts
|
||||
@@ -74,8 +72,7 @@ chrin_repeat:
|
||||
not_end_of_input:
|
||||
// Return next byte of waiting input and advance index
|
||||
tay
|
||||
pla
|
||||
tax
|
||||
_plx
|
||||
lda (LXSP),y
|
||||
jsr screen_code_to_petscii
|
||||
inc CRSW
|
||||
@@ -126,8 +123,7 @@ read_from_keyboard:
|
||||
sta CRSW
|
||||
// Return first char of line
|
||||
ldy #$00
|
||||
pla
|
||||
tax
|
||||
_plx
|
||||
lda (LXSP),y
|
||||
jsr screen_code_to_petscii
|
||||
clc
|
||||
@@ -137,8 +133,7 @@ empty_line:
|
||||
// For an empty line, just return the carriage return
|
||||
// (and don't forget to actually print the carriage return, so that
|
||||
// the cursor advances and screen scrolls as required)
|
||||
pla
|
||||
tax
|
||||
_plx
|
||||
clc
|
||||
lda #$0d
|
||||
rts
|
||||
|
||||
@@ -12,8 +12,7 @@
|
||||
clall_real:
|
||||
|
||||
// Store .Y register
|
||||
tya
|
||||
pha
|
||||
_phy
|
||||
|
||||
// Original routine probably just sets LDTND to 0, but this is not really safe,
|
||||
// so we actually close all the channels; at least IDE64 does the same for
|
||||
@@ -27,8 +26,7 @@ clall_real:
|
||||
jmp !-
|
||||
!:
|
||||
// Restore .Y register
|
||||
pla
|
||||
tay
|
||||
_ply
|
||||
|
||||
// 'C64 Programmers Reference Guide', page 281, claims it calls CLRCHN too
|
||||
jsr CLRCHN
|
||||
|
||||
@@ -17,15 +17,8 @@ CHROUT:
|
||||
// don't get modified, in agreement with C64 PRG's
|
||||
// description of CHROUT)
|
||||
|
||||
#if CONFIG_CPU_MOS_6502
|
||||
txa
|
||||
pha
|
||||
tya
|
||||
pha
|
||||
#else
|
||||
phx
|
||||
phy
|
||||
#endif
|
||||
_phx
|
||||
_phy
|
||||
|
||||
php
|
||||
|
||||
@@ -52,16 +45,8 @@ chrout_done_fail:
|
||||
plp
|
||||
|
||||
// Restore X and Y
|
||||
|
||||
#if CONFIG_CPU_MOS_6502
|
||||
pla
|
||||
tay
|
||||
pla
|
||||
tax
|
||||
#else
|
||||
ply
|
||||
plx
|
||||
#endif
|
||||
_ply
|
||||
_plx
|
||||
|
||||
sec // indicate failure
|
||||
rts
|
||||
@@ -71,16 +56,8 @@ chrout_done_unknown_device:
|
||||
plp
|
||||
|
||||
// Restore X and Y
|
||||
|
||||
#if CONFIG_CPU_MOS_6502
|
||||
pla
|
||||
tay
|
||||
pla
|
||||
tax
|
||||
#else
|
||||
ply
|
||||
plx
|
||||
#endif
|
||||
_ply
|
||||
_plx
|
||||
|
||||
// End wioth error
|
||||
jmp lvs_device_not_found_error
|
||||
@@ -90,16 +67,8 @@ chrout_done_success:
|
||||
plp
|
||||
|
||||
// Restore X and Y
|
||||
|
||||
#if CONFIG_CPU_MOS_6502
|
||||
pla
|
||||
tay
|
||||
pla
|
||||
tax
|
||||
#else
|
||||
ply
|
||||
plx
|
||||
#endif
|
||||
_ply
|
||||
_plx
|
||||
|
||||
lda SCHAR
|
||||
clc // indicate success
|
||||
|
||||
@@ -14,10 +14,8 @@ iec_return_success:
|
||||
lda #$00
|
||||
sta C3PO
|
||||
// Restore registers
|
||||
pla
|
||||
tay
|
||||
pla
|
||||
tax
|
||||
_ply
|
||||
_plx
|
||||
// Report success
|
||||
clc
|
||||
rts
|
||||
@@ -30,9 +28,7 @@ iec_return_DEVICE_NOT_FOUND:
|
||||
lda #$00
|
||||
sta C3PO
|
||||
// Restore registers
|
||||
pla
|
||||
tay
|
||||
pla
|
||||
tax
|
||||
_ply
|
||||
_plx
|
||||
// Report error
|
||||
jmp kernalerror_DEVICE_NOT_FOUND
|
||||
@@ -7,10 +7,8 @@
|
||||
iec_rx_byte:
|
||||
|
||||
// Store .X and .Y on the stack - preserve them
|
||||
txa
|
||||
pha
|
||||
tya
|
||||
pha
|
||||
_phx
|
||||
_phy
|
||||
|
||||
// Timing is critical here - execute on disabled IRQs
|
||||
// The best practice would be to do PHP first, but it seems this is not
|
||||
|
||||
@@ -5,10 +5,8 @@
|
||||
iec_turnaround_to_listen:
|
||||
|
||||
// Store .X and .Y on the stack - preserve them
|
||||
txa
|
||||
pha
|
||||
tya
|
||||
pha
|
||||
_phx
|
||||
_phy
|
||||
|
||||
// Timing is critical here - execute on disabled IRQs
|
||||
php
|
||||
|
||||
@@ -5,10 +5,8 @@
|
||||
iec_turnaround_to_talk:
|
||||
|
||||
// Store .X and .Y on the stack - preserve them
|
||||
txa
|
||||
pha
|
||||
tya
|
||||
pha
|
||||
_phx
|
||||
_phy
|
||||
|
||||
// Timing is critical here - execute on disabled IRQs
|
||||
php
|
||||
|
||||
@@ -10,10 +10,8 @@
|
||||
iec_tx_byte:
|
||||
|
||||
// Store .X and .Y on the stack - preserve them
|
||||
txa
|
||||
pha
|
||||
tya
|
||||
pha
|
||||
_phx
|
||||
_phy
|
||||
|
||||
// Notify all devices that we are going to send a byte
|
||||
// and it is going to be a data byte (released ATN)
|
||||
|
||||
@@ -10,10 +10,8 @@
|
||||
iec_tx_command:
|
||||
|
||||
// Store .X and .Y on the stack - preserve them
|
||||
txa
|
||||
pha
|
||||
tya
|
||||
pha
|
||||
_phx
|
||||
_phy
|
||||
|
||||
// Notify all devices that we are going to send a byte
|
||||
// and it is going to be a command (pulled ATN)
|
||||
|
||||
@@ -6,10 +6,8 @@
|
||||
iec_tx_command_finalize:
|
||||
|
||||
// Store .X and .Y on the stack - preserve them
|
||||
txa
|
||||
pha
|
||||
tya
|
||||
pha
|
||||
_phx
|
||||
_phy
|
||||
|
||||
// Give device some time to complete command reception, release ATN,
|
||||
// give it some time again before (possible) next command
|
||||
|
||||
@@ -12,15 +12,7 @@ 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
|
||||
_ply
|
||||
_plx
|
||||
pla
|
||||
rti
|
||||
|
||||
@@ -6,15 +6,8 @@ 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
|
||||
_phx
|
||||
_phy
|
||||
|
||||
// XXX: RS-232 support is not implemented
|
||||
|
||||
|
||||
@@ -11,15 +11,8 @@ hw_entry_irq:
|
||||
|
||||
// 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
|
||||
_phx
|
||||
_phy
|
||||
|
||||
#if CONFIG_CPU_MOS_6502 && CONFIG_BCD_SAFE_INTERRUPTS
|
||||
cld // clear decimal flag to allow using it without disabling interrupts
|
||||
|
||||
Reference in new issue
Block a user