STRCPY Function.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

STRCPY Function.

2,307 Views
NeoSP
Contributor I
Hello Friends,

I've been using the NE64 with a RAM external memory. Anybody could help me with the strcpy function? How can I copy or transfer some data from one page to another page. For example, 0x118000 to 0x108000. Does anybody know how I can use the strcpy function to do it? Or does anybody have any other idea?

Thanks,

Best regards,
Marco.
Labels (1)
Tags (1)
0 Kudos
4 Replies

647 Views
CrasyCat
Specialist III
Hello
Just my 10 cents on that one.
When you are building in BANKED memory model, strcpy assumes per default, that all pointer are 16-bit wide.
If you need to pass 24-bit pointer to strcpy, you need to rebuild an ansi library supporting 24-bit pointer to char.
  
There should be an FAQ around that in the system.
BAsically:
- Open the project HC12Lib.mcp
- Edit the file libdefs.h located in the installation directory "LIB\HC12C\include". In this file modify lines 74 and 78 as follows:
   #define LIBDEF_FAR_CONST_STRINGS  1  
   #define LIBDEF_FAR_STRINGS        1  
- Generate the library again. This can be done using the project hc12 lib.mcp located in the installation LIB\HC12C directory. Technical note TN105 provide you information how to generate a new library.
If you are using HCS12 CPU, make sure to compile your application and the library with -CpPPAGE=RUNTIME to let compiler know banked constant must be accessed using runtime function.
 
I attached the referenced Technical note to this thread.

CrasyCat
 
0 Kudos

647 Views
Lundin
Senior Contributor IV
No, you don't want to do that. It may make the code portable between two compilers but not between two computers. The next person who picks up that project will have a hard time understanding why the code isn't working, since the libs are stored on a local computer.

That will also force all calls to strcpy() to use far pointers even when it isn't needed, which may reduce the performance of the program in an unwanted way.

The serious approach is to do as I suggested and write a separate routine yourself.


As a sidenote, if you use CpPPAGE=RUNTIME, wouldn't you have to link that pesky datapage.c to the project as well? I'm pretty certain that the compiler ignores that particular compiler option unless you do.
0 Kudos

647 Views
Nouchi
Senior Contributor II
Hi,

I don't have any experience with CW for HCS12, but I used HC16 compiler(formerly Hiware technology) where far keywords could be used to specified 20bits pointer instead 16bits.

Maybe CW HS12 compiler let you write things like this :
strcpy((char *far)destPtr, (char *far)srcPtr));


Emmanuel
0 Kudos

647 Views
Lundin
Senior Contributor IV
(Assuming that NE64 = HCS12)

No, it wouldn't be possible with strcpy(). The simple solution would be to write your own function that takes far pointers as parameters. Put this function in non-paged flash then save the page register in a temporary variable, set the page register manually, copy data and restore the page register.

Perhaps CW contains a non-standard library function for this, but it is always better to write non-standard functions yourself, because then you will have the source code when/if you decide to port the code in the future.
0 Kudos