下面是初始代的启动代码中的一段,这段的做用是什么,是不是檫除所有的RAM,汇编我看不懂
test:
_asm
bnz 3
tstfsz curr_entry, 1
bra 1
_endasm
goto done;
/* Count down so we only have to look up the data in _cinit
* once.
*
* At this point we know that TBLPTR points to the top of the current
* entry in _cinit, so we can just start reading the from, to, and
* size values.
*/
_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
//prom = data_ptr->from;
//FSR0 = data_ptr->to;
//curr_byte = (unsigned short) data_ptr->size;
/* the table pointer now points to the next entry. Save it
* off since we'll be using the table pointer to do the copying
* for the entry.
*/
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: |