📄 ncrt0.a30
字号:
;*******************************************************************************
;
; C COMPILER for M16C/80
; Copyright 1999 MITSUBISHI ELECTRIC CORPORATION
; AND MITSUBISHI ELECTRIC SEMICONDUCTOR APPLICATION ENGINEERING CORPORATION
; All Rights Reserved.
;
; ncrt0.a30 : NC308 startup program
;
; This program is applicable when using the basic I/O library
;
; $Id: ncrt0.a30,v 1.17 2002/06/18 10:08:54 muramatu Exp $
;
;*******************************************************************************
;---------------------------------------------------------------------
; HEEP SIZE definition
;---------------------------------------------------------------------
;HEAPSIZE .equ 300h
;---------------------------------------------------------------------
; STACK SIZE definition
;---------------------------------------------------------------------
STACKSIZE .equ 1000h
;---------------------------------------------------------------------
; INTERRUPT STACK SIZE definition
;---------------------------------------------------------------------
ISTACKSIZE .equ 400h
;---------------------------------------------------------------------
; INTERRUPT VECTOR ADDRESS definition
;---------------------------------------------------------------------
VECTOR_ADR .equ 0fffd00h
;---------------------------------------------------------------
; special page definition
;---------------------------------------------------------------
; macro define for special page
;
;Format:
; SPECIAL number
;
SPECIAL .macro NUM
.org 0FFFFFEH-(NUM*2)
.glb __SPECIAL_@NUM
.word __SPECIAL_@NUM & 0FFFFH
.endm
;---------------------------------------------------------------------
; Section allocation
;---------------------------------------------------------------------
.list OFF
.include sect308.inc
.list ON
;---------------------------------------------------------------------
; SBDATA area definition
;---------------------------------------------------------------------
.glb __SB__
__SB__ .equ data_SE_top
;====================================================================
; Initialize Macro declaration
;---------------------------------------------------------------------
;
; when copy less 64K byte
BZERO .macro TOP_ ,SECT_
mov.b #00H, R0L
mov.l #TOP_, A1
mov.w #sizeof SECT_ , R3
sstr.b
.endm
BCOPY .macro FROM_,TO_,SECT_
mov.l #FROM_ ,A0
mov.l #TO_ ,A1
mov.w #sizeof SECT_ , R3
smovf.b
.endm
; when copy over 64K byte
BZEROL .macro TOP_,SECT_
push.w #sizeof SECT_ >> 16
push.w #sizeof SECT_ & 0ffffh
pusha TOP_
.stk 8
.glb _bzero
.call _bzero,G
jsr.a _bzero
.endm
BCOPYL .macro FROM_ ,TO_ ,SECT_
push.w #sizeof SECT_ >> 16
push.w #sizeof SECT_ & 0ffffh
pusha TO_
pusha FROM_
.stk 12
.glb _bcopy
.call _bcopy,G
jsr.a _bcopy
.endm
;====================================================================
; Interrupt section start
;---------------------------------------------------------------------
.insf start,S,0
.glb start
.section interrupt
start:
;---------------------------------------------------------------------
; after reset,this program will start
;---------------------------------------------------------------------
ldc #istack_top, isp ;set istack pointer
mov.b #02h,0ah
mov.b #03h,04h ;set processer mode register 1 :microprocesser mode (by default)
mov.b #02h,05h ;set processer mode register 2 :mode 3
mov.b #00h,0ah
mov.b #09h,0bh; ;Both CS0 and CS1 are16-bit
mov.b #0a6h,08h ;set Wait control mode
;set main clock division
; 00 --- 16
; 0e --- 14
; 0c --- 12
; 0a --- 10
; 08 --- 8
; 06 --- 6
; 04 --- 4
; 02 --- 2
; 12 --- 1
mov.b #01h,0ah
mov.b #12h,0ch ; main clock division register
mov.b #0h,0ah
ldc #0080h, flg ;set U flag (User stack pointer)
ldc #stack_top, sp ;set stack pointer
ldc #data_SE_top, sb ;set sb register
fset b ;switch to bank 1
ldc #data_SE_top, sb ;set sb register
fclr b ;switch to bank 0
ldc #VECTOR_ADR,intb
;====================================================================
; NEAR area initialize.
;--------------------------------------------------------------------
; bss zero clear
;--------------------------------------------------------------------
BZERO bss_SE_top,bss_SE
BZERO bss_SO_top,bss_SO
BZERO bss_NE_top,bss_NE
BZERO bss_NO_top,bss_NO
;---------------------------------------------------------------------
; initialize data section
;---------------------------------------------------------------------
BCOPY data_SEI_top,data_SE_top,data_SE
BCOPY data_SOI_top,data_SO_top,data_SO
BCOPY data_NEI_top,data_NE_top,data_NE
BCOPY data_NOI_top,data_NO_top,data_NO
;====================================================================
; FAR area initialize.
;---------------------------------------------------------------------
; bss zero clear
;---------------------------------------------------------------------
BZERO bss_SE_top,bss_SE
BZERO bss_SO_top,bss_SO
; BZERO bss_6E_top,bss_6E
; BZERO bss_6O_top,bss_6O
; BZERO bss_FE_top,bss_FE
; BZERO bss_FO_top,bss_FO
;---------------------------------------------------------------------
; Copy edata_E(O) section from edata_EI(OI) section
;---------------------------------------------------------------------
BCOPY data_SEI_top,data_SE_top,data_SE
BCOPY data_SOI_top,data_SO_top,data_SO
; BCOPY data_6EI_top,data_6E_top,data_6E
; BCOPY data_6OI_top,data_6O_top,data_6O
BCOPY data_FEI_top,data_FE_top,data_FE
BCOPY data_FOI_top,data_FO_top,data_FO
ldc #stack_top,sp
; .stk -?? ; Validate this when use BZEROL,BCOPYL
;====================================================================
; heap area initialize
;---------------------------------------------------------------------
;.if __HEAP__ != 1
; .glb __mbase
; .glb __mnext
; .glb __msize
; mov.l #(heap_top&0FFFFFFH), __mbase
; mov.l #(heap_top&0FFFFFFH), __mnext
; mov.l #(HEAPSIZE&0FFFFFFH), __msize
;.endif
;====================================================================
; Initialize standard I/O
;---------------------------------------------------------------------
;.if __STANDARD_IO__ != 1 ; debug 2003.1.10
; .glb _init
; .call _init,G
; jsr.a _init
;.endif
;====================================================================
; Call main() function
;---------------------------------------------------------------------
ldc #0h,fb ; for debuger
.glb _main
jsr.a _main
;====================================================================
; exit() function
;---------------------------------------------------------------------
.glb _exit
.glb $exit
_exit: ; End program
$exit:
jmp _exit
.einsf
;====================================================================
; dummy interrupt function
;---------------------------------------------------------------------
dummy_int:
reit
.end
;*******************************************************************************
;
; C COMPILER for M16C/80
; Copyright 1999 MITSUBISHI ELECTRIC CORPORATION
; AND MITSUBISHI ELECTRIC SEMICONDUCTOR APPLICATION ENGINEERING CORPORATION
; All Rights Reserved.
;
;*******************************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -