I have a small C function and I want to make a hex file for it.
Running
gcc -c in.c
makes an object file But I need hex file for this standalone function. I need to put this on a separate location, so that I can simply JMP to this location from my main code. But I want this to be in hex format.
I cant do a -
gcc -c in.c -o in.hex
This is not working.. Please help me out..
Click "File," then "Save As" to save the text file to your hard drive. Choose the file extension HEX instead of the typical Notepad extension TXT. Doing so will allow any program that reads data from HEX files to read your hexadecimal code.
Intel hexadecimal object file format, Intel hex format or Intellec Hex is a file format that conveys binary information in ASCII text form. It is commonly used for programming microcontrollers, EPROMs, and other types of programmable logic devices and hardware emulators.
HEX files are supported by several editors, including Heaventools FlexHex, Hex Workshop Hex Editor, and HexEdit. If you have a binary HEX file, it can only be opened with hex-editing programs. If you have a text-based HEX file, it can also be opened and edited with a text editor.
By using objcopy
we can make hex file
gcc -c example.c
objcopy --change-address 0xE0000 -O ihex example.o example.hex
it will generate example.hex
file
use Bless Hex Editor
to see the .hex file clearly
First you need to use the linker ld
to create a raw binary binary file. Then use objcopy
to create the hex file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With