computer science - Machine code to execution, what is going on? -


i have been learning computer programming on years , layer of abstraction clouding understand. compiled source code , have executable machine code. once computer runs code going on?

for example, run simple if else statement , have machine code. going on in circuitry of computer executes instruction?

i depends on language, regular executable (like c/c++) machine code bit patterns cpu interpret direct instructions. these machine language instructions map 1-to-1 assembly instructions if have done assembly (if getting cs degree should end taking course or 2 learn assembly, , may have manually translate between assembly , machine language using cpu reference).

other languages java , c# little more tricky, there intermediate "byte-code" interpreted , translated machine code program run, allowing them achieve platform independence.

as instructions do, depends on cpu, of them can things following:

  • move value register* ram address or vice-versa
  • perform operation on 2 values (like add, xor, and, or, etc...)
  • compare 2 values (determine if equal or if 1 greater other)
  • change current instruction register (jump) different address, dependent on result of last comparison (used in loops)
  • move value onto stack**, or remove value stack
  • save our position/state on stack, , jump new address
  • recall saved position/state stack, , jump used (these last 2 used in function calls)

and more.

*a register small fast memory space exists within cpu; registers used instructions. 1 of these current instruction register holds address of next instruction executed. changing value directly jump new address, similar goto statement.

**the stack internal stack values can stored , retrieved in first-in-last-out manner. how function calling achieved. hansel , gretel, leave trail of bread crumbs behind can find our way home.

additionally, there 2 "schools of thought" towards how instruction sets should organized: risc , cisc (reduced instruction set computers, , complex instruction set computers). in risc computer, there fewer less powerful instructions, , it's programmer or compiler use groups of them more complex things. in cisc computer, there more , more powerful instructions, redundancy. intel based cpus cisc.

see also:


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -