Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how do compilers work please ?

Status
Not open for further replies.

expelleior

Member level 1
Joined
Jul 25, 2009
Messages
40
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Location
OZ
Activity points
1,610
Hi,
I am curious about programming languages. Does a C++ and Visual Basic compiler (just random examples) produce the 'code' that is actually run by a PC.

When a language is 'invented' is itreally a new compiler/enviroment that is created ?
 

Hi,

At the high level, the compiler works like this.

1) you write the source code in C++/VB
2) Compiler first parses the source code i,e breaks the code into tokens according to the language grammer
3) if the source code does not confirm to the grammer then you get an error
4) Forms a token tree
5) Translates this to the appropriate targeted platform assembly code
6) Also the compiler performs linkages to other libraires if you have used functions from other libraries

"When a language is 'invented' is it really a new compiler/enviroment that is created ?"

yes, a new language will require a new compiler.
 

Does a C++ and Visual Basic compiler (just random examples) produce the 'code' that is actually run by a PC.
From a simple user's point of view, the answer is yes. But if we digg into the compiler detail, we'll know that compiler produces objects and libraries, which are then passed to the linker and it is the linker that generates the bit pattern readable by the PC.

Also there are high level/interpreted languages where the compiler produces the byte code and that is run directly using some kind of virtual machine.

When a language is 'invented' is itreally a new compiler/enviroment that is created ?
Yes, a new compiler is needed.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top