[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: Counting records in a binary file
- From: "Jeff Wise" <jwise@...>
- Date: Mon, 15 Sep 2008 11:13:41 -0500
> - convert bytes 2,3 to a number 'N'
> - skip N bytes
I'm sorry, but I have no clue how to convert bytes 2,3 to a number, nor how to skip N bytes. Can you elaborate, perhaps a code snippet?
In my world, assuming reg 2 points to the first byte:
SR R10,R10 Zero count register
LOOP DS 0H
CLI R2,X'5A' Is first byte 5A?
BNE NO5A No, skip processing
LA R10,1(,R10) Bump count reg by 1
LH R3,1(,R2) Pick up halfword length
LA R2,1(R3,R2) Accommodate the length field
B LOOP Go to Loop
NO5A DS 0H
* Bad data, no '5A' header
I do realize this code doesn't look for the end of the data...
From: firstname.lastname@example.org [mailto:email@example.com] On Behalf Of Javier Guerra
Sent: Monday, September 15, 2008 10:43 AM
To: Lua list
Subject: Re: Counting records in a binary file
On Mon, Sep 15, 2008 at 10:07 AM, Jeff Wise <firstname.lastname@example.org> wrote:
> ➢ ignore it, and don't waste time trying to use it
> I must count the records. Each record begins with '5A'. After this '5A' is a 2 byte length but it does not account for the '5A'. Unfortunately "gsub" will not count the records because there are '5A' embedded. Here is an example of the form '5A', nnnn, data bytes.
if you're not interested in the records content, then just:
- read three bytes
- assert the first is a '5A' (optional, just for checks)
- convert bytes 2,3 to a number 'N'
- skip N bytes
No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.169 / Virus Database: 270.6.21/1671 - Release Date: 9/14/2008 7:16 AM