Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

public hex to asm possible to get

Status
Not open for further replies.
c_mitra it does not work same only shows a dot,and i have re-tried last both files

The source code files you have posted are different but compiles ok.

I shall try to edit the hex file...
 

.Can you try the last one mw104.zip .

Yes, I have finally modified the mw104.zip (this appears to be a newer file). The corrected file is attached here:View attachment final.zip

You need to unzip and upload the final.hex - fortunately the code was not protected for modification.

I have modified only the first line and you should now see REVE FM LEBANON displayed.

If this works, I shall outline the steps on how to edit the text in the hex file.

Good luck.
 
Thanks c_mitra my freind but i need for tomorrow to reply .
regards.
 

I can say C_mitra , we get what we need finally ,but there is minor error in the name LEBANON .
 

Attachments

  • 20191117_221107.jpg
    20191117_221107.jpg
    484.1 KB · Views: 97
  • 20191117_221300.jpg
    20191117_221300.jpg
    499.9 KB · Views: 96

but there is minor error in the name LEBANON .

It is my fault; I did not double check. I should have.

Now that it is working, I can tell you how I did edit the hex file OR I can do the correction.

I did edit the file in vim; it has context color and is not difficult.

There may be other editors, but the hex file is a text file (this is intel format file; hex bytes are written in ASCII). There is a specific format for each line of text.

I shall edit them and send you again.

- - - Updated - - -

I shall edit them and send you again.

The error corrected file is here: View attachment final1.zip

This is the last attempt! I am getting bored with editing!
 
hi no please dont get bored ,yes i know it is boring but i need to learn a bit ,i hvae downloaded the vim software ,but i need the steps to ,if i want to change anything later thanks .i have teamviwer ?
I can tell you how I did edit the hex file OR I can do the correction.

- - - Updated - - -

final1.zip it is not working only dots

- - - Updated - - -

34 46 33 34 35 41 33 34 33 32 33 34 34 33 33 34 37 32 0D 0A 3A 31 30 31 36 35 41 30 30 35 30 33 34 35 35 33 34 32 30 33 34 34 34 33 34 34 39 33 34 34 37 33 34 34 39 33 34 35 37 33 34 41 37 0D 0A 3A 31 30 31 36 36 41 30 30 34 31 33 34 35 34 33 34 35 34 33 34 34 44 33 34 34 35 33 34 35 34 33 34 34 35 33 34 35 32 33 34 36 41 0D 0A 3A 31 30 31 36 37 41 30 30 30 30 33 34 34 46 33 34 35 41 33 34 33 32 33 34 34 33 33 34 35 30 33 34 35 35 33 34 32 30 33 34 44 44 0D 0A 3A 31 30 31 36 38 41 30 30 34 34 33 34 34 39 33 34 34 37 33 34 34 39 33 34 35 37 33 34 34 31 33 34 35 34 33 34 35 34 33 34 35 33 0D 0A 3A 31 30 31 36 39 41 30 30 34 44 33 34 34 35 33 34 35 34 33 34 34 35 33 34 35 32 33 34 30 30 33 34 35 36 33 34 36 35 33 34 36 38

is this where have you edit ?
 

Sorry, I must have made some mistake in the editing. I am outlining the steps to be followed with some screenshots.

1. Start with the last working file, final.zip, extract it to get final.hex. This file has some mistakes and we wish to change /correct that.

2. I use vim for this; when I use vim final.hex, I get the output. (pic below).

Screenshot from 2019-11-19 09-51-02.png

This is the hex image in intel format. Each line is one record; first two chars (one byte) tells the number of bytes in the record. Next four chars (two bytes) are the address. Next 16 bytes (32 chars) are the data. Last two chars are the checksum for this record.

The color coding has been done by vim.

When we change a byte, we must also recalculate the checksum.

Let us see how to locate the string. First we search for the char L:

We type in vim /4C to look for the char L. But there may be some that are not part of the data string. So we cannot change at random.

We type :%s/4C//gn in vim. We see that the char L occurs 50 times. So we go for another char. This time we search for "!"
In vim I type /21. We see where they are present.

Finally we locate them in address line 165A. Look up an ascii table ans see that the ascii codes for LEBANON are 4C 45 42 41 4E 4F 4E

(see next post)

- - - Updated - - -

Searching is messy because they may not occur on the same line. ALso note that each char is separated by hex 34.

Search /4C344534 and you will that it is presence only once ... (it should be present twice but because of the spelling error)

Now we know that we have typed LF (by mistake) - so we search for /4C344634.

We reach the line that needs correction. Address line 168A.

in this line change 46 to 45. Also change 21 (code for !) to 41 (code for A). That is all.

Wait, we have made some changes to the file and the checksum is now to be corrected.

Open a calculator in hex mode. And add the following: 10 +16 +8A +20 +34 +4C+ 34 +45 +34 +42 +34 +41 +34 +4E +34+ 4F +34 +4E +34

(number of bytes + address two bytes + data bytes (sixteen in this case): in this case 46F. We take twos complement and take the last byte: 91.

We must put the correct checksum in line 168A (the last byte is the checksum). We replace B0 with 91.

Now you save and exit. (command is :x in vim).

That is all, load and run!

- - - Updated - - -

In the screenshot, vim is saying [dos] on the status line; by mistake I opened the file without the -b option. You should open the hex file in binary mode (i.e., vim -b final.hex)- otherwise other stuff may be written in the file.

After the edit, the original file (you kept a copy, right?) and final file must have he same size.

Also a diff orig.file chang.file should show only one line (because we have modified only one line).

I hope I have made the basics clear.
 
Hi i knew that you Helped me a lot lot ,and this thread began to be long and maybe boring for others ,and you put lots of energie and work and effort and time ,but thoses they are hard to me to understand because i dont have that basic ,i will try to learn what you did but i am sure it would took a lot of time and maybe i will not achieve my goal.so i would save thoses instructions guide for a to do ,OKAY i should try myself thoses simple instruction to learn a bit ,and if i will not succssed because i am not so familiar ,then i will ask to corrrect ,please keep an eye from moment to moment
regards .
thanks edaboard.
 
Last edited:

Patching a HEX file is not something we would normally do so don't worry about learning it too much. Having said that, I think most of us 'more experienced' engineers have had to do it once or twice in the past.

You are not changing the software itself, you are manually searching for the characters in the binary file the MCU runs and substituting new ones then modifying the checksum to keep the programming hardware happy.
It works but there are some drawbacks:
1. the characters are in the middle of other code and you can't move that code, that means your new text must be the same length as the old one.
2. you have to manually re-calculate the checksum as c_mitra explained, the final byte is used by the programming hardware to confirm the whole line is good so you have to compensate for your changes.
3. the program you are editing may be encrypted or may do its own internal checks to confirm the text hasn't been changed, to protect against piracy for example.
4. sometimes the whole program is verified with a checksum, either in the HEX file or by some internal routine (PC BIOS for example). This is much harder to edit because there can be other changes hidden in the HEX file.
5. the characters may not be in standard ASCII code. If they use UTF coding for example, each character you see on the LCD may be more than one byte in the HEX file.

Re-compiling for source code is the best way by far because it creates a new HEX file for you with all the changes and checksums freshly calculated. I'm not sure why c_mitra's source edits didn't work but I suspect it is because a HEX file can also contain a section that isn't part of the program itself but is instructions to the programming hardware to configure the MCU. If that is missing the program will appear to compile but it will not run or behave unpredictably in real silicon.

Brian.
 

Patching a HEX file is not something we would normally do so don't worry about learning it too much....

You are correct; but this is a nice exercise for a beginner.

Fortunately the code was not protected. PIC HEX files can be resistant to editing if they are code protected. However, I do not know how that works exactly.

Fortunately I had the original source (but that did not work because of some other errors) and I see that the strings have been defined in one place - all with a fixed 20 char length- padded with space. We were double luckey!

Fortunately, the display can take only ASCII chars (it can display custom char but that is a hassle).

The original poster gave me the source and it compiled ok but I could not follow the logic. And it did not work- for some strange reasons. I could not debug because I did not follow the logic.

If there were a checksum for the whole file, that would have increased the work load. But it could have been done.

The program is very old and written carelessly. But that is a different story.

I moved some of the __CONFIG statements to #pragma. Some of the in-build variable names have been changed (and I modified them too).

But it is tough to modify if you do not follow the logic.

I have used PIC for some projects eons ago; but the student did most of the work and I mostly supervised and debugged the program.

My point is that the software and the hardware cannot be divorced; the user must learn both as a package.

MPLAB IDE is also having lots of bugs (it flags errors that are not really errors)- but that is a different story in another direction.
 

Thanks for you both for every teaching.
C_mitra there still my freind a little error ONLY in the first page and not in the end ,the error is in the name , i have already said that before ,but maybe you have not seen it,only one character is wrong ,instead of LEBANO n you put another char ,this is the only mistake ,please correct it .:clap:
 

Attachments

  • last error.jpg
    last error.jpg
    503.7 KB · Views: 92

I thank you very much c_mitra ,because you took a long time to mind on me and helped me.Worked okay .
 

because you took a long time to mind on me and helped me.Worked okay...

It took long time because I made mistakes after mistakes. I made mistakes not because I did not know how to do but because I was not careful enough.

I am glad that it worked. Happy coding and recoding.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top