The default init function is the bootstrap or glue code that sets up the DSP56800E environment before your code executes. This function is in the init file for each board-specific stationery project. The routines defined in the init file performs other tasks such as clearing the hardware stack, creating an interrupt table, and retrieving the stack start and exception handler addresses.
The final task performed by the init function is to call the main() function.
The starting point for a program is set in the Entry Point field in the DSC Linker > Input settings panel.
The project for the DSP56800E runtime is: CodeWarrior\M56800E Support\runtime_56800E\projects\Runtime 56800E.mcp
| Library Name | Location |
|---|---|
| Large Memory Model Runtime 56800E lmm.lib |
CodeWarrior\M56800E Support\runtime_56800E\lib |
| Small Memory Model Runtime 56800E.Lib |
CodeWarrior\M56800E Support\runtime_56800E\lib |
When creating a project from R1.1 or later Stationery, the associated init code is specific to the DSP56800E board. See the startup folder in the new project folder for the init code.
#
; -------------------------------------------------------
;
; 56852_init.asm
; sample
description: main entry point to C code.
; setup runtime for C and call main
;
; -------------------------------------------------------
;===============================
; OMR mode bits
;===============================
NL_MODE EQU $8000
CM_MODE EQU $0100
XP_MODE EQU $0080
R_MODE EQU $0020
SA_MODE EQU $0010
section rtlib
XREF F_stack_addr
org p:
GLOBAL Finit_M56852_
SUBROUTINE "Finit_M56852_",Finit_M56852_,Finit_M56852END-Finit_M56852_
Finit_M56852_:
;
; setup the OMr with the values required by C
;
bfset #NL_MODE,omr ; ensure NL=1 (enables nsted DO loops)
nop
nop
bfclr #(CM_MODE|XP_MODE|R_MODE|SA_MODE),omr ; ensure CM=0 (optional for C)
; ensure XP=0 to enable harvard architecture
; ensure R=0 (required for C)
; ensure SA=0 (required for C)
; Setup the m01 register for linear addressing
move.w #-1,x0
moveu.w x0,m01 ; Set the m register to linear addressing
moveu.w hws,la ; Clear the hardware stack
moveu.w hws,la nop
nop
CALLMAIN: ; Initialize compiler environment
;Initialize the Stack
move.l #>>F_Lstack_addr,r0
bftsth #$0001,r0
bcc noinc
adda #1,r0
noinc:
tfra r0,sp ; set stack pointer too
move.w #0,r1
nop
move.w r1,x:(sp)
adda #1,sp
jsr F__init_sections
; Call main()
move.w #0,y0 ; Pass parameters to main()
move.w #0,R2
move.w #0,R3
jsr Fmain ; Call the Users program
;
; The fflush calls where removed because they added code
; growth in cases where the user is not using any debugger IO.
; Users should now make these calls at the end of main if they use debugger IO
;
; move.w #0,r2
; jsr Ffflush ; Flush File IO
; jsr Ffflush_console ; Flush Console IO
; end of program; halt CPU
debughlt
rts
Finit_M56852END:
endsec