6
$\begingroup$

I went through lots of blogs and posts but could not exactly figure out how the machine code is converted to electrical signals?

Any software program is compiled to machine code which is nothing but lots of 1s and 0s. 1 means high voltage e.g 5V and 0 means comparatively low voltage e.g. 0V or ground, what's the component which understands that okay I got 1(one) so I need to step up up the voltage to 5V and for 0(zero) I need to step down to lower voltage level and how it does that?

$\endgroup$
3
  • 1
    $\begingroup$ Try to find a textbook on logic design. $\endgroup$ – Ran G. Jun 7 '15 at 16:10
  • 5
    $\begingroup$ Sorry, this wasn't meant to be mean or anything -- you said you read about this matter in blogs and post, and I just thought you may find the answers if you target your reading for "logic design" posts. This was supposed to be a simple pointer. Sometimes just knowing the right buzzword is the key to getting the information. $\endgroup$ – Ran G. Jun 8 '15 at 19:36
  • $\begingroup$ Note: I have updated my answer now as I have expanded it. $\endgroup$ – Shashank V M yesterday

10 Answers 10

4
$\begingroup$

In old computer you actually had a row of switches on the front panel that would allow entering 1s and 0s directly by hand in the registers of the machines. But this is no longer done.

You never have 1s and 0s, unless you ask the machine to print its internal information as a sequence of 1s and 0s. All information is already in the machine encoded as voltage, or magnetic orientation, or hole in a physical substrate, or some other physical form. Various devices can perform the translation between these form: magnetic heads, laser beams, electro-mechanical devices, electronic circuits,etc.

Some form are better adapted at memorizing or transmission by various means, while other (electrical signal notably) are better adapted at processing, usually by complex systems of logical gates (and, or, not, xor ...) and micro-memories (registers).

In general, binary/machine code is no longer entered by human beings, but produced by a program (usually a compiler) by the computer itself, or by another computer and then imported on some memory support or by network. However, human beings can ask to have it printed as 1s and 0s to check what the computer is using or producing. However this requires transforming the single bit 0 or 1 in the computer as a stream of bits to be interpreted by the printer as a request to print an actual drawing (on screen or paper) od the symbol representing a 0 or a 1.

It is hard to give more details without your being more specific regarding the source form and target form of the conversion. But it is most often from binary to binary, with a different physical representation.

$\endgroup$
3
  • $\begingroup$ Thanks for great explanation! Very first computer was hard wired to perform predetermined calculations then punch cards came in punch cards were also kind of physical input to computer, you have to tell computer what to do. This evolution continued and people realise the need of where computer could perform some stored instructions automatically without human intervention, eventually EDSAC became the first computer which could execute stored instructions. Could you explain about how stored instructions are executed by a computer? $\endgroup$ – dev gr Jun 8 '15 at 2:36
  • $\begingroup$ @devgr Well, I am not a specialist, and CPU design is a whole field by itself. Furthermore there is a variety of techniques, depending on whether things are done serially or in parallel, on whether it is synchronous or asynchronous, and others I would not know. An instruction is a sequence of bits with several fields corresponding to op-code or address/value or flag. It is loaded in a register (row of circuit locations that have a "stabilized" voltage corresponding to 0 or 1. The points for each field are connected to circuits supposed to act according to the field content at a clock signal. $\endgroup$ – babou Jun 8 '15 at 10:38
  • $\begingroup$ If the instruction has an "add register" op-code, with two registers addresses, then the circuitry will be activated so as to direct the content of the registers towards the adder entry point, and activate the adder circuitry, the result being stored in a standard result register (for example). I am making this up to give you an example. It varies according to designs, and my example is probably very naive $\endgroup$ – babou Jun 8 '15 at 10:43
2
$\begingroup$

You don't "convert" a zero to low voltage: a zero is low voltage. Whenever a logic component is at low voltage, we call that state "zero". Likewise, when a component is at high voltage, we call that state "one". Zeroes and ones exist only as voltage levels.

$\endgroup$
2
  • 1
    $\begingroup$ As a programmer we write softwares using any language in a text editor not build circuits. So when this code is compiled you can feed this code to machine so that it performs required operation using physical components like transistors and diodes etc. which only understand voltage levels. So some component is switching the voltage levels according to the code you wrote. What's that component? $\endgroup$ – dev gr Jun 7 '15 at 8:35
  • 1
    $\begingroup$ The computer knows nothing except voltage levels. Even when you press a key, that changes voltage levels. "Zero", "one", "a Java program" and so on are all just the meanings that we assign to those voltage levels or sequences of voltage levels. The component that switches voltage levels according to the voltage levels you call code is the CPU. $\endgroup$ – David Richerby Jun 7 '15 at 9:26
2
$\begingroup$

The question is asking there must be something between the machine code and the electric signal in the computer. For example, a program written in C++ is compiled into machine code first, then it is converted into electrical signal so that the computer can really "execute" the program. As the computer does not understand the machine code, what is the component really change machine code to electronic signal?

Some answers mentioned the input process from keyboard, but that does not really answer the question. I think if anybody who can explain step by step the execution process of an .exe file on a Windows computer will be able to provide more valuable details.

$\endgroup$
1
  • $\begingroup$ Interesting comment, but it is good to indicate when your answer is just a comment and not a full answer. Maybe you an include a note at the top of this answer that says "Not a full answer"? $\endgroup$ – 6005 Jun 18 '20 at 2:36
1
$\begingroup$

Your machine code is not "converted" into electrical signals at all. It is a set of electrical signals. The fact that you see numbers and letters on your screen is irrelevant, all of that data is simply the processing of very precisely arranged electrical signals under a strict set of rules.

See this answer on SuperUser for a more detailed answer

$\endgroup$
1
$\begingroup$

I’m afraid you are looking at things from the wrong level. There’s a highest level that we usually look at here: Algorithm design. Next level: High level programming languages. Below that: Assembly languages and machine code. Below: Processors. Below that: Logic design. Building things from and/or/nand gates. Out Next level: Transistors. And that’s where actual electricity comes in; voltages, currents, capacitors etc.

Very few people know and very few people care about details as low as this.

$\endgroup$
0
$\begingroup$

There is nothing to convert, the moment you press a key your keyboard sends a signal containing the information about the pressed key (imagine a switch being turned on for the duration of the keypress, this is interpreted by a microchip), this information is already voltage and the cpu or other components work with that. So the only points where such a conversion is necessary are IO devices, if the device in question sends analog data this would be done by an AD Converter.

Maybe you are reffering to the state transion 1->0 or 0->1 itself ? Well, at the lowest level this is done with transistors, for example in NMOS logic you could build a NOR gate like this:

NOR Gate in NMOS Logic

see NMOS, CMOS, MOSFET if you want to know more about it.

$\endgroup$
0
$\begingroup$

The text / code you are looking at on your display right now is a view of the underlying voltages residing on Memory ; therefore, if it’s not a voltage on memory, it’s never on screen.

Text/code is a view of voltages

To compile source code means cover underlying voltages to different voltages and view the resulted voltages as compiled code/text

$\endgroup$
2
  • 1
    $\begingroup$ The question asks who compiles the source code. $\endgroup$ – xskxzr Sep 18 '19 at 18:49
  • $\begingroup$ The Central Processing Unit - the CPU. $\endgroup$ – MrFadelK Sep 20 '19 at 2:09
0
$\begingroup$
  • A computer is just an electronic circuit that operates on 2 voltage levels, called 0 and 1 or HIGH and LOW. Such electronic circuits are called digital electronic circuits since they operate on two discrete voltage levels. Contrast this with analog circuits, which operate on continuous voltage levels.

  • 1 is used to represent a high voltage level. 0 is a symbol used to represent low voltage level. This is assuming Active High logic. Vice-versa for Active Low logic.

  • CMOS Transistors are commonly used to form the basic building blocks of digital electronic ciruits called logic gates.

  • A CMOS inverter converts a low voltage level to a high voltage level and vice-versa. This can be called a NOT gate since it converts the symbol 1 to 0 and 0 to 1. Similarly there are other gates that do other functions.

  • NAND and NOR are the universal gates. You can realize any logic function using combinations of these gates alone.

  • Sequential circuits are built from these logic gates. Sequential circuits are Finite State Machines.

  • The computer is a Finite State Machine, not a Turing machine. It can, however, be approximated as a Turing machine. The computer executes instructions sequentially. Instructions can also be executed in parallel, if the task is parallelizable.

  • Finite State Machines, also known as Finite State Automata, is a very generic term for any process (electronic or otherwise) whose output is not just a function of its current inputs, but also of its past inputs. In other words, it has memory.

  • Here is a brief overview of a typical compilation and execution flow on a Von Neumann machine:

  1. Type in the source code in a plain text editor.
  2. This source code consists of characters. Characters are encoded as bits. An example of encoding is ASCII. These bits are stored on the disk, when you save the source code.
  3. Invoke the compiler to compile the source code. The compiler parses the source code file(s), produces object code and links the object files to produce a machine language file called executable. The executable is stored on the disk.
  4. Run the executable. This is called execution.
  • At all steps in the process, the operating system controls and co-ordinates processes and does the memory management.

  • Data is stored in the RAM temporarily when the process running on the machine requires it.

  • Data is stored on the disk when it needs to be stored permanently.

  • There is also a process called swapping which is done by the OS when there is no RAM memory left. A section of the disk memory is used for swapping.

  • There can be multiple processes running on the machine. These processes can run parallely or concurrently. The operating system allocates resources for processes and schedules the processes to run using scheduling algorithms.

Further reading:

$\endgroup$
-1
$\begingroup$

Every thing you write on a text editor, first, it is stored in a memory (electric signals generated from the keybord) no matter in which code (ascii,...). From memory, those signals are fed into the computer monitor and you can see the source code you are typing. Then, you run your compiler (or assembler) that reads the source code in memory (electric signals) and converts it to machine code, storing those transformed electric signals in another region of the memory (electric signals again). When the cpu reads the machine code, what it sees are electric signals. There is no logic levels, so there is no need to convert logic level in voltage level.

$\endgroup$
1
  • 4
    $\begingroup$ I don't think this answers the question. $\endgroup$ – Raphael Jul 5 '16 at 8:20
-1
$\begingroup$

Actually voltage signals work with themselves in voltage layer(involve cpu,memory,input,output,...) ,and we can see the meaning of voltages signals in binary codes or c code or other language at pc monitor.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.