Author Topic: x86 machine code  (Read 2257 times)

0 Members and 1 Guest are viewing this topic.

Offline Ephraim B

  • LV2 Member (Next: 40)
  • **
  • Posts: 28
  • Rating: +1/-1
    • View Profile
x86 machine code
« on: February 19, 2015, 09:42:29 am »
I feel like those high level languages are not actual programming, for example, there's a whole compiler to compile ASM down to machine code and a whole #include file to compile C down to machine code. I feel like this is cheating and anyone can make mistakes on a compiler. I feel like machine code is actual programming. Is there any tutorials for x86 machine code?





Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6198
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: x86 machine code
« Reply #1 on: February 19, 2015, 01:15:08 pm »
A quick google search will answer this question for you.
This forum is not a search engine, please use it for asking specific questions about the language, or about specific tutorials you have already found.
/e

Offline harold

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 226
  • Rating: +41/-3
    • View Profile
Re: x86 machine code
« Reply #2 on: February 19, 2015, 01:27:16 pm »
Well not really, but there is plenty of information to get started, in the form of assembly tutorials, the Intel manuals (or the AMD manuals if you want), and this handy ModRM table.

Encoding x86 instructions isn't too bad once you know how they work, for example take "add r8, [r10 + 8 * r9 + 8]". This is of the form add r64, rm64, so that'll be REX.W 03 /r. The rm operand needs a SIB byte, so the ModRM and SIB are 44 CA, also REX.B, REX.X and REX.R should be set, and the ofs8 is 8. So in total: 4F 03 44 CA 08
Blog about bitmath: bitmath.blogspot.nl
Check the haroldbot thread for the supported commands and syntax.
You can use haroldbot from this website.

Offline Ivoah

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +3/-0
    • View Profile
    • Codinghobbit
Re: x86 machine code
« Reply #3 on: February 19, 2015, 08:22:29 pm »
I feel like those high level languages are not actual programming, for example, there's a whole compiler to compile ASM down to machine code and a whole #include file to compile C down to machine code. I feel like this is cheating and anyone can make mistakes on a compiler. I feel like machine code is actual programming. Is there any tutorials for x86 machine code?

1st, there is no "compiler" for assembly code, it's an assembler. Also, there's much more to C than an #include file.
http://codinghobbit.no-ip.org
My Calcs:
TI-86 (now broken) $2
TI SR-56 - $0
TI-Nspire CX CAS - $152
TI-84+ Silver Edition - $56
TI-84+ Silver Edition - $0
TI-85 - $0
TI-73 Explorer VS - $10
ViewScreen - $3

Offline MateoConLechuga

  • LV0 Newcomer (Next: 5)
  • Posts: 4
  • Rating: +1/-0
    • View Profile
Re: x86 machine code
« Reply #4 on: February 19, 2015, 09:24:36 pm »
I feel like those high level languages are not actual programming, for example, there's a whole compiler to compile ASM down to machine code and a whole #include file to compile C down to machine code. I feel like this is cheating and anyone can make mistakes on a compiler. I feel like machine code is actual programming. Is there any tutorials for x86 machine code?
One question: Why would you ever want to do this? It is making it extremely difficult on yourself for no real gain. There is a reason compilers exist. :( If you have a valid reason for wanting to learn, besides feeling that it is better, then go for it. As for making mistakes, there are orders of magnitudes more you can make with this route. Most C IDEs have debuggers and compiler warnings.

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: x86 machine code
« Reply #5 on: February 19, 2015, 09:40:16 pm »
I feel like those high level languages are not actual programming, for example, there's a whole compiler to compile ASM down to machine code and a whole #include file to compile C down to machine code. I feel like this is cheating and anyone can make mistakes on a compiler. I feel like machine code is actual programming.

Why do you feel like these aren't real programming. Machine code is interpreted by hardware inside the CPU and converted into microcode (which is the actual code the CPU runs). Compilers have mistakes, but they're extraordinarily rare on common platforms like the x86 or x86-64 families. The thing about C is that almost every part of the compiler can be stripped out and thrown away if you don't need it. I'm a systems programmer who works in C. My systems have completely custom standard libraries and environments that are specifically tailored to the hardware we design. Even in C, I work at a lower level than anything you can access on a PC. Your PC has what are called rings or modes that prevent your programs from seeing the fragmented layout of memory and peripheral interfaces. Even if you were to write in Machine code, your code would not be executing on the silicon as we say. Instead, it'd be executing inside a sandbox carefully constructed by the OS so as not to affect other programs. C is simply a thin layer of abstraction over the top of this forced abstraction the OS enforces. Even better, you can remove or change any parts of the abstraction you wish. Other than bootloaders, coprocessor code, and your crt0, there's very little need to write at a level lower than C.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ