I've updated the UPD_STL routine and it's now 21 bytes in size, a savings of 5 bytes.
Code:
UPD_STL INC SRCL ;Increment source low byte
BNE UPD_TL ;Check for rollover
INC SRCH ;Increment source high byte
UPD_TL INC TGTL ;Increment target low byte
BNE DECLEN ;Check for rollover
INC TGTH ;Increment target high byte
;
;DECLEN subroutine: decrement 16-bit variable LENL/LENH
DECLEN LDA LENL ;Get length low byte
BNE SKP_LENH ;Test for LENL = zero
DEC LENH ;Else decrement length high byte
SKP_LENH DEC LENL ;Decrement length low byte
RTS ;Return to caller
The memory move and memory fill routines have the stayed the same at 15 bytes each. I rewrote the compare routine so it handles the EEPROM writing based on a flag setting. It no longer requires the JSR/RTS to the error routine which prints the failed address. This resulted in the compare routine being 9 bytes larger.
Code:
COMPLP LDA LENL ;Get low byte of length
ORA LENH ;OR in High byte of length
BEQ QUITMV ;If zero, nothing to write
BIT TEMP2 ;Check for EEPROM programming
BPL SKP_BURN ;If bit 7 not set, skip it
JSR BURN_BYTE ;Else Burn a byte to EEPROM
SKP_BURN LDA (SRCL) ;Else load source
CMP (TGTL) ;Compare to source
BEQ CMP_OK ;If compare is good, continue
;
LDA TEMP2 ;Get EEPROM flag
ORA #$40 ;Get bit 6 mask for error
STA TEMP2 ;Store to flag to show error in EEPROM write
JSR SPC2 ;Send 2 spaces
JSR DOLLAR ;Print $ sign
LDA TGTH ;Get high byte of address
LDY TGTL ;Get Low byte of address
JSR PRWORD ;Print word
JSR SPC ;Add 1 space for formatting
;
CMP_OK JSR UPD_STL ;Update pointers
BRA COMPLP ;Loop back until done
The EEPROM write routine was rewritten to simply set the flag, call the compare routine and check the flag for an error on return to print the appropriate message before exiting. This saved 20 bytes of code.
Code:
PROG LDA #$80 ;Get EEPROM write active mask
STA TEMP2 ;Set flag for COMPLP routine
JSR COMPLP ;Call routine to write/compare
;
BIT TEMP2 ;Check for error bit in flag
BVC PRG_GOOD ;Branch if no errors
;
LDA #$26 ;Get Prog failed message
BRA BRA_PRMPT ;Branch to Prompt routine
;
PRG_GOOD LDA #$25 ;Get completed message
JSR PROMPT ;Send to console and exit
LDA #$27 ;Get warning message for RTC and Reset
BRA_PRMPT JMP PROMPT ;Send to console and exit
Since starting this thread, between the core routines here plus two others which increment and decrement another 16-bit pointer, I've reduced code by 27 bytes. I'm still looking at some other options and can likely save a few more bytes by putting the length check for zero in the UPD_STL routine, but it needs to check on entry and confirm on exit to work with the existing routines.