I
I
Inkvidim2015-04-24 10:57:22
Programming
Inkvidim, 2015-04-24 10:57:22

How to write "Hello World" in machine code?

Recently I came across a video where some crazy person wrote a program that prints the words "Hello World" in binary / machine code to the console (to be honest, I'm not sure what it is).
Link to video.
Please tell me how you can repeat the result (do not advise copying the code from the video, I want to understand exactly how to do this)? Is there any literature on this?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
A
asd111, 2015-04-24
@Inkvidim

You just need to study the assembler and everything will become clear.
Each assembler instruction is translated "verbatim" into machine code.
Those. for example, the command pushl %edxwill turn into one byte 82
. For example, an assembler program:

push %ebp
mov %esp,%ebp
call 0x8048298 
cmp $0x41,%eax
jne 0x80483ce 
push $0x80484b0
call 0x80482c8 
add $0x4,%esp
mov $0x0,%eax
mov %ebp,%esp
pop %ebp
ret

will turn into machine code:
0x55 0x89 0xe5 0xe8 0xfc 0xff 0xff 0xff
0x83 0xf8 0x41 0x75 0x0d 0x68 0x00 0x00
0x00 0x00 0xe8 0xfc 0xff 0xff 0xff 0x83
0xc4 0x04 0xb8 0x00 0x00 0x00 0x00 0x89
0xec 0x5d 0xc3

You can read here and here . In general, any book on assembler will do.

K
Kirill Olenev, 2015-04-24
@agent10

"Stop the Earth - I'll get off.."
Do you know any programming language?

R
Rsa97, 2015-04-24
@Rsa97

There is nothing special there. Take any program, open it in a hex editor, print out a hex or bin representation, open a new document in a hex editor, type the dump manually, save it, run it.

S
Spetros, 2015-04-24
@Spetros

Wikipedia has a related article Machine Code

M
Mrrl, 2015-04-24
@Mrl

There is an example on SO how to do this in assembler using kernel32.lib:
stackoverflow.com/questions/1023593/how-to-write-h...
You can try to start from there, then learn how to translate it into machine code (for example, by looking to an assembler listing).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question