Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: byte data manipulation

Reply
Thread Tools

Re: byte data manipulation

 
 
Niv (KP)
Guest
Posts: n/a
 
      04-27-2009
On 26 Apr, 17:23, Han from China <(E-Mail Removed)>
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
 
Reply With Quote
 
 
 
 
Niv (KP)
Guest
Posts: n/a
 
      04-27-2009
On 27 Apr, 13:18, "Niv (KP)" <(E-Mail Removed)> wrote:
> On 26 Apr, 17:23, Han from China <(E-Mail Removed)>
> 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.
 
Reply With Quote
 
 
 
 
James Kuyper
Guest
Posts: n/a
 
      04-27-2009
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
byte data manipulation Niv (KP) C Programming 14 05-04-2009 05:10 PM
read/write data byte-per-byte to and from a socket crash.test.dummy Java 1 02-17-2006 06:18 AM
byte manipulation in Java ? Ph. Barthelemy Java 3 09-02-2004 03:56 PM
Re: byte manipulation in Java ? monroeds@hampton-data.com Java 2 09-02-2004 12:44 PM
Single byte addressable, multiple byte readout. Andreas VHDL 1 05-04-2004 01:49 PM



Advertisments