📄 start.asm
字号:
#set COMPACT 2 ; 24 Bit 16 Bit
#set LARGE 3 ; 24 Bit 24 Bit
#set AUTOMODEL 4 ; works always, might occupy two
; additional bytes
#set MEMMODEL AUTOMODEL ; <<< C-memory model
; The selected memory model should be set in order to fit to the
; model selected for the compiler.
; Note, in this startup version AUTOMODEL will work for all
; C-models. However, if the compiler is configured for SMALL or
; COMPACT, two additional bytes on stack are occupied. If this is not
; acceptable, the above setting should be set to the correct model.
;====================================================================
; 4.3 Function-Call Interface
;====================================================================
#if __REG_PASS__
.REG_PASS
#endif
; Above statement informs Assembler on compatibility of start-up code
; to Function Call Interface as selected for the application. There
; is nothing to configure.
; The Function-Call Interface specifies the method of passing parame-
; ter from function caller to callee. The standard method of FCC907S
; compiler uses "stack argument passing". Alternatively, language
; tools can be configured for "register argument passing".
; For details see the compiler manual.
; This start-up file is compatible to both interfaces.
;====================================================================
; 4.4 Constant Data Handling
;====================================================================
#set ROMCONST 0 ; works only with compiler ROMCONST
#set RAMCONST 1 ; works with BOTH compiler settings
#set AUTOCONST RAMCONST ; works with BOTH compiler settings
#set CONSTDATA AUTOCONST ; <<< set RAM/ROM/AUTOCONST
; - AUTOCONST (default) is a the same as RAMCONST
; - RAMCONST/AUTOCONST should always work, even if compiler is set to
; ROMCONST. If compiler is set to ROMCONST and this startup file is
; set to RAMCONST or AUTOCONST, this startup file will generate an
; empty section CINIT in RAM. However, the code, which copies from
; CONST to CINIT will not have any effect, because size of section 0.
; - It is highly recommended to set the compiler to ROMCONST for
; single-chip mode or internal ROM+ext bus. The start-up file
; should be set to AUTOCONST.
; - ROMCONST setting on systems with full external bus requires exter-
; nal address mapping.
; Single-chip can be emulated by the emulator debugger.
; ROM mirror can also be used with simulator.
;
; see also MIRROR options of external bus settings
;====================================================================
; 4.5 Stack Type and Stack Size
;====================================================================
#set USRSTACK 0 ; user stack: for main program
#set SYSSTACK 1 ; system stack: for main program and interrupts
#set STACKUSE SYSSTACK ; <<< set active stack
#set STACK_RESERVE ON ; <<< reserve stack area in this module
#set STACK_SYS_SIZE 768 ; <<< byte size of System stack
#set STACK_USR_SIZE 2 ; <<< byte size of User stack
#set STACK_FILL ON ; <<< fills the stack area with pattern
#set STACK_PATTERN 0x55AA ; <<< the pattern to write to stack
; - If the active stack is set to SYSSTACK, it is used for main program
; and interrupts. In this case, the user stack could be set to a dummy
; size.
; If the active stack is set to user stack, it is used for the main
; program but the system stack s automatically activated, if an inter-
; rupt is serviced. Both stack areas must have a reasonable size.
; - If STACK_RESERVE is ON, the sections USTACK and SSTACK are reserved
; in this module. Otherwise, they have to be reserved in other modules.
; If STACK_RESERVE is OFF, the size definitions STACK_SYS_SIZE and
; STACK_USR_SIZE have no meaning.
; - Even if they are reverved in other modules, they are still initialised
; in this start-up file.
; - Filling the stack with pattern allows to dynamically check the stack
; area, which had already been used.
;
; - If only system stack is used and SSB is linked to a different bank
; than USB, make sure that all C-modules (which generate far pointers
; to stack data) have "#pragma SSB". Applies only to exclusive confi-
; gurations.
; - Note, several library functions require quite a big stack (due to
; ANSI). Check the stack information files (*.stk) in the LIB\907
; directory.
;====================================================================
; 4.6 General Register Bank
;====================================================================
#set REGBANK 0 ; <<< set default register bank
; set the General Register Bank that is to be used after startup.
; Usually, this is bank 0, which applies to address H'180..H'18F. Set
; in the range from 0 to 31.
; Note: All used register banks have to be reserved (linker options).
#if REGBANK > 31 || REGBANK < 0
# error REGBANK setting out of range
#endif
;====================================================================
; 4.7 Low-Level Library Interface
;====================================================================
#set CLIBINIT OFF ; <<< select extended library usage
; This option has only to be set, if stream-IO/standard-IO function of
; the C-libraray have to be used (printf(), fopen()...). This also
; requires low-level functions to be defined by the application
; software.
; For other library functions like (e.g. sprintf()) all this is not
; necessary. However, several functions consume a large amount of stack.
;====================================================================
; 4.8 Clock Selection
;====================================================================
#set NOCLOCK 0 ; do not touch CKSCR register
#set MAINCLOCK 1 ; select main clock (1/2 external)
#set PLLx1 2 ; set PLL to x1 ext. clock/quartz
#set PLLx2 3 ; set PLL to x2 ext. clock/quartz
#set PLLx3 4 ; set PLL to x3 ext. clock/quartz
#set PLLx4 5 ; set PLL to x4 ext. clock/quartz
; next factors are for specific MCU only
; Check datasheet or header file for presence of register PSCCR. The
; header file (assembler part) must be member in project, so linker
; can find the extended PLL register.
#set PLLx6 6 ; set PLL to x6 ext. clock/quartz
#set PLLx8 7 ; set PLL to x8 ext. clock/quartz
#set CLOCKSPEED PLLx4 ; <<< set PLL ratio
#set CLOCKWAIT ON ; <<< wait for stabilized PLL, if
; PLL is used
#set EXTENDED_PLL ON ; <<< set ON, if PSCCR exists
; The clock is set quiet early. However, if CLOCKWAIT is ON, polling
; for machine clock to be switched to PLL is done at the end of this
; file. Therefore, the stabilization time is not wasted. Main() will
; finally start at correct speed. Resources can immediately be used.
;
; This startup file version does not support subclock.
; Note, for controllers with extended PLL and sub-clock the sub-clock
; divider is set to 4.
#if EXTENDED_PLL == ON
# define PSCCR __psccr
.import PSCCR ; import definition from IO-file
#else
# if CLOCKSPEED > PLLx4
# error: clock > factor 4 requires spec. MCU and EXTENDED__PLL == ON
# endif
#endif
;====================================================================
; 4.9 External Bus Interface
;====================================================================
#set SINGLE_CHIP 0 ; all internal
#set INTROM_EXTBUS 1 ; mask ROM, FLASH, or OTP ROM used
#set EXTROM_EXTBUS 2 ; full external bus (INROM not used)
#set BUSMODE SINGLE_CHIP ; <<< set bus mode (see mode pins)
#set MULTIPLEXED 0 ;
#set NON_MULTIPLEXED 1 ; only if supported by the device
#set ADDRESSMODE MULTIPLEXED ; <<< set address-mode
; Some devices support multiplexed and/or non-multiplexed Bus mode
; please refer to the related datasheet/hardwaremanual
#set ROMMIRROR ON ; <<< ROM mirror function ON/OFF
; MB90500/400/300/800 family only
; In Internal ROM / External Bus mode one can select whether to mirror
; area FF4000..FFFFFF to 004000..00FFFF. This is necessary to get the
; compiler ROMCONST option working. However, if ROMCONST is not used,
; this area might be used to access external memory. This is intended
; to increase performance, if a lot of dynamic data have to be accessed.
; In SMALL and MEDIUM model these data can be accessed within bank 0,
; which allows to use near addressing.
; These controller without the ROMM-control register always have the
; mirror function on in INROM mode.
; If BUSMODE is "SINGLE_CHIP", ignore remaining bus settings.
#set AUTOWAIT_IO 0 ; <<< 0..3 waitstates for IO area
#set AUTOWAIT_LO 0 ; <<< 0..3 for lower external area
#set AUTOWAIT_HI 0 ; <<< 0..3 for higher external area
#set ADDR_PINS B'00000000 ; <<< select used address lines
; A23..A16 to be output.
; This is the value to be set in HACR-register. "1" means: pin used as
; IO-port. (B'10000000 => A23 not used, B'00000001 => A16 not used)
#set BUS_SIGNAL B'00000100 ; <<< enable bus control signals
; |||||||+-- ignored
; ||||||+--- bus width lower memory (0:16, 1:8Bit)
; |||||+---- output WR signal(s) (1: enabled )
; ||||+----- bus width upper memory (0:16, 1:8Bit)
; |||+------ bus width ext IO area (0:16, 1:8Bit)
; ||+------- enable HRQ input (1: enabled )
; |+-------- enable RDY input (1: enabled )
; +--------- output CLK signal (1:enabled )
; These settings correspond to the EPCR-register.
; Hint: Except for MB90500/400/300/800 devices the clock output is
; needed for external RDY synchronisation, if Ready function is used.
; Hint: Don't forget to enable WR signals, if external RAM has to be
; written to.
#set iARSR ((AUTOWAIT_IO<<6)|((AUTOWAIT_HI&3)<<4)|(AUTOWAIT_LO&3))
;====================================================================
; 4.10 Reset Vector
;====================================================================
#set RESET_VECTOR ON ; <<< enable reset vector
#if BUSMODE == SINGLE_CHIP
# set MODEBYTE 0
#else ; external bus
# set MODEBYTE (((BUSMODE&3)<<6) | ((ADDRESSMODE&1)<<4) | ((~BUS_SIGNAL)&8))
#endif
; Above setting can also be used, if all other interrupt vectors are
; specified via "pragma intvect". Only if interrupts 0..7 are specified
; via "pragma intvect", this will conflict with the vector in this
; module. The reason is the INTVECT section, which includes the whole
; area from the lowest to the highest specified vector.
#if RESET_VECTOR == ON
.SECTION RESVECT, CONST, LOCATE=H'FFFFDC
.DATA.E _start
.DATA.B MODEBYTE
#endif
;====================================================================
; 4.11 Enable RAMCODE Copying
;====================================================================
#set COPY_RAMCODE OFF ; <<< enable RAMCODE section to
; be copied from ROM to RAM
; to get this option properly working the code to be executed has to
; be linked to section RAMCODE (e.g. by #pragma section). The section
; RAMCODE has be located in RAM and the section @RAMCODE has to be
; located at a fixed address in ROM by linker settings.
;====================================================================
; 4.12 Enable information stamps in ROM
;====================================================================
#set VERSION_STAMP OFF ; <<< enable version number in
; separated section
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -