📄 start8fx.asm
字号:
;;====================================================================
; MB95100 Series C Compiler,
; (C) FUJITSU MICROELECTRONICS EUROPE
;
; Startup file for memory and basic controller initialisation
;=====================================================================
.PROGRAM start
.TITLE start
;--------------------------------------------------------------------------
;====================================================================
; 1 Contents
;====================================================================
;
; 1 Contents
; 2 Disclaimer
; 3 History
; 4 Settings
; 4.1 Modbyte
; 4.2 Clock Mode Selection
; 4.3 Main-PLL Clock Selection
; 4.4 Sub-PLL Clock Selection
; 4.5 DIV Clock Selection (Machine clock division ratio)
; 4.6 Stack Size
; 4.7 Flash Security
; 5 Section and Data Declaration
; 5.1 Several fixed addresses
; 5.2 External declaration of symbols
; 5.3 Definition to stack area
; 5.4 Definition to start address of data, const and code section
; 5.5 Define Reset vector and Modebyte
; 5.6 Flash Security section
; 6 Start-Up Code
; 6.1 Set stack pointer
; 6.2 Set register bank, direct bank pointer and I flag
; 6.3 Set ILM to the lowest level(3)
; 6.4 Set PLL (PLCC)
; 6.5 Set System Clock (SYCC)
; 6.6 Copy initial value *CONST(ROM) section to *INIT(RAM) section
; 6.7 Zero clear of *VAR section
; 6.8 call main routine
;
;====================================================================
; 2 Disclaimer
;====================================================================
; FUJITSU MICROELECTRONICS EUROPE GMBH
; Am Siebenstein 6-10, 63303 Dreieich
; Tel.:++49/6103/690-0,Fax - 122
;
; The following software is for demonstration purposes only.
; It is not fully tested, nor validated in order to fullfill
; its task under all circumstances. Therefore, this software
; or any part of it must only be used in an evaluation
; laboratory environment.
; This software is subject to the rules of our standard
; DISCLAIMER, that is delivered with our SW-tools on the CD
; "Micros Documentation & Software" (V3.0 see "\START.HTM") or
; see our Internet Page -
; http://www.fme.fujitsu
;
;====================================================================
; 3 History
;====================================================================
;
; Version 1.00 12 Oct 04 H. Wech
; - Created for Softune Workbench V30L29
;
;====================================================================
; 4 Settings
;====================================================================
; CHECK ALL OPTIONS WHETHER THEY FIT TO THE APPLICATION;
;
; Configure this startup file in the "Settings" section. Search for
; comments with leading "; <<<". This points to the items to be set.
;
#set OFF 0
#set ON 1
;
;
;====================================================================
; 4.1 Modbyte
;====================================================================
# set SINGLE_CHIP 0 ; single chip mode, no external bus interface
# set EXTERNAL_BUS 1 ; external bus interface
;
# set MODEBYTE SINGLE_CHIP ; <<< set modebyte
;
; The Mode Byte defines whether an external bus interface is available or not.
; it is read after the reset vector. Please have a look at the Hardware manual
; of the used microcontroller for further information on that topic
;
;
;====================================================================
; 4.2 Clock Mode Selection
;====================================================================
# set SUB 0 ; Sub clock mode
# set SUB_PLL 1 ; Sub PLL clock mode
# set MAIN 2 ; Main clock mode
# set MAIN_PLL 3 ; Main PLL mode
# set NOCLOCK FF ; Do not touch the clock and PLL register
;
#set CLOCKMODE MAIN_PLL ; <<< Clock seletion
;
;
;====================================================================
; 4.3 Main-PLL Clock Selection
;====================================================================
# set MAINPLL_OFF 0 ; No Main-clock setting
# set MAINPLLx1 1 ; Original oscillator clock x1
# set MAINPLLx2 2 ; Original oscillator clock x2
# set MAINPLLx2p5 3 ; Original oscillator clock x2.5
;
#set CLOCKSPEED MAINPLLx2p5 ; <<< set PLL speed
;
;
;====================================================================
; 4.5 Sub-PLL Clock Selection
;====================================================================
# set SUBPLL_OFF 0 ; No Sub-clock setting
# set SUBPLLx2 1 ; Original oscillator clock x2
# set SUBPLLx3 2 ; Original oscillator clock x3
# set SUBPLLx4 3 ; Original oscillator clock x4
;
#set SUBCLOCKSPEED SUBPLL_OFF ; <<< set Sub-clock PLL speed
;
;
;====================================================================
; 4.5 DIV Clock Selection (Machine clock division ratio)
;====================================================================
# set CLK_0 0 ; Original oscillator div 1
# set CLK_4 1 ; Original oscillator div 4
# set CLK_8 2 ; Original oscillator div 8
# set CLK_16 3 ; Original oscillator div 16
;
#set CLOCKDIV CLK_0 ; <<< set DIV clock ratio
;
;
;====================================================================
; 4.6 Stack Size
;====================================================================
;
# set STACKSIZE 64 ; <<< Stack size
;
;
;====================================================================
; 4.7 Flash Security
;====================================================================
;
# set FLASHSECURITY OFF ; <<< Define Flash Security (ON / OFF)
;
;
; <<< END OF SETTINGS >>>
;
;
;====================================================================
; 5 Section and Data Declaration
;====================================================================
;====================================================================
; 5.1 Several fixed addresses
;====================================================================
PLLC .EQU 0x06 ; PLL register
SYCC .EQU 0x07 ; Clock select control register
;
;
;====================================================================
; 5.2 External declaration of symbols
;====================================================================
.EXPORT __start
.IMPORT _main
.IMPORT _SetClockMainToPll
.IMPORT LMEMTOMEM
.IMPORT LMEMCLEAR
.IMPORT _RAM_INIT
.IMPORT _ROM_INIT
.IMPORT _RAM_DIRINIT
.IMPORT _ROM_DIRINIT
;--------------------------------------------------------------------------
; 5.3 Definition to stack area
;--------------------------------------------------------------------------
.SECTION STACK, STACK, ALIGN=1
.RES.B STACKSIZE
STACK_TOP:
.RES.B 2
;--------------------------------------------------------------------------
; 5.4 Definition to start address of data, const and code section
;--------------------------------------------------------------------------
.SECTION DIRDATA, DIR, ALIGN=1
DIRDATA_S:
.SECTION DIRINIT, DIR, ALIGN=1
DIRINIT_S:
.SECTION DATA, DATA, ALIGN=2
DATA_S:
.SECTION INIT, DATA, ALIGN=2
INIT_S:
;-----------------------------------------------------------
; 5.5 Define Reset vector and Modebyte
;-----------------------------------------------------------
; The Mode Byte is defined at the beginning of the start.asm
.SECTION RESVECT, CONST, LOCATE=H'FFFD
.DATA.B MODEBYTE
.DATA.W __start
;-----------------------------------------------------------
; 5.6 Flash Security
;-----------------------------------------------------------
; The Flash of MB95Fxxx can be secured
.SECTION SECURITY, CONST, LOCATE=H'4000
#if FLASHSECURITY == ON
.DATA.B 0x01
#else
.DATA.B 0xFF
#endif
;
;
;====================================================================
; 6 Start-Up Code
;====================================================================
;
;
;====================================================================
; ___ _____ __ ___ _____
; / | / \ | \ |
; \___ | | | |___/ |
; \ | |----| | \ |
; ___/ | | | | \ | Begin of actual code section
;====================================================================
.SECTION CODE, CODE, ALIGN=1
__start:
;
;
;--------------------------------------------------------------------------
; 6.1 Set stack pointer
;--------------------------------------------------------------------------
MOVW A, #STACK_TOP
MOVW SP, A
;
;
;--------------------------------------------------------------------------
; 6.2 Set Register bank Pointer 0 / set Direct bank Pointer 0 (0x80..0xFF)
;--------------------------------------------------------------------------
;
MOVW A, PS
MOVW A, #0x00BF ; RP=0, DP=0, I=0
ANDW A
MOVW PS, A
;
;--------------------------------------------------------------------------
; 6.3 Set ILM to the lowest level(3)
;--------------------------------------------------------------------------
;
MOVW A, PS
MOVW A, #0x0030
ORW A
MOVW PS, A
;
;--------------------------------------------------------------------------
; 6.4 Set PLL
;--------------------------------------------------------------------------
;
; Set Main-PLL clock
;
# if CLOCKMODE != NOCLOCK
SETB PLLC:4 ; set PLL stable for simulation
# if CLOCKSPEED == MAINPLLx1
CLRB PLLC:5
CLRB PLLC:6
SETB PLLC:7 ; Main PLL enable
#endif
# if CLOCKSPEED == MAINPLLx2
SETB PLLC:5
CLRB PLLC:6
SETB PLLC:7 ; Main PLL enable
#endif
# if CLOCKSPEED == MAINPLLx2p5
CLRB PLLC:5
SETB PLLC:6
SETB PLLC:7 ; Main PLL enable
#endif
;
; Set Sub-PLL clock
;
# if SUBCLOCKSPEED == SUBPLLx2
SETB PLLC:1
CLRB PLLC:2
SETB PLLC:3
#endif
# if SUBCLOCKSPEED == SUBPLLx3
CLRB PLLC:1
SETB PLLC:2
SETB PLLC:3
#endif
# if SUBCLOCKSPEED == SUBPLLx4
SETB PLLC:1
SETB PLLC:2
SETB PLLC:3
#endif
# if ( (CLOCKMODE == MAIN_PLL) && (CLOCKSPEED != MAINPLL_OFF) )
WAITMAINPLL:
MOV A,PLLC ; Waiting Main-PLL stabilization
AND A,#0x10
BNZ SETCLK
JMP WAITMAINPLL
# elif ( (CLOCKMODE == SUB_PLL) && (SUBCLOCKSPEED != SUBPLL_OFF) )
WAITSUBPLL:
MOV A,PLLC ; Waiting Sub-PLL stabilization
AND A,#0x01
BNZ SETCLK
JMP WAITSUBPLL
# endif
#endif
;
;--------------------------------------------------------------------------
; 6.5 Set System Clock
;--------------------------------------------------------------------------
;
SETCLK:
# if CLOCKMODE != NOCLOCK
MOV SYCC,#(CLOCKMODE<<4 + CLOCKDIV)
# endif
;
;
;--------------------------------------------------------------------------
; 6.6 Copy initial value *CONST(ROM) section to *INIT(RAM) section
;--------------------------------------------------------------------------
;
#macro ICOPY src_addr, dest_addr, src_segment
MOVW EP, #\src_addr
MOVW A, #\dest_addr
MOVW A, #SIZEOF (\src_segment)
CALL LMEMTOMEM
#endm
ICOPY _ROM_INIT, _RAM_INIT, INIT
ICOPY _ROM_DIRINIT, _RAM_DIRINIT, DIRINIT
;
;--------------------------------------------------------------------------
; 6.7 Zero clear of *VAR section
;--------------------------------------------------------------------------
;
#macro FILL0 src_addr, src_segment
MOVW A, #\src_addr
MOVW A, #SIZEOF (\src_segment)
CALL LMEMCLEAR
#endm
FILL0 DIRDATA_S, DIRDATA
FILL0 DATA_S, DATA;
;
;
;--------------------------------------------------------------------------
; 6.8 call main routine
;--------------------------------------------------------------------------
CALL _main
end: JMP end
.END __start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -