source: trunk/FirmwareFX2/startup.a51@ 13

Last change on this file since 13 was 5, checked in by demin, 15 years ago

adapt to latest usb_jtag sources and altera drivers

File size: 3.2 KB
Line 
1;;; -*- asm -*-
2;;;
3;;;-----------------------------------------------------------------------------
4;;; Startup code
5;;;-----------------------------------------------------------------------------
6;;; Code taken from USRP2 firmware (GNU Radio Project), version 3.0.2,
7;;; Copyright 2003 Free Software Foundation, Inc.
8;;;-----------------------------------------------------------------------------
9;;; This code is part of usbjtag. usbjtag is free software; you can redistribute
10;;; it and/or modify it under the terms of the GNU General Public License as
11;;; published by the Free Software Foundation; either version 2 of the License,
12;;; or (at your option) any later version. usbjtag is distributed in the hope
13;;; that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
14;;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;;; GNU General Public License for more details. You should have received a
16;;; copy of the GNU General Public License along with this program in the file
17;;; COPYING; if not, write to the Free Software Foundation, Inc., 51 Franklin
18;;; St, Fifth Floor, Boston, MA 02110-1301 USA
19;;;-----------------------------------------------------------------------------
20
21;;; The default external memory initialization provided by sdcc is not
22;;; appropriate to the FX2. This is derived from the sdcc code, but uses
23;;; the FX2 specific _MPAGE sfr.
24
25
26 ;; .area XISEG (XDATA) ; the initialized external data area
27 ;; .area XINIT (CODE) ; the code space consts to init XISEG
28 .area XSEG (XDATA) ; zero initialized xdata
29 .area USBDESCSEG (XDATA) ; usb descriptors
30
31
32 .area CSEG (CODE)
33
34 ;; sfr that sets upper address byte of MOVX using @r0 or @r1
35 _MPAGE = 0x0092
36
37__sdcc_external_startup::
38 ;; This system is now compiled with the --no-xinit-opt
39 ;; which means that any initialized XDATA is handled
40 ;; inline by code in the GSINIT segs emitted for each file.
41 ;;
42 ;; We zero XSEG and all of the internal ram to ensure
43 ;; a known good state for uninitialized variables.
44
45; _mcs51_genRAMCLEAR() start
46 mov r0,#l_XSEG
47 mov a,r0
48 orl a,#(l_XSEG >> 8)
49 jz 00002$
50 mov r1,#((l_XSEG + 255) >> 8)
51 mov dptr,#s_XSEG
52 clr a
53
5400001$: movx @dptr,a
55 inc dptr
56 djnz r0,00001$
57 djnz r1,00001$
58
59 ;; We're about to clear internal memory. This will overwrite
60 ;; the stack which contains our return address.
61 ;; Pop our return address into DPH, DPL
6200002$: pop dph
63 pop dpl
64
65 ;; R0 and A contain 0. This loop will execute 256 times.
66 ;;
67 ;; FWIW the first iteration writes direct address 0x00,
68 ;; which is the location of r0. We get lucky, we're
69 ;; writing the correct value (0)
70
7100003$: mov @r0,a
72 djnz r0,00003$
73
74 push dpl ; restore our return address
75 push dph
76
77 mov dpl,#0 ; indicate that data init is still required
78 ret
Note: See TracBrowser for help on using the repository browser.