I have been working with assembly level programming lately and I am able to convert the assembly level code to the machine level code using nasm or as and extract the hex code from it, But how is the inverse possible ? I need to write binary executable files with only the hex being given. I need to convert the following hex 7a\x65\x00\x5f\x73\x74\x61\x72\x74\x00\x5f\x5f\x62\x73\x73\x5f\x73\x74\x61\x72\x74\x00\x5f\x65\x64\x61\x74\x61\x00\x5f\x65\x6e\x64\x00 to an executable, How do I do it ?
-
What OS are you writing for? Windows, or Linux, or another platform?Brenton Fletcher– Brenton Fletcher2013-07-29 03:47:46 +00:00Commented Jul 29, 2013 at 3:47
-
1I use ubuntu, but I'd like to keep the discussion to both windows and linux with linux having the greater priorityvikkyhacks– vikkyhacks2013-07-29 03:58:15 +00:00Commented Jul 29, 2013 at 3:58
Add a comment
|
1 Answer
a.s:
.globl _start
_start:
.byte 0x7a,0x65,0x00,0x5f,0x73,0x74,0x61,0x72,0x74,0x00,0x5f,0x5f,0x62,0x73,0x73,0x5f,0x73,0x74,0x61,0x72,0x74,0x00,0x5f,0x65,0x64,0x61,0x74,0x61,0x00,0x5f,0x65,0x6e,0x64,0x00
gnu toolchain commands
as a.s -o a.o
ld a.o -o a
EDIT
it took longer to type this edit than do the google search
nasm syntax:
global _start
_start:
db 0x7a,0x65,0x00,0x5f,0x73,0x74,0x61,0x72,0x74,0x00,0x5f,0x5f,0x62,0x73,0x73,0x5f,0x73,0x74,0x61,0x72,0x74,0x00,0x5f,0x65,0x64,0x61,0x74,0x61,0x00,0x5f,0x65,0x6e,0x64,0x00
2 Comments
vikkyhacks
Thanks that was very promising, but is there any way to do it the nasm way. I see that you are using gas assembler !!!
old_timer
I am sure it is very similar, simply define data however nasm wants and whatever global linker variables global _start or something like that...