5 ;;;-----------------------------------------------------------------------------
\r
9 ;;;-----------------------------------------------------------------------------
\r
11 ;;; Code taken from USRP2 firmware (GNU Radio Project), version 3.0.2,
\r
13 ;;; Copyright 2003 Free Software Foundation, Inc.
\r
15 ;;;-----------------------------------------------------------------------------
\r
17 ;;; This code is part of usbjtag. usbjtag is free software; you can redistribute
\r
19 ;;; it and/or modify it under the terms of the GNU General Public License as
\r
21 ;;; published by the Free Software Foundation; either version 2 of the License,
\r
23 ;;; or (at your option) any later version. usbjtag is distributed in the hope
\r
25 ;;; that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
\r
27 ;;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
29 ;;; GNU General Public License for more details. You should have received a
\r
31 ;;; copy of the GNU General Public License along with this program in the file
\r
33 ;;; COPYING; if not, write to the Free Software Foundation, Inc., 51 Franklin
\r
35 ;;; St, Fifth Floor, Boston, MA 02110-1301 USA
\r
37 ;;;-----------------------------------------------------------------------------
\r
41 ;;; The default external memory initialization provided by sdcc is not
\r
43 ;;; appropriate to the FX2. This is derived from the sdcc code, but uses
\r
45 ;;; the FX2 specific _MPAGE sfr.
\r
51 ;; .area XISEG (XDATA) ; the initialized external data area
\r
53 ;; .area XINIT (CODE) ; the code space consts to init XISEG
\r
55 .area XSEG (XDATA) ; zero initialized xdata
\r
57 .area USBDESCSEG (XDATA) ; usb descriptors
\r
67 ;; sfr that sets upper address byte of MOVX using @r0 or @r1
\r
73 __sdcc_external_startup::
\r
75 ;; This system is now compiled with the --no-xinit-opt
\r
77 ;; which means that any initialized XDATA is handled
\r
79 ;; inline by code in the GSINIT segs emitted for each file.
\r
83 ;; We zero XSEG and all of the internal ram to ensure
\r
85 ;; a known good state for uninitialized variables.
\r
89 ; _mcs51_genRAMCLEAR() start
\r
95 orl a,#(l_XSEG >> 8)
\r
99 mov r1,#((l_XSEG + 255) >> 8)
\r
107 00001$: movx @dptr,a
\r
117 ;; We're about to clear internal memory. This will overwrite
\r
119 ;; the stack which contains our return address.
\r
121 ;; Pop our return address into DPH, DPL
\r
129 ;; R0 and A contain 0. This loop will execute 256 times.
\r
133 ;; FWIW the first iteration writes direct address 0x00,
\r
135 ;; which is the location of r0. We get lucky, we're
\r
137 ;; writing the correct value (0)
\r
147 push dpl ; restore our return address
\r
153 mov dpl,#0 ; indicate that data init is still required
\r