Re: byte data manipulation

Discussion in 'C Programming' started by Niv (KP), Apr 27, 2009.

  1. Niv (KP)

    Niv (KP) Guest

    On 26 Apr, 17:23, Han from China <>
    wrote:
    > Richard wrote:
    > > And a far less long winded and easier on the eye (to me)

    >
    > Yeah, I don't enjoy reading code with too much vertical space,
    > which usually means Allman style, superfluous braces, and
    > fully unrolled logic reminiscent of a RISC assembly dump. It's
    > irritating to browse, and trivial functions end up looking
    > as though they're important, whereas they should be tight,
    > terse, and out of the way. Only a style opinion, of course.
    >
    >   "Bob went to check the mail."
    >
    > vs.
    >
    >   "Bob retrieved
    >    {
    >       the door key from his pocket
    >    }
    >    and inserted it into the pin-tumbler
    >    lock of his front door, hearing
    >    {
    >       the pins align with gentle
    >    }
    >    clicks on the shear line. Bob then
    >    made a conscious
    >    choice
    >    {
    >       to
    >    }
    >    turn the key, sending a nerve impulse
    >    ..."
    >
    > Yours,
    > Han from China
    >
    > --
    > "Only entropy comes easy." -- Anton Chekhov


    First major hurdle: can't seem to declare an array of "unsigned char"
    much greater than 1030000, (a bit less than 1Mbyte) so how to
    overcome?
    This is going to make it difficult to fill 2 arrays, each of 2Mbyte!

    I'm using Borland BuilderX as my compiler btw.

    Niv
     
    Niv (KP), Apr 27, 2009
    #1
    1. Advertising

  2. Niv (KP)

    Niv (KP) Guest

    On 27 Apr, 13:18, "Niv (KP)" <> wrote:
    > On 26 Apr, 17:23, Han from China <>
    > wrote:
    >
    >
    >
    >
    >
    > > Richard wrote:
    > > > And a far less long winded and easier on the eye (to me)

    >
    > > Yeah, I don't enjoy reading code with too much vertical space,
    > > which usually means Allman style, superfluous braces, and
    > > fully unrolled logic reminiscent of a RISC assembly dump. It's
    > > irritating to browse, and trivial functions end up looking
    > > as though they're important, whereas they should be tight,
    > > terse, and out of the way. Only a style opinion, of course.

    >
    > >   "Bob went to check the mail."

    >
    > > vs.

    >
    > >   "Bob retrieved
    > >    {
    > >       the door key from his pocket
    > >    }
    > >    and inserted it into the pin-tumbler
    > >    lock of his front door, hearing
    > >    {
    > >       the pins align with gentle
    > >    }
    > >    clicks on the shear line. Bob then
    > >    made a conscious
    > >    choice
    > >    {
    > >       to
    > >    }
    > >    turn the key, sending a nerve impulse
    > >    ..."

    >
    > > Yours,
    > > Han from China

    >
    > > --
    > > "Only entropy comes easy." -- Anton Chekhov

    >
    > First major hurdle: can't seem to declare an array of "unsigned char"
    > much greater than 1030000, (a bit less than 1Mbyte) so how to
    > overcome?
    > This is going to make it difficult to fill 2 arrays, each of 2Mbyte!
    >
    > I'm using Borland BuilderX as my compiler btw.
    >
    > Niv- Hide quoted text -
    >
    > - Show quoted text -


    More info:

    1. The input file is an intel s record, and we (me) assume it has been
    correctly built by the fpga compiler.
    2. The input file is a always less than 2Mbytes in data content, but
    maybe more with preamble & checksum.
    3. I need to read in the input file, throwing away the preamble and
    checksum, and put the data bytes into an array, which has been pre-
    filled with all '0's (or "00" as unsigned chars?).
    4. I then copy the full 2 Mbytes data bytes in this array to a second
    array in a non-linear address fashion.
    5. I write out the second array in a linear fashion, 16 bytes at a
    time, adding back in the preamble and a newly calculated checksum at
    the end. The preamble value will come from a counter for the address,
    fixed pattern for data type, and fixed pattern for length (always 16
    bytes).
    6. Address modifiers will also be written out as required. (These
    occur every 64 Kbytes because 4 bit address space in s-record only
    caters for that much). (Also calulated from the address counter, but
    higher bits).

    I'm getting nowhere with this despite the suggestion offered so far.
    Just my complete lack of C knowledge really, (but trying). I think one
    problem is I keep resorting to VHDL &/or Tcl syntax, which i sort of
    know. Doh!

    Niv.
     
    Niv (KP), Apr 27, 2009
    #2
    1. Advertising

  3. Niv (KP)

    James Kuyper Guest

    Niv (KP) wrote:
    ....
    > First major hurdle: can't seem to declare an array of "unsigned char"
    > much greater than 1030000, (a bit less than 1Mbyte) so how to
    > overcome?


    It's often the case that you can allocate memory using malloc() for a
    larger array than you can declare.

    Alternatively, you may need to figure out a way to organize your
    algorithm so that it doesn't require that the entire array be in memory
    at the same time. This is almost always possible, though often at
    significant cost in performance. But being able to do something slowly
    is often better than not being able to do it at all.
     
    James Kuyper, Apr 27, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andreas
    Replies:
    1
    Views:
    861
    Jonathan Bromley
    May 4, 2004
  2. Ph. Barthelemy

    byte manipulation in Java ?

    Ph. Barthelemy, Sep 1, 2004, in forum: Java
    Replies:
    3
    Views:
    7,383
    Ph. Barthelemy
    Sep 2, 2004
  3. Replies:
    2
    Views:
    768
    Dave Monroe
    Sep 2, 2004
  4. crash.test.dummy
    Replies:
    1
    Views:
    944
    Knute Johnson
    Feb 17, 2006
  5. Niv (KP)

    byte data manipulation

    Niv (KP), Apr 25, 2009, in forum: C Programming
    Replies:
    14
    Views:
    928
    Flash Gordon
    May 4, 2009
Loading...

Share This Page