Jump to content

Recommended Posts

This question may have been asked in the past, but being new to boost I will ask anyway.

At the start of my programs ( programmed in BloC previously ) I reset the banks of registers I will be using.

The following code clears Bank 0 & 1 OK. It sets most of Bank 2 OK, but doesn't use indirection. I know I could embed the asm

to cure but is there a trick I am missing to get boost to do it for me?

 

/*******************************/

/* Clear bottom bank of memory */

/*******************************/

fsr = (unsigned char)&Light_Timer;

do

{

indf = 0;

fsr++;

}

while ( fsr <= &Daily_Count );

 

/**************************/

/* Clear bank 2 of memory */

/**************************/

same as Bank 0 different registers

 

/**************************/

/* Clear bank 3 of memory */

/**************************/

fsr = (unsigned char)&HeatCtr;

do

{

indf = 0;

fsr++;

}

while ( fsr <= &B2_Unused );

 

cheers

 

MKL

Share this post


Link to post
Share on other sites

minitech,

This question may have been asked in the past, but being new to boost I will ask anyway.

At the start of my programs ( programmed in BloC previously ) I reset the banks of registers I will be using.

The following code clears Bank 0 & 1 OK. It sets most of Bank 2 OK, but doesn't use indirection. I know I could embed the asm

to cure but is there a trick I am missing to get boost to do it for me?

 

/*******************************/

/* Clear bottom bank of memory */

/*******************************/

fsr = (unsigned char)&Light_Timer;

do

{

indf = 0;

fsr++;

}

while ( fsr <= &Daily_Count );

 

/**************************/

/* Clear bank 2 of memory */

/**************************/

same as Bank 0 different registers

 

/**************************/

/* Clear bank 3 of memory */

/**************************/

fsr = (unsigned char)&HeatCtr;

do

{

indf = 0;

fsr++;

}

while ( fsr <= &B2_Unused );

This method of zeroing registers is certainly not recommended for the following reasons:

1) It assumes the variables refenced are in specific banks. It is normal practice to leav linker to decide where to put variables in the memory space.

2) It assumes that the loop uses no data that may be destroyed as it clears the memory.

3) It is non-portable, should you ever use some of your code on another device it may not work.

 

The recommended method is:

 

int myGlobalVar = 0;

etc.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...