404
Notes: 1. In this sample program, the stack pointer (SP) is set at address FF80. As the stack area,
on-chip RAM addresses FF7E and FF7F are used. Therefore, when executing this
sample program, addresses FF7E and FF7F should not be used. In addition, the on-chip
RAM should not be disabled.
2. In this sample program, the program written in a ROM area (including external space)
is transferred into the RAM area and executed in the RAM to which the program is
transferred. #RAMSTR in the program is the starting destination address in RAM to
which the program is transferred. #RAMSTR must be set to an even number.
3. When executing this sample program in the on-chip ROM area or external space,
#RAMSTR should be set to #START.
FLMCR: .RQU H'FF80
EBR1: .EQU H'FF82
EBR2: .EQU H'FF83
TCSR: .EQU H'FFA8
STACK: .EQU H'FF80
.ALIGN2
START: MOV.W #STACK, SP
; Set the bits in R0 following the description on the previous page. This program is a sample program to
; erase all blocks.
MOV.W #H'0FFF, R0
MOV.W R0, @EBR1
; Set stack pointer
; Select blocks to be erased (R0: EBR1/EBR2)
; Set EBR1/EBR2
; #RAMSTR is starting destination address to which program is transferred in RAM.
; Set #RAMSTR to even number.
MOV.W #RAMSTR, R2
MOV.W #ERVADR, R3
ADD.W R3, R2
MOV.W #START, R3
SUB.W R3, R2
; Starting transfer destination address (RAM)
;
; #RAMSTR + #ERVADR
→
R2
;
; Address of data area used in RAM
MOV.B #H'00, R1L
PRETST: CMP.B #H'0C, R1L
BEQ ERASES
CMP.B #H'08, R1L
BMI EBR2PW
MOV.B R1L, R1H
SUBX #H'08, R1H
BTST R1H, R0H
BNE PREWRT
BRA PWADD1
EBR2PW: BTST R1L, R0L
BNE PREWRT
PWADD1: INC R1L
MOV.W @R2+, R3
BRA PRETST
: Used to test R1L bit in R0
; R1L = H'0C
; If finished checking all R0 bits, branch to ERASES
;
; Test EBR1 if R1L
≥
8, or EBR2 if R1L < 8
;
; R1L – 8
→
R1H
; Test R1H bit in EBR1 (R0H)
; If R1H bit in EBR1 (R0H) is 1, branch to PREWRT
; If R1H bit in EBR1 (R0H) is 0, branch to PWADD1
; Test R1L bit in EBR2 (R0L)
; If R1L bit in EBR2 (R0H) is 1, branch to PREWRT
; R1L + 1
→
R1L
; Dummy-increment R2
;