📄 crt1.asm
字号:
.byte 0x1 .byte 0x13 .byte 0x3f .byte 0xc .byte 0x3 .byte 0x8 .byte 0x3a .byte 0xb .byte 0x3b .byte 0xb .byte 0x27 .byte 0xc .byte 0x11 .byte 0x1 .byte 0x12 .byte 0x1 .byte 0x40 .byte 0xa .byte 0,0 .byte 0x3 .byte 0x5 .byte 0x0 .byte 0x3 .byte 0x8 .byte 0x3a .byte 0xb .byte 0x3b .byte 0xb .byte 0x49 .byte 0x13 .byte 0x2 .byte 0xa .byte 0,0 .byte 0x4 .byte 0x24 .byte 0x0 .byte 0x3 .byte 0x8 .byte 0xb .byte 0xb .byte 0x3e .byte 0xb .byte 0,0 .byte 0 .section .debug_pubnames .ualong 0x27 .uaword 0x2 .ualong .Ldebug_info0 .ualong 0xab .ualong 0x5b .string "_superh_trap_handler" .ualong 0x0 .section .debug_aranges .ualong 0x1c .uaword 0x2 .ualong .Ldebug_info0 .byte 0x4 .byte 0x0 .uaword 0x0,0 .ualong .Ltext0 .ualong .Letext0-.Ltext0 .ualong 0x0 .ualong 0x0 .ident "GCC: (GNU) 2.97-sh5-010522"#endif /* MMU_SUPPORT */#else /* ! __SH5__ */ ! make a place to keep any previous value of the vbr register ! this will only have a value if it has been set by redboot (for example) .section .bssold_vbr: .long 0 .section .text .global start .import ___rtos_profiler_start_timer .weak ___rtos_profiler_start_timerstart: mov.l stack_k,r15#if defined (__SH3__) || (defined (__SH_FPU_ANY__) && ! defined (__SH2A__)) || defined (__SH4_NOFPU__)#define VBR_SETUP ! before zeroing the bss ... ! if the vbr is already set to vbr_start then the program has been restarted ! (i.e. it is not the first time the program has been run since reset) ! reset the vbr to its old value before old_vbr (in bss) is wiped ! this ensures that the later code does not create a circular vbr chain stc vbr, r1 mov.l vbr_start_k, r2 cmp/eq r1, r2 bf 0f ! reset the old vbr value mov.l old_vbr_k, r1 mov.l @r1, r2 ldc r2, vbr0: #endif /* VBR_SETUP */ ! zero out bss mov.l edata_k,r0 mov.l end_k,r1 mov #0,r2start_l: mov.l r2,@r0 add #4,r0 cmp/ge r0,r1 bt start_l#if defined (__SH_FPU_ANY__) mov.l set_fpscr_k, r1 mov #4,r4 jsr @r1 shll16 r4 ! Set DN bit (flush denormal inputs to zero) lds r3,fpscr ! Switch to default precision#endif /* defined (__SH_FPU_ANY__) */#ifdef VBR_SETUP ! save the existing contents of the vbr ! there will only be a prior value when using something like redboot ! otherwise it will be zero stc vbr, r1 mov.l old_vbr_k, r2 mov.l r1, @r2 ! setup vbr mov.l vbr_start_k, r1 ldc r1,vbr#endif /* VBR_SETUP */ ! if an rtos is exporting a timer start fn, ! then pick up an SR which does not enable ints ! (the rtos will take care of this) mov.l rtos_start_fn, r0 mov.l sr_initial_bare, r1 tst r0, r0 bt set_sr mov.l sr_initial_rtos, r1set_sr: ! Set status register (sr) ldc r1, sr ! arrange for exit to call fini mov.l atexit_k,r0 mov.l fini_k,r4 jsr @r0 nop ! call init mov.l init_k,r0 jsr @r0 nop ! call the mainline mov.l main_k,r0 jsr @r0 nop ! call exit mov r0,r4 mov.l exit_k,r0 jsr @r0 nop .align 2#if defined (__SH_FPU_ANY__)set_fpscr_k: .long ___set_fpscr#endif /* defined (__SH_FPU_ANY__) */stack_k: .long _stack edata_k: .long _edataend_k: .long _endmain_k: .long ___setup_argv_and_call_mainexit_k: .long _exitatexit_k: .long _atexitinit_k: .long _initfini_k: .long _fini#ifdef VBR_SETUPold_vbr_k: .long old_vbrvbr_start_k: .long vbr_start#endif /* VBR_SETUP */ sr_initial_rtos: ! Privileged mode RB 1 BL 0. Keep BL 0 to allow default trap handlers to work. ! Whether profiling or not, keep interrupts masked, ! the RTOS will enable these if required. .long 0x600000f1 rtos_start_fn: .long ___rtos_profiler_start_timer sr_initial_bare: ! Privileged mode RB 1 BL 0. Keep BL 0 to allow default trap handlers to work. ! Keep interrupts disabled - the application will enable as required. .long 0x600000f1 ! supplied for backward compatibility only, in case of linking ! code whose main() was compiled with an older version of GCC. .global ___main___main: rts nop#ifdef VBR_SETUP! Exception handlers .balign 256vbr_start: mov.l 2f, r0 ! load the old vbr setting (if any) mov.l @r0, r0 cmp/eq #0, r0 bf 1f ! no previous vbr - jump to own generic handler bra handler nop1: ! there was a previous handler - chain them jmp @r0 nop .balign 42: .long old_vbr .balign 256vbr_100: ! Non profiling case.handler_100: mov.l 2f, r0 ! load the old vbr setting (if any) mov.l @r0, r0 cmp/eq #0, r0 bf 1f ! no previous vbr - jump to own generic handler bra handler nop 1: ! there was a previous handler - chain them add #0x7f, r0 ! 0x7f add #0x7f, r0 ! 0xfe add #0x2, r0 ! add 0x100 without corrupting another register jmp @r0 nop .balign 42: .long old_vbr .balign 256vbr_200: mov.l 2f, r0 ! load the old vbr setting (if any) mov.l @r0, r0 cmp/eq #0, r0 bf 1f ! no previous vbr - jump to own generic handler bra handler nop 1: ! there was a previous handler - chain them add #0x7f, r0 ! 0x7f add #0x7f, r0 ! 0xfe add #0x7f, r0 ! 0x17d add #0x7f, r0 ! 0x1fc add #0x4, r0 ! add 0x200 without corrupting another register jmp @r0 nop .balign 42: .long old_vbr .balign 256vbr_300: mov.l 2f, r0 ! load the old vbr setting (if any) mov.l @r0, r0 cmp/eq #0, r0 bf 1f ! no previous vbr - jump to own generic handler bra handler nop 1: ! there was a previous handler - chain them add #0x7f, r0 ! 0x7f add #0x7f, r0 ! 0xfe add #0x7f, r0 ! 0x17d add #0x7f, r0 ! 0x1fc add #0x7f, r0 ! 0x27b add #0x7f, r0 ! 0x2fa add #0x6, r0 ! add 0x300 without corrupting another register jmp @r0 nop .balign 42: .long old_vbr .balign 256 vbr_400: ! Should be at vbr+0x400 mov.l 2f, r0 ! load the old vbr setting (if any) mov.l @r0, r0 cmp/eq #0, r0 ! no previous vbr - jump to own generic handler bt handler ! there was a previous handler - chain them add #0x7f, r0 ! 0x7f add #0x7f, r0 ! 0xfe add #0x7f, r0 ! 0x17d add #0x7f, r0 ! 0x1fc add #0x7f, r0 ! 0x27b add #0x7f, r0 ! 0x2fa add #0x7f, r0 ! 0x379 add #0x7f, r0 ! 0x3f8 add #0x8, r0 ! add 0x400 without corrupting another register jmp @r0 nop .balign 42: .long old_vbrhandler: /* If the trap handler is there call it */ mov.l superh_trap_handler_k, r0 cmp/eq #0, r0 ! True if zero. bf 3f bra chandler nop3: ! Here handler available, call it. /* Now call the trap handler with as much of the context unchanged as possible. Move trapping address into PR to make it look like the trap point */ stc spc, r1 lds r1, pr mov.l expevt_k, r4 mov.l @r4, r4 ! r4 is value of expevt, first parameter. mov r1, r5 ! Remember trapping pc. mov r1, r6 ! Remember trapping pc. mov.l chandler_k, r1 mov.l superh_trap_handler_k, r2 ! jmp to trap handler to avoid disturbing pr. jmp @r2 nop .balign 256vbr_500: mov.l 2f, r0 ! load the old vbr setting (if any) mov.l @r0, r0 cmp/eq #0, r0 ! no previous vbr - jump to own generic handler bt handler ! there was a previous handler - chain them add #0x7f, r0 ! 0x7f add #0x7f, r0 ! 0xfe add #0x7f, r0 ! 0x17d add #0x7f, r0 ! 0x1fc add #0x7f, r0 ! 0x27b add #0x7f, r0 ! 0x2fa add #0x7f, r0 ! 0x379 add #0x7f, r0 ! 0x3f8 add #0x7f, r0 ! 0x477 add #0x7f, r0 ! 0x4f6 add #0xa, r0 ! add 0x500 without corrupting another register jmp @r0 nop .balign 42: .long old_vbr .balign 256vbr_600: mov.l 2f, r0 ! load the old vbr setting (if any) mov.l @r0, r0 cmp/eq #0, r0 ! no previous vbr - jump to own handler bt chandler ! there was a previous handler - chain them add #0x7f, r0 ! 0x7f add #0x7f, r0 ! 0xfe add #0x7f, r0 ! 0x17d add #0x7f, r0 ! 0x1fc add #0x7f, r0 ! 0x27b add #0x7f, r0 ! 0x2fa add #0x7f, r0 ! 0x379 add #0x7f, r0 ! 0x3f8 add #0x7f, r0 ! 0x477 add #0x7f, r0 ! 0x4f6 add #0x7f, r0 ! 0x575 add #0x7f, r0 ! 0x5f4 add #0xc, r0 ! add 0x600 without corrupting another register jmp @r0 nop .balign 42: .long old_vbrchandler: mov.l expevt_k, r4 mov.l @r4, r4 ! r4 is value of expevt hence making this the return code mov.l handler_exit_k,r0 jsr @r0 nop ! We should never return from _exit but in case we do we would enter the ! the following tight looplimbo: bra limbo nop .balign 4expevt_k: .long 0xff000024 ! Address of expevtchandler_k: .long chandler superh_trap_handler_k: .long __superh_trap_handlerhandler_exit_k: .long _exit .align 2! Simulated compile of trap handler. .section .debug_abbrev,"",@progbits.Ldebug_abbrev0: .section .debug_info,"",@progbits.Ldebug_info0: .section .debug_line,"",@progbits.Ldebug_line0: .text.Ltext0: .align 5 .type __superh_trap_handler,@function__superh_trap_handler:.LFB1: mov.l r14,@-r15.LCFI0: add #-4,r15.LCFI1: mov r15,r14.LCFI2: mov.l r4,@r14 lds r1, pr add #4,r14 mov r14,r15 mov.l @r15+,r14 rts nop.LFE1:.Lfe1: .size __superh_trap_handler,.Lfe1-__superh_trap_handler .section .debug_frame,"",@progbits.Lframe0: .ualong .LECIE0-.LSCIE0.LSCIE0: .ualong 0xffffffff .byte 0x1 .string "" .uleb128 0x1 .sleb128 -4 .byte 0x11 .byte 0xc .uleb128 0xf .uleb128 0x0 .align 2.LECIE0:.LSFDE0: .ualong .LEFDE0-.LASFDE0.LASFDE0: .ualong .Lframe0 .ualong .LFB1 .ualong .LFE1-.LFB1 .byte 0x4 .ualong .LCFI0-.LFB1 .byte 0xe .uleb128 0x4 .byte 0x4 .ualong .LCFI1-.LCFI0 .byte 0xe .uleb128 0x8 .byte 0x8e .uleb128 0x1 .byte 0x4 .ualong .LCFI2-.LCFI1 .byte 0xd .uleb128 0xe .align 2.LEFDE0: .text.Letext0: .section .debug_info .ualong 0xb3 .uaword 0x2 .ualong .Ldebug_abbrev0 .byte 0x4 .uleb128 0x1 .ualong .Ldebug_line0 .ualong .Letext0 .ualong .Ltext0 .string "trap_handler.c" .string "xxxxxxxxxxxxxxxxxxxxxxxxxxxx" .string "GNU C 3.2 20020529 (experimental)" .byte 0x1 .uleb128 0x2 .ualong 0xa6 .byte 0x1 .string "_superh_trap_handler" .byte 0x1 .byte 0x2 .byte 0x1 .ualong .LFB1 .ualong .LFE1 .byte 0x1 .byte 0x5e .uleb128 0x3 .string "trap_reason" .byte 0x1 .byte 0x1 .ualong 0xa6 .byte 0x2 .byte 0x91 .sleb128 0 .byte 0x0 .uleb128 0x4 .string "unsigned int" .byte 0x4 .byte 0x7 .byte 0x0 .section .debug_abbrev .uleb128 0x1 .uleb128 0x11 .byte 0x1 .uleb128 0x10 .uleb128 0x6 .uleb128 0x12 .uleb128 0x1 .uleb128 0x11 .uleb128 0x1 .uleb128 0x3 .uleb128 0x8 .uleb128 0x1b .uleb128 0x8 .uleb128 0x25 .uleb128 0x8 .uleb128 0x13 .uleb128 0xb .byte 0x0 .byte 0x0 .uleb128 0x2 .uleb128 0x2e .byte 0x1 .uleb128 0x1 .uleb128 0x13 .uleb128 0x3f .uleb128 0xc .uleb128 0x3 .uleb128 0x8 .uleb128 0x3a .uleb128 0xb .uleb128 0x3b .uleb128 0xb .uleb128 0x27 .uleb128 0xc .uleb128 0x11 .uleb128 0x1 .uleb128 0x12 .uleb128 0x1 .uleb128 0x40 .uleb128 0xa .byte 0x0 .byte 0x0 .uleb128 0x3 .uleb128 0x5 .byte 0x0 .uleb128 0x3 .uleb128 0x8 .uleb128 0x3a .uleb128 0xb .uleb128 0x3b .uleb128 0xb .uleb128 0x49 .uleb128 0x13 .uleb128 0x2 .uleb128 0xa .byte 0x0 .byte 0x0 .uleb128 0x4 .uleb128 0x24 .byte 0x0 .uleb128 0x3 .uleb128 0x8 .uleb128 0xb .uleb128 0xb .uleb128 0x3e .uleb128 0xb .byte 0x0 .byte 0x0 .byte 0x0 .section .debug_pubnames,"",@progbits .ualong 0x27 .uaword 0x2 .ualong .Ldebug_info0 .ualong 0xb7 .ualong 0x67 .string "_superh_trap_handler" .ualong 0x0 .section .debug_aranges,"",@progbits .ualong 0x1c .uaword 0x2 .ualong .Ldebug_info0 .byte 0x4 .byte 0x0 .uaword 0x0 .uaword 0x0 .ualong .Ltext0 .ualong .Letext0-.Ltext0 .ualong 0x0 .ualong 0x0#endif /* VBR_SETUP */#endif /* ! __SH5__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -