⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 start.asm

📁 单片机
💻 ASM
字号:
/* THIS SAMPLE CODE IS PROVIDED AS IS AND IS SUBJECT TO ALTERATIONS. FUJITSU  */
/* MICROELECTRONICS ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR  */
/* ELIGIBILITY FOR ANY PURPOSES.                                              */
/*                 (C) Fujitsu Microelectronics Europe GmbH                   */
/*----------------------------------------------------------------------------*/

;*******************************************************************************
;   FFMC-8L Family Sample program for initialization                           *
;*******************************************************************************
;
;
; History
; Date         Rev    Author  Description
; 22.10.98     0.1    TKa     Created for Softune Workbench V03
; 13.04.99     0.2    TKa     Reset Vector and mode byte added
; 22.07.99     0.3    TKa     Allignment =1 added for section definitions
;                             and DATA, DIRDATA section clear function call 
;                             modified -> now independent from linkage order
; 13.08.99     0.4    TKa     Initialization of RP in PS register added, 
;                             disable interrupts
;*******************************************************************************
 
        .PROGRAM  init
        .TITLE    init

;===============================================================================
;    Settings
;===============================================================================
; 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
;===============================================================================

#  set    MODEBYTE 0 ; 0 is used for single chip mode, no external bus interface
                     ; 1 is used for external bus interface
                                   
;-------------------------------------------------------------------------------
; Symbol definition for zero data area
;-------------------------------------------------------------------------------

        .section  DATA, DATA, ALIGN=1   ; zero clear area
        .section  DIRDATA, DIR, ALIGN=1 ; zero clear area

;-------------------------------------------------------------------------------
; Symbol definition for initial value area
;-------------------------------------------------------------------------------
; For copying the initial data from the INIT and DIRINIT section, it is 
; necessary to define a @INIT and a @DIRINIT section of type const in the ROM  
; area. Otherwise an error message is output. Therfore use the section setting 
; in the Linker options Disposition/Connection
;-------------------------------------------------------------------------------

        .section  INIT, DATA, ALIGN=1   ; initialized area
                                        
        .section  DIRINIT, DIR, ALIGN=1 ; initialized DIR area
                                        
        .section  CONST, CONST, ALIGN=1 ;

;-------------------------------------------------------------------------------
; Code area, CPU register initialization
;-------------------------------------------------------------------------------

        .section  CODE, CODE
        .EXPORT   end
        .IMPORT   _main
        .IMPORT   LMEMTOMEM
        .IMPORT   LMEMCLEAR

;-------------------------------------------------------------------------------
; 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
  
;-------------------------------------------------------------------------------
; Definition of stack area and stack top 
;-------------------------------------------------------------------------------

        .section STACK, STACK
        .RES.B 48
STACK_TOP:

;===============================================================================
;   ___  _____   __    ___  _____
;  /       |    /  \  |   \   |                  
;  \___    |   |    | |___/   |   
;      \   |   |----| |  \    |   
;   ___/   |   |    | |   \   |      Begin of actual code section
;===============================================================================

          .SECTION  CODE_START, CODE, ALIGN=1
          .IMPORT   _main                            ; user code entrance

;===============================================================================
; "NOT RESET YET" WARNING
;===============================================================================

notresetyet:
          NOP  ; read hint below!!!!!!!
          
; If the debugger stays at the NOP above, the controller has not been
; reset yet. In order to reset all hardware register it is highly re-
; commended to reset the controller.
; However, if no reset vector has been defined on purpose, this dummy
; start address can also be used.
; This mechanism is using the .END instruction at the end of this mo-
; dule. It is not necessary for controller operation but improves 
; security during debugging (mainly emulator debugger).

;===============================================================================
; Program start address the reset vector should point here
;===============================================================================

_start:

;-------------------------------------------------------------------------------
; Set Register Pointer RP to 0, disable interrupts, clear flags
;-------------------------------------------------------------------------------

          MOVW  A, #H'0030
          MOVW  PS, A

;-------------------------------------------------------------------------------
; Set Stack Pointer 
;-------------------------------------------------------------------------------

          MOVW  A, #STACK_TOP    ; Stack top
          MOVW  SP, A

;-------------------------------------------------------------------------------
; Copy from initial value area to data area
; _ROM_INIT    -> _RAM_INIT   ; _ROM_INIT generated by linker option @INIT/ROM
; _ROM_DIRINIT -> _RAM_DIRINIT; _ROM_DIRINIT generated by linker option @DIRINIT/ROM
;-------------------------------------------------------------------------------

          .IMPORT _RAM_INIT
          .IMPORT _ROM_INIT
          .IMPORT _RAM_DIRINIT
          .IMPORT _ROM_DIRINIT
          
          MOVW  A, #_RAM_INIT
          MOVW  A, #SIZEOF(INIT)
          MOVW  EP, #_ROM_INIT
          CALL  LMEMTOMEM

          MOVW  A, #_RAM_DIRINIT
          MOVW  A, #SIZEOF(DIRINIT)
          MOVW  EP, #_ROM_DIRINIT
          CALL  LMEMTOMEM

;-------------------------------------------------------------------------------
; Clear data area to zero
; Clear DATA
; Clear DIRDATA
;-------------------------------------------------------------------------------

          MOVW  A, #DATA
          MOVW  A, #SIZEOF(DATA)
          CALL  LMEMCLEAR

          MOVW  A, #DIRDATA
          MOVW  A, #SIZEOF(DIRDATA)
          CALL  LMEMCLEAR

;-------------------------------------------------------------------------------
; Call user function
;-------------------------------------------------------------------------------

          CALL  _main   ; Start main function

end:      
          JMP end       ; Loop
          
          .END notresetyet
        

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -