I am a newbie porting an application from the TMS320LF2407A to the TMS320F28234.
During this effort, I encountered a routine written in assembly that copies strings from program space to data space.
I would like to perform this same operation without the use of assembly routines (if at all possible).
Is it possible to do this in C?
What I seem to have is a bunch of strings stored in program space that can not be copied to data space at boot (probably because the data space is limited).
So the strings are declared something like:
.sect "PBG_STR"
__Dbg_Baud_110:
.string " 110",0
__Dbg_Baud_300:
.string " 300",0
__Dbg_Baud_1200:
.string " 1200",0
The PBG_STR section is linked and located to Page 0 (program space).
In the C program, an assembly language routine is called to copy the string from code space to data space:
char baudstring[32];
Str_GetProgramString(baudstring, _Dbg_Baud_110);
The assembly routine Str_GetProgramString() is:
Note: The routine below copies null terminated strings, but I would like to be able to copy any data type as well.
;
; prototype:
; unsigned short Str_GetProgramString(SERCHAR* s1, SERCHAR* s2);
;
; function:
; a routine to copy a program string at s2 into the user buffer
; at s1. s1 and s2 are terminated by NUL characters. this routine
; cannot be written in c, note the TBLR instruction used to access
; the program space strings.
; returns:
; the length of s1, equivalently, of s2.
;
POPD *+
SAR AR0,*+
SAR AR1,*
LARK AR0,#3
LAR AR0,*0+,AR2
LRLK AR2,#-4
MAR *0+
LAR AR3,*+ ; ar3=s2
LAR AR4,* ; ar4=s1
ADRK #4
ZAC ; ar2->x (TOS+1) = 0
SACL *-
$1: SAR AR3,* ; get the byte into the accumulator- HIGH first
LACC * ; TOS = *ar3 >> 8
TBLR *
LACC *,8
SACH *
LACC *+,8,AR4 ; *ar4(high) = TOS; clear *ar4(low)
SACL *,AR2
BCND $2,EQ ; if TOS = NUL then exit loop
LACC * ; x++
ADDK #1
SACL *-
SAR AR3,* ; get the byte into the accumulator- now LOW
LACC * ; TOS = *ar3 & 0xff
TBLR *
LACC *
AND #000FFH
SACL *,AR4
OR * ; *ar4(low) |= TOS
SACL *+,AR2
LACC *+
BCND $2,EQ ; if TOS = NUL then exit loop
LACC * ; x++
ADDK #1
SACL *-,AR3 ; move to the next doublet of s2
MAR *+,AR2
B $1
$2: LACC *
B RET2
Thank you in advance.