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 ?
Asked
Active
Viewed 2,948 times
3

vikkyhacks
- 3,190
- 9
- 32
- 47
-
What OS are you writing for? Windows, or Linux, or another platform? – Brenton Fletcher Jul 29 '13 at 03:47
-
1I use ubuntu, but I'd like to keep the discussion to both windows and linux with linux having the greater priority – vikkyhacks Jul 29 '13 at 03:58
1 Answers
2
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

old_timer
- 69,149
- 8
- 89
- 168
-
Thanks that was very promising, but is there any way to do it the nasm way. I see that you are using gas assembler !!! – vikkyhacks Jul 29 '13 at 18:45
-
I am sure it is very similar, simply define data however nasm wants and whatever global linker variables global _start or something like that... – old_timer Jul 29 '13 at 19:03