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 ?

vikkyhacks
  • 3,190
  • 9
  • 32
  • 47

1 Answers1

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