4 /* This routine is intended to setup the DS80C390 in contiguous addressing
5 mode, using a 10-bit stack (mapped to 0x400000).
6 It assumes that _sdcc_gsinit_startup is called from a boot loader
7 in 22-bit contiguous addressing mode */
9 /* Uncomment this if you are using the tini loader 000515. Make sure
10 XSEG starts at 0x100080 or it will overwrite your IVT. This won't harm
11 if you are using the 990824 loader */
12 #define TINI_LOADER_0515
14 unsigned char _sdcc_external_startup(void)
16 IE=0; // disable ALL interrupts
19 ; save the 24-bit return address
24 ; use A19..16 and !CE3..0, no CAN
25 mov _TA,#0xaa; timed access
29 ; use !PCE3..0, serial 1 at P5.2/3
30 mov _TA,#0xaa; timed access
37 ; watchdog set to 9.1 seconds
39 ; no strech-cycles for movx
42 ; use internal 4k RAM as data(stack) memory at 0x400000 and
43 ; move CANx memory access to 0x401000 and upwards
44 ; use !CE* for program and/or data memory access
45 mov _TA,#0xaa; timed access
49 mov _PMR,#0x82; two clocks per cycle
50 mov _PMR,#0x92; enable multiplier
51 _Startup390WaitForClock:
53 jnb acc.3,_Startup390WaitForClock; wait for multiplier to be ready
54 mov _PMR,#0x12; one clock per cycle, xtal*2
56 mov _TA,#0xaa; timed access
58 mov _ACON,#0x06; 24-bit addresses, 10-bit stack at 0x400000
60 mov _ESP,#0x00; reinitialize the stack
63 ; restore the 24-bit return address
69 #ifdef TINI_LOADER_0515
70 // Copy the Interrupt Vector Table (128 bytes) from 0x10000 to 0x100000
71 // Make sure that XSEG starts at 0x100080 in this case!
79 mov dps,#0x00 ; make sure no autoincrement in progress
80 mov dptr,#0x10000 ; from
81 inc dps ; switch to alternate dptr
82 mov dptr,#0x100000 ; to
92 djnz b,_Startup390CopyIVT
103 // global interrupt enable, all masks cleared
104 // let the Gods be with us :)
107 // now that the stack is re-initialized, we can safely call
110 // signal _sdcc_gsinit_startup to initialize data (call _sdcc_init_data)