3
$\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$
  • $\begingroup$ Try to find a textbook on logic design. $\endgroup$ – Ran G. Jun 7 '15 at 16:10
  • 2
    $\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
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$
  • $\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
1
$\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$
  • 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
  • $\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
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$
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$
  • 1
    $\begingroup$ The question asks who compiles the source code. $\endgroup$ – xskxzr Sep 18 at 18:49
  • $\begingroup$ The Central Processing Unit - the CPU. $\endgroup$ – MrFadelK Sep 20 at 2:09
-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$
  • 3
    $\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.