3

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 ?

2
  • What OS are you writing for? Windows, or Linux, or another platform? Commented Jul 29, 2013 at 3:47
  • 1
    I use ubuntu, but I'd like to keep the discussion to both windows and linux with linux having the greater priority Commented Jul 29, 2013 at 3:58

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks that was very promising, but is there any way to do it the nasm way. I see that you are using gas assembler !!!
I am sure it is very similar, simply define data however nasm wants and whatever global linker variables global _start or something like that...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.