/* This C language subroutine transform a string from one locale to another. Since there is only one locale defined here, this is basically just a strcpy clone. The Run Time Library for the C Language. Gordon A. Sterling (617) 461 - 3076 DSP Development Tools Engineering Created on 4/30/90 Updated on 5/94 by AS Updated on 3/95 by AS - separated polymorphic functions #include
size_t strxfrm(char *s1, const char *s2, size_t size); */ #include "lib_glob.h" #include "str_glob.h" .SEGMENT/CODE Code_Space_Name; .FILE RTL_FILENAME; .EXTERN ___lib_strlendm; .GLOBAL ___strxfrmDP; ___strxfrmDP: transform_core: R0=R0-R0, FETCH_RETURN; /* Clear result register */ R8=PASS R8, dm_lnt=dm_0; /* Test for NULL s2 */ IF EQ JUMP (PC, restore_state); /* Return with 0 result */ R12=PASS R12; /* Test for length of zero */ IF EQ JUMP (PC, dm_to_pm_xform) (DB); R0=R0-1; /* Set return to -1 for error */ R4=PASS R4; /* Test for NULL s1 */ IF EQ JUMP (PC, restore_state); /* NULL s1, return -1 */ dm_to_pm_xform: R12=PASS R12, dm_ptr=R4; /* Point to s1 */ pm_ptr=R8; /* Point to s2 */ IF EQ JUMP (PC, return_pm_len) (DB); /* Return the length of input*/ R12=PASS R12, R0=dm_0; /* Loop one less */ IF EQ JUMP (PC, pm_dm); /* Write out NULL only */ LCNTR=R12, DO pm_dm UNTIL LCE; /* Copy n-1 characters at most */ IF NE R0=R0+1, R2=PM(pm_ptr, pm_1); /* Read in char */ pm_dm: IF NE R2=PASS R2, DM(dm_ptr, dm_1)=R2; /* Write char */ IF EQ R0=R0-1; /* Remove NULL from count */ R4=R4-R4, MODIFY(dm_ptr, dm_M1);/* Backup pointer to last write */ R2=PASS R2, DM(dm_ptr, dm_1)=R4;/* Write out NULL, test write */ IF NE R0=R0+1; /* Increment count for error */ restore_state: RETURN (DB); RESTORE_STACK RESTORE_FRAME return_pm_len: R0=PASS R8, pm_ptr=R8; /* Hold string start */ DO find_pm_end UNTIL EQ; /* Loop until NULL */ find_pm_end: IF NE R8=PASS R8, R8=PM(pm_ptr,pm_1); R0=R0+1, MODIFY(pm_ptr, pm_M1); /* Back up to NULL */ JUMP (PC, restore_state) (DB); R8=pm_ptr; R0=R8-R0, MODIFY(pm_ptr, pm_M1);/* Compute length */ .ENDSEG;