Translating code

I have seen that operating systems like windows, apple, and android all use some sort of hexadecimal code language, which is obviously not human friendly. (I hope I am using that term correctly)

Is there some way or program I can use to translate them into a language I can read, such as JavaScript. And then back again if I modify them?

Thanks in advance for the help :grinning:

Hello @8-bitgaming, could you show an image of what you are referring to? I’m curious as well. You don’t mean binary, do you?

I have seen that operating systems like windows, apple, and android all use some sort of hexadecimal code language, which is obviously not human friendly. (I hope I am using that term correctly)

That’s the difference between high-level and low-level languages.

Example:

Ascii

Hello World

Hex

48 65 6C 6C 6F 20 77 6F 72 6C 64

Binary

01001000 01100101 01101100 01101100 01101111 00100000 01110111 01101111 01110010 01101100 01100100

This is precisely why people created languages that have a very high level of abstraction.

High-level languages do a lot “under the hood” to make things simpler for us.

They’re human-friendly. Binary is machine-friendly. Because computers cannot understand human-friendly languages.

For example, in Go you’d write

fmt.Println("Hello World")

You’ll then have to compile this into a binary executable that the machine can understand.

So the compiler will translate high-level into low-level. Makes sense.

All languages translate into machine code. Some languages are compiled, like Go, C++, Java, Swift, others are interpreted, like JavaScript, Python, Ruby, PHP.

Is there some way or program I can use to translate them into a language I can read, such as JavaScript. And then back again if I modify them?

So you want to reverse engineer? You could use a decompiler I guess (the opposite of the compiler)

https://www.hex-rays.com/products/decompiler/

And you could then recompile.

But I don’t think you’ll find a decompiler that translates to JavaScript. You’ll have to look it up.

This is used a lot in software security. And I guess in cracking as well. So, careful on your use case.

Also keep in mind that source code is often considered commercial secret, and can be protected by law. If it’s not open-source, you’ll want to be careful how you treat such code / what you do with it.

Hope this answers your question

2 Likes

Here is an example of the process of C code being broken down into machine code.
C code
a = b + 3 # add three and b and store in a

Gets compiled into assembly code - I’m going to use risc - v instructions
Assembly
addi x5, x7, 3 # same meaning as c code

This get broken down into binary machine code - according to a format determined by your computer architecture.

Risc - V machine code 32 bit instruction
00000000011 00111 000 00101 0010011
Don’t worry about what the binary means exactly, it is telling the machine to do a certain operation to certain areas of memory.

Now that binary could be stored as hexadecimal as you’ve seen
Hex representation of machine code
00338293

and that is how a = b+3 ends up being 00338293.

1 Like

Basically to get into reverse engineering code, you need to learn about architecture. That is a long way away! Focus on learning high level programming for now, the low level stuff will follow

Thanks very much @ghostlovescore! That was a lot of very helpful information. :grinning:

1 Like

Thank you very much for your advice @fight_dragons, but I have been doing high level code for a number of years now, and I am ready to begin expanding my knowledge.

I’d google various stuff like, cpu architecture, assembly, logic design, fetch-decode-execute, conversions between number systems. The godbolt compiler explorer is a great tool for seeing generated assembly.

1 Like