How do languages that communicate directly to the hardware work?

How do languages that communicated directly to the hardware work?

1 Like

Can you make your question a bit clearer? You mean programs accessing hardware or compiled stuff?

2 Likes

I mean things like the language Assembly. So how does it sort of feed it into the computer?

1 Like

I guess you know that a program is called executable and this is a binary file that contains machine code (1s and 0s in some form), representing a sequence of instructions that the CPU (processor) can execute. When an executable is launched, the operating system loads the binary file into memory and sets up a process, which is an instance of the executable running on the system. The operating system then transfers control to the entry point of the executable, which is the first instruction that will be executed.
This is in its simpler form as in the old days. Things are a bit more complex now.

6 Likes

Thanks for the amazing explanation. Understand it now.

1 Like

My PhD was about CPU architecture (circutis, compiler, etc etc) and i still love the topic

4 Likes

This is why we like having you here: you know so much. Most of us are a lot younger than you and have much to learn.

3 Likes

Accurate. In a lower level, the CPU executes programs stored in memory by following a sequence of instructions. The instruction pointer is a special register that keeps track of the memory address of the next instruction to be produced and executed. The CPU takes an instruction from memory, decodes it into an opcode and operands, and then executes it using the ALU or other specialized units such as the FPU for floating point operations. The CPU also has small, high-speed memories called registers that hold operands and intermediate results during instruction execution. Registers are predefined by the CPU architecture and can be accessed much faster than memory. Programs written in higher-level languages are translated or interpreted into machine code, which determines which registers are used and how they are handled. In addition to registers, the CPU also has other components, such as cache memory, which accelerate the execution of instructions by storing frequently used data closer to the CPU. The CPU also uses pipelining and other techniques to overlap multiple instructions and increase performance.

TL;DR:

  • The CPU executes programs stored in memory by following a sequence of instructions.
  • The CPU takes an instruction from memory, decodes it into an opcode and operands, and then executes it using the ALU or other specialized units such as the FPU for floating point operations.
  • The CPU also has small, high-speed memories called registers that hold operands and intermediate results during instruction execution.
  • In addition to registers, the CPU also has other components, such as cache memory, which accelerate the execution of instructions by storing frequently used data closer to the CPU.

Please note that this is very oversimplified.

2 Likes

That is so 1990s and just one possible architecture … let’s not open the architecture pandora box @jpg

2 Likes

Yes, as I said its quite oversimplified. The comment I made was just so OP could understand how a very generic system works, not so that he knows exactly how everything in it works…

Machine code is the binary code that the processor can execute directly. It consists of a series of instructions that are represented as 0s and 1s. Machine code programs are typically generated by compilers, which translate higher-level programming languages into machine code.

2 Likes