I am using this in a JM60 project, its an adaptation to the Mini-RAM routines posted in this forum.
const unsigned char ROM_PGM[7] = { 0xf7, // sta ,X FSTAT 0x44, // lsra - delay and convert to FCCF bit0xf5, // Bit X ,fstat0xf5, // Bit X ,fstat0x27,0xfd, // BEQ *-10x81 // RTS}; volatile unsigned char PGM[7] = { 0xf7, // sta ,X FSTAT 0x44, // lsra - delay and convert to FCCF bit0xf5, // Bit X ,fstat0xf5, // Bit X ,fstat0x27,0xfd, // BEQ *-10x81 // RTS}; void InitFlashRoutine(void) // match number of bytes above. { PGM[0] = ROM_PGM[0]; PGM[1] = ROM_PGM[1]; PGM[2] = ROM_PGM[2]; PGM[3] = ROM_PGM[3]; PGM[4] = ROM_PGM[4]; PGM[5] = ROM_PGM[5]; PGM[6] = ROM_PGM[6]; }byte FlashErasePage(word page) { asm { TPA ; Get status to A PSHA ; Save current status SEI ; Disable interrupts LDA #0x30 STA FSTAT ; Clear FACCERR & FPVIOL flags LDHX page STA ,X ; Save the data LDA #$40 ; Erase command STA FCMD LDA #FSTAT_FCBEF_MASK LDHX @FSTAT JSR PGM PULA ; Restore previous status TAP } return (FSTAT & 0x30); }byte FlashProgramByte(word address, byte data) { asm{ TPA PSHA ; Save current status SEI ; Disable interrupts LDA #0x30 STA FSTAT ; Clear FACCERR & FPVIOL flags LDHX address LDA data STA ,X ; Save the data LDA #$20 ; Burn command STA FCMD LDA #FSTAT_FCBEF_MASK LDHX @FSTAT JSR PGM PULA ; Restore previous status TAP } return (FSTAT & 0x30); }