Reading hex data from assembler


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Reading hex data from assembler
# 8  
Old 03-26-2010
yes I am aware of the meta data of the file.
# 9  
Old 03-26-2010
Do you think it is possible to use cut and dd to copy the easy parts, and then write a script to translate the binary/packed decimal, then put it back together.

Something like:

echo `cut -c1-100` >>output
echo `cut -c101-110 >>packeddecimal
echo `cut -c 111- ` >>output2


then
while read pd
do
convert pd >>packdecimal2
done <packeddecimal


Then
Paste the files back together.
# 10  
Old 03-26-2010
1) Do you have the code of the program which wrote the file?
2) Was the file created on your current server? If not, what server was it?
(This is a dig for byte-reversal).
3) Is it the file fixed-length records?
4) Is it a file with line-feed as the record terminator?
5) How long is each record?
6) How many records?
7) What is the record layout? What is the picture of each field?
8) Can you post a sample of a few records in hexadecimal (blotting anything confidential with FF or 00), showing how you would expect the conversion to take place.
9) You you have any high-level languages on your server?
10) Any chance of getting the file written in a more suitable format for a unix server?
11) jgt has the best suggestion so far (use Cobol).
# 11  
Old 03-27-2010
From previous posts,
Code:
pd=`cut -c101-104`       #4 byte packed decimal field
                                   # Cobol PIC S9(7) COMP-3 
echo (-e) "$pd\c" |hd |pd2disp   # (-e) optional SUSE yes, SCO no

where pd2disp

Code:
read discard a b c d e f
digit=`echo $d|cut -c1`
sign=`echo $d|cut -c2`
if [ $sign = f ]
then
  echo "$a$b$c$digit+\c"                  
# Cobol PIC S9(7) SIGN IS TRAILING SEPARATE CHARACTER
else
  echo "$a$b$c$digit-\c"
fi

hd (hexadecimal dump) is the equivalent of debug on DOS systems. It is part of the base utilities on SCO systems, but is not on my SUSE system.

So hd is hexdump. The output is the same data, but the presentation is different

pd2disp would change as follows

Code:
read discard a c 
b=`echo $a|cut -c1-2`
a=`echo $a|cut -c3-4`
d=`echo $c|cut -c1-2`
c=`echo $d|cut -c3-4`
sign=`echo $d|cut -c2`
digit=`echo $d|cut -c1`


Last edited by jgt; 03-27-2010 at 09:19 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reading in data that has spaces in it.

I have a csv file called template.csv which has the following data Name, Age, Height Jessica Jesse, 18, 150 Now what I want to do is use a shell script to read the name age and height which looks like this: #!bin/sh INPUT='template.csv while read Name Age Height do echo... (2 Replies)
Discussion started by: JSNY
2 Replies

2. Shell Programming and Scripting

how to get data from hex file using SED or AWK based on pattern sign

I have a binary (hex) file I need to parse to get some data which are encoded this way: .* b4 . . . 01 12 .* af .* 83 L1 x1 x2 xL 84 L2 y1 y2 yL By another words there is a stream of hexadecimal bytes (in my example separated by space for better readability). I need to get value stored in... (3 Replies)
Discussion started by: sameucho
3 Replies

3. Programming

What is the difference between ios::hex and std::hex?

Hi, Is there really a difference between these two, std::hex and ios::hex?? I stumbled upon reading a line, "std::ios::hex is a bitmask (8 on gcc) and works with setf(). std::hex is the operator". Is this true? Thanks (0 Replies)
Discussion started by: royalibrahim
0 Replies

4. Programming

After converting the hexstr to Hex and storing the Hex in a char*

Hi All, My main intension of is to convert the Hexstring stored in a char* into hex and then prefixing it with "0x" and suffix it with ',' This has to be done for all the hexstring char* is NULL. Store the result prefixed with "0x" and suffixed with ',' in another char* and pass it to... (1 Reply)
Discussion started by: rvan
1 Replies

5. Programming

Data formating using C programm with Hex deciamal 'x0d'

:b:Guys, Can some body throw some light on this please..... sprintf(req_line1, "%c%s%c", '\x0b',"TESTING1",'\x0d'); sprintf(req_line2, "%s%c", "TESTING2", '\x0d'); sprintf(req_line3, "%s%c", "Testing3", '\x0d'); sprintf(req_line4, "%s%c%c%c", "Testing4", '\x0d', '\x1c', '\x0d'); ... (6 Replies)
Discussion started by: sudharma
6 Replies

6. Programming

How to use assembler (as) in UNIX? [I got errors using assembler]

Hi, folks, I have a simple program main.c. The program is very simple, just for testing purpose. The program was proven correct by using "gcc". Now I would compile it step by step from main.c to main.o. Here is what I did: cpp main.c main.i <This step succeeded> cc main.i -o... (5 Replies)
Discussion started by: meili100
5 Replies

7. Programming

reading reading data from webpage

hi iam reading data from web page using request socket and curl socket. now my problem is some the web page containg data as a image so how can i read the data from a image. thank,inadvance. sree (3 Replies)
Discussion started by: phani_sree
3 Replies

8. Shell Programming and Scripting

Using loop reading a file,retrieving data from data base.

Hi All, I am having trouble through, I am reading the input from tab delimited file containing several records, e.g. line1 field1 field2 field3 so on.. line2 field1 field2 field3 so on.. .. .. on the basis of certain fields for each record in input file, I have to retrieve... (1 Reply)
Discussion started by: Sonu4lov
1 Replies

9. UNIX for Advanced & Expert Users

hex data conversion

Dear friends, I have hexadecimal data like this. now i want to read each letter and convert to decimal format. for example.: from the below data first i have to read hex data 0 and convert to 4 bit decimal value ie 0000. similarly second letter 8 decimal value is 1000. like this.... (6 Replies)
Discussion started by: rajan_ka1
6 Replies

10. Shell Programming and Scripting

Column data reading

Experts I am new to UNIX shell programming ( or scripting). My problem is that I have an ASCII file in which column wise data is present, the columns are seperated by spaces. I want to read each columns data and store it in arrays, next I will be using the arrays to perform some numerical... (1 Reply)
Discussion started by: FarhanNaseer
1 Replies
Login or Register to Ask a Question