Common Intermediate Language: Difference between revisions

Content deleted Content added
Computational model: copy editing
Computational model: copy editing
Line 41:
<!-- {{Copy edit|section|date=June 2020}} starting copy edit 20 July 2020 -->
 
The Common Intermediate Language is object-oriented and [[stack-based]], which means that instruction parameters and results are storedkept on a single stack instead of general-purposein several registers or other memory locations, as in most [[programming language]]s.
 
Code that adds two numbers in [[x86 assembly language]], where eax and edx specify two different [[X86#x86_registers|general-purpose registers]]:
In [[x86]] it might look like this:
<syntaxhighlight lang="asm">
add eax, edx
</syntaxhighlight>
 
The corresponding codeCould in [[Intermediate language|IL]] can be renderedlook aslike this, where 0 is eax and 1 is edx:
<syntaxhighlight lang="csharp">
ldloc.0 // push local variable 0 onto stack
Line 56:
</syntaxhighlight>
 
HereIn arethe latter example, the values of the two localsregisters, thateax and edx, are first pushed on the stack. When the add-instruction is called the operands getare "popped", or retrieved, and the result is "pushed", or stored on the stack. The remainingresulting value is then popped from the stack and stored in the first localeax.
 
===Object-oriented concepts===