-
-
Neuer Benutzer
Öfters hier
Hi,
habe es geschafft das mein zweites Projekt ab Adresse 2000 beginnt,
ohne das er bei 0x0000 ein goto Befehl reinschreibt.
Habe dazu die c018i.c ein wenig manipuliert.
extern void main (void);
void _entry (void);
void _startup (void);
void _do_cinit (void);
extern volatile near unsigned long short TBLPTR;
extern near unsigned FSR0;
extern near char FPFLAGS;
#define RND 6
#pragma code _entry_scn=0x000000
void _entry (void)
{
_asm goto _startup _endasm
}
#pragma code _startup_scn
void _startup (void)
{
_asm
lfsr 1, _stack lfsr 2, _stack clrf TBLPTRU, 0
bcf FPFLAGS,RND,0
bsf 0xa6, 7, 0
bcf 0xa6, 6, 0
_endasm
_do_cinit ();
loop:
main ();
goto loop;
}
extern far rom struct
{
unsigned short num_init;
struct _init_entry
{
unsigned long from;
unsigned long to;
unsigned long size;
}
entries[];
}
_cinit;
#pragma code _cinit_scn
void
_do_cinit (void)
{
static short long prom;
static unsigned short curr_byte;
static unsigned short curr_entry;
static short long data_ptr;
// Initialized data...
TBLPTR = (short long)&_cinit;
_asm
movlb data_ptr
tblrdpostinc
movf TABLAT, 0, 0
movwf curr_entry, 1
tblrdpostinc
movf TABLAT, 0, 0
movwf curr_entry+1, 1
_endasm
test:
_asm
bnz 3
tstfsz curr_entry, 1
bra 1
_endasm
goto done;
_asm
/* read the source address */
tblrdpostinc
movf TABLAT, 0, 0
movwf prom, 1
tblrdpostinc
movf TABLAT, 0, 0
movwf prom+1, 1
tblrdpostinc
movf TABLAT, 0, 0
movwf prom+2, 1
/* skip a byte since it's stored as a 32bit int */
tblrdpostinc
/* read the destination address directly into FSR0 */
tblrdpostinc
movf TABLAT, 0, 0
movwf FSR0L, 0
tblrdpostinc
movf TABLAT, 0, 0
movwf FSR0H, 0
/* skip two bytes since it's stored as a 32bit int */
tblrdpostinc
tblrdpostinc
/* read the destination address directly into FSR0 */
tblrdpostinc
movf TABLAT, 0, 0
movwf curr_byte, 1
tblrdpostinc
movf TABLAT, 0, 0
movwf curr_byte+1, 1
/* skip two bytes since it's stored as a 32bit int */
tblrdpostinc
tblrdpostinc
_endasm
data_ptr = TBLPTR;
/* now assign the source address to the table pointer */
TBLPTR = prom;
/* do the copy loop */
_asm
// determine if we have any more bytes to copy
movlb curr_byte
movf curr_byte, 1, 1
copy_loop:
bnz 2 // copy_one_byte
movf curr_byte + 1, 1, 1
bz 7 // done_copying
copy_one_byte:
tblrdpostinc
movf TABLAT, 0, 0
movwf POSTINC0, 0
// decrement byte counter
decf curr_byte, 1, 1
bc -8 // copy_loop
decf curr_byte + 1, 1, 1
bra -7 // copy_one_byte
done_copying:
_endasm
/* restore the table pointer for the next entry */
TBLPTR = data_ptr;
/* next entry... */
curr_entry--;
goto test;
done:
;
}
Jetzt habe ich das Problem, wenn ich das erst Hex file auf den Pic
flashe und danach das zweite, dann überschreibe ich das erste Hex file.
Berechtigungen
- Neue Themen erstellen: Nein
- Themen beantworten: Nein
- Anhänge hochladen: Nein
- Beiträge bearbeiten: Nein
-
Foren-Regeln
Lesezeichen