
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 stack pointer
; 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
; Select blocks to be erased (R0: EBR1/EBR2)
MOV.W
R0,
@EBR1
; Set EBR1/EBR2
; #RAMSTR is starting destination address to which program is transferred in RAM.
; Set #RAMSTR to even number.
MOV.W
#RAMSTR,
R2
; Starting transfer destination address (RAM)
MOV.W
#ERVADR,
R3
;
ADD.W
R3,
R2
; #RAMSTR + #ERVADR
→ R2
MOV.W
#START,
R3
;
SUB.W
R3,
R2
; Address of data area used in RAM
MOV.B
#H'00,
R1L
: Used to test R1L bit in R0
PRETST:
CMP.B
#H'0C,
R1L
; R1L = H'0C?
BEQ
ERASES
; If finished checking all R0 bits, branch to ERASES
CMP.B
#H'08,
R1L
;
BMI
EBR2PW
; Test EBR1 if R1L
≥ 8, or EBR2 if R1L < 8
MOV.B
R1L,
R1H
;
SUBX
#H'08,
R1H
; R1L – 8
→ R1H
BTST
R1H,
R0H
; Test R1H bit in EBR1 (R0H)
BNE
PREWRT
; If R1H bit in EBR1 (R0H) is 1, branch to PREWRT
BRA
PWADD1
; If R1H bit in EBR1 (R0H) is 0, branch to PWADD1
EBR2PW:
BTST
R1L,
R0L
; Test R1L bit in EBR2 (R0L)
BNE
PREWRT
; If R1L bit in EBR2 (R0H) is 1, branch to PREWRT
PWADD1:
INC
R1L
; R1L + 1
→ R1L
MOV.W
@R2+,
R3
; Dummy-increment R2
BRA
PRETST
;