22 Replies - 4526 Views - Last Post: 18 April 2012 - 04:04 AM
#1
How does code gets converted/executed on a computer?
Posted 18 December 2011 - 02:25 PM
I have searched a lot but can't find any answers to my question:
When does software and "metal" meet on a computer? what I have in mind is how does text/code get converted into
electrical signals and gets executed?
any links and stuff could be very helpful...
thanks in advance
Replies To: How does code gets converted/executed on a computer?
#2
Re: How does code gets converted/executed on a computer?
Posted 18 December 2011 - 04:54 PM
#3
Re: How does code gets converted/executed on a computer?
Posted 18 December 2011 - 04:56 PM
On a Mac the software relies on a 'Kernel' which is a piece of software that relays messages and bridges the gap between the hardware and software.
http://www.google.co...OGaOWiQfytaG8BQ
#4
Re: How does code gets converted/executed on a computer?
Posted 18 December 2011 - 05:07 PM
Results: TONS!
compile a program and open it in a hex editor, see all those nubmers? Most of those are opcodes - instructions the CPU understands.
In a nutshell, the OS loader loads your program into memory (does a few calculations) and sets the EIP register to the address of the first instruction, the cpu executes that instruction and increments the address in EIP according to the opcode size, executes the next instruction.. this keeps going in a linear fashion from A to Z. Skipping some code according to compares and jmps. When you call a function, the cpu skips to the address of that function but returns to the spot right after the call.. Nutshell, it is very in depth as to the workings of the CPU
#5
Re: How does code gets converted/executed on a computer?
Posted 18 December 2011 - 05:08 PM
#6
Re: How does code gets converted/executed on a computer?
Posted 18 December 2011 - 05:12 PM
#7
Re: How does code gets converted/executed on a computer?
Posted 18 December 2011 - 05:13 PM
#8
Re: How does code gets converted/executed on a computer?
Posted 18 December 2011 - 05:29 PM
GunnerInc, on 18 December 2011 - 05:07 PM, said:
Results: TONS!
compile a program and open it in a hex editor, see all those nubmers? Most of those are opcodes - instructions the CPU understands.
In a nutshell, the OS loader loads your program into memory (does a few calculations) and sets the EIP register to the address of the first instruction, the cpu executes that instruction and increments the address in EIP according to the opcode size, executes the next instruction.. this keeps going in a linear fashion from A to Z. Skipping some code according to compares and jmps. When you call a function, the cpu skips to the address of that function but returns to the spot right after the call.. Nutshell, it is very in depth as to the workings of the CPU
ya, but when in this process does "dead metal/silicon" becomes able to "read & understand" the instructions in the registers? or put in other terms: how does software which is "text" gets converted to electrical signals on/off?
#9
Re: How does code gets converted/executed on a computer?
Posted 18 December 2011 - 05:31 PM
#10
Re: How does code gets converted/executed on a computer?
Posted 18 December 2011 - 05:39 PM
When the CPU gets made, it is built with microcode that understands the opcodes which opens/closes certain circuits. CPUS contain an ALU and CU, the CU decodes the opcodes, the ALU does math and logic. Read on the net, way too much info to explain here.
#11
Re: How does code gets converted/executed on a computer?
Posted 18 December 2011 - 05:50 PM
GunnerInc, on 18 December 2011 - 05:39 PM, said:
When the CPU gets made, it is built with microcode that understands the opcodes which opens/closes certain circuits. CPUS contain an ALU and CU, the CU decodes the opcodes, the ALU does math and logic. Read on the net, way too much info to explain here.
thanks that was helpful, but can you link me to some stuff that explains when the opcodes and the metal bridges?
#12
Re: How does code gets converted/executed on a computer?
Posted 18 December 2011 - 06:13 PM
Info for AMD and INTEL, I am missing a few books (I think they are under my bed) so can't tell you which ones you want, they are all relevant though
http://www.intel.com...rds=&topicarea=
http://developer.amd...es/default.aspx
#13
Re: How does code gets converted/executed on a computer?
Posted 18 December 2011 - 06:24 PM
kaylled, on 18 December 2011 - 07:29 PM, said:
It's all a matter of addressing. The CPU addresses memory, the memory stores instructions & values. All execution must occur in memory. Data is pulled from the hard drive, loaded into memory, executed.
When the computer is 1st turned on, all hard ware is addressed & mapped. Other than what has previously been provided by Gunner, this information is very detailed & available on the internet. It's no secret of hardware communicates, & loads software for execution.
#14
Re: How does code gets converted/executed on a computer?
Posted 18 December 2011 - 06:48 PM

POPULAR
a = 0
b = 1
c = 2
d = 3
.
.
z = 25
I press 'z' on my keyboard, which is 25 or 11001. An encoder places a signal on lines 1, 2, and 5. Now the memory buffer contains 11001.
Selected
|
Kybd |A| |B| |C| ....|Z|
\ | | /
------------
| Decoder |
------------
| | | | |
Bus | | | | |
| | | | |
-------------
Memory | 1|1|0|0|1 |
-------------
Pretty straight forward. How is this signal (electrical energy or the flow of electrons) stored in the hardware?
Realize the ways that a bit of information can be stored in hardware. One way is to store it in a capacitor: a device that stores energy. DRAM uses capacitance-based memory (with transistors), which has to be refreshed since the charge leaks. If there's no charge in it, it's a 0, otherwise a 1. CPU components use flip-flops.
From there the CPU has access to memory. It bring its contents into registers and operates on it, as directed by the program it's running. The CPU is designed to operate according to the opcodes that it receives. Often you hear of Intel-based PC's referred to as the x86 platform, which is also the name of Intel's assembly language.
It's not the program that determines what's text and what's instructions; it's the programmer. It's possible to design hardware that implements algorithms, but it's costly and more complex.
All hardware components are designed to operate in a specific way.
Quote
Book recommendations:
Computer Organization and Design: A high-level treatment of hardware, but enough to get the picture and infer how things are done.
Electronic Circuits: You have to do your research, many of these books require Integral Calculus. Something like Schaum's Outline of whatever may be more appropriate.
Some key terms: data path, ALU, multiplexer, encoder/decoder, barrel shifter, control logic, read/write register file, program counter, transistor, resistor, transducer, operational amplifier (analog to digital conversion), cache, translation look-aside buffer, bus, and interrupt controller.
I'm a fan of the bottom-up learning approach, which requires diving into circuit analysis first, but top-down is best if you don't want to subject yourself to dry reading material.
There really needs to be a Wiki for this stuff.
This post has been edited by blackcompe: 29 December 2011 - 10:24 AM
#15
Re: How does code gets converted/executed on a computer?
Posted 19 December 2011 - 01:56 AM

New Topic/Question



MultiQuote






|