🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

3 total messages Started by psyxsgp Mon, 24 Jun 1991 19:23
bit reversal of a C array in '30 code
#2060
Author: psyxsgp
Date: Mon, 24 Jun 1991 19:23
10 lines
763 bytes
Hi,
	Could anyone tell us how to zero align an array
generated in C, but calling an assembler routine in
tms320c30 code which does bit reversal.
	Have tried setting 'align' in the .cmd file used by 
the linker, unsuccessfully ..inspection of the .map file 
shows variables beginning at any memory location ..
though I might have got things wrong there
Thanks
Stephen Pearce
Re: bit reversal of a C array in '30 code
#2063
Author: Dave Mc Mahan
Date: Wed, 26 Jun 1991 05:27
58 lines
2393 bytes
 In a previous article, psyxsgp@otago.ac.nz writes:
>Hi,
>    Could anyone tell us how to zero align an array
>generated in C, but calling an assembler routine in
>tms320c30 code which does bit reversal.

One way to long word-align an array is to put it in a seperate segment,
and then ensure that the segement starts on the proper boundry.  Failing
that, you can do it at run-time.  The code isn't pretty, but it does work.

The trick to this is to declare an array that is 4 bytes larger than you
really need.  You then set a pointer to the first location in the array,
add 4 to the pointer, and then logically AND the pointer with ~(3) to
force it to contain a value that MUST fall on the proper boundry.  This gets
a little messy if you have strict type-checking, but fortunately 'C' doesn't
do that.  The code might be something like this:

#define    MYSIZE    100    /*  Size in bytes you want, not size of
                                longwords you will eventually use.
                            */

static    char  dumb_array[MYSIZE+4];

    long        *ptr_to_use;

main()
{

    /*  Notice the use of casting to prevent the compiler from complaining
        about the fast-and-loose type conversions.
    */

    ptr_to_use = (long *)(&dumb_array[4]);
    ptr_to_use = (long *)((long)ptr_to_use & ~3L);

    ptr_to_use[0]  = 6;
    ptr_to_use[24] = 9943;     /*  This is the last element of the array
                                    that you can safely use.  Anything bigger
                                    may fall outside the declared array.
                               */
}    


Caveat:  I haven't compiled this example, but it should work.  I have used
         this technique before when I had to force alignment within my data
         and couldn't get the compiler to do it for me.


>Stephen Pearce



   -dave

-- 
Dave McMahan                            mcmahan@netcom.com
					{apple,amdahl,claris}!netcom!mcmahan
Re: bit reversal of a C array in '30 code
#2068
Author: Andrew E Page
Date: Fri, 28 Jun 1991 14:09
33 lines
1707 bytes
In article <1991Jun26.052754.5772@netcom.COM> mcmahan@netcom.COM (Dave Mc Mahan) writes:
>
> In a previous article, psyxsgp@otago.ac.nz writes:
>>Hi,
>>    Could anyone tell us how to zero align an array
>>generated in C, but calling an assembler routine in
>>tms320c30 code which does bit reversal.
>
>One way to long word-align an array is to put it in a seperate segment,
>and then ensure that the segement starts on the proper boundry.  Failing
>that, you can do it at run-time.  The code isn't pretty, but it does work.
    ^^^^^^^^^

Bear in mind that ALL words in a TMS320C30 (chars, ints, longs) are always
going to be 32bits in length.  There is no need to allign data generated
in C~r (for the C30 thatis) in order to align in in it's memory. 

Second...

  The ALIGN operator in the cmd linker aligns to PAGE boundaries which
are necessary for bit reverse and circular address buffers.  


Third:

IN the originail posting when you said 'zero align' exactly what do you 
mean by this?  


-- 
Andrew E. Page (Warrior Poet)   |   Decision and Effort The Archer and Arrow
Concepts Enginerring            |     The difference between what we are
Macintosh and DSP Technology    |           and what we want to be.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads