ASP.NET
  Home arrow ASP.NET arrow Finishing an Introductory Look at CIL
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

Finishing an Introductory Look at CIL
By: Peyton McCullough
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2007-11-26

    Table of Contents:
  • Finishing an Introductory Look at CIL
  • Local Variables
  • Loops
  • Loops Continued
  • The Outer Loop
  • The Inner Loop
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Finishing an Introductory Look at CIL


    (Page 1 of 7 )

    In this second part to a two-part article on CIL, we'll take the C# program with which we started and convert it into CIL. This will involve several steps, which we'll describe and discuss in full.

    In the previous article, we looked at a C# program that finds prime numbers between two and one million. We started to convert it to CIL, recreating the class and method involved in the program, and then we took a look at method calls and the concept of a stack. Finally, we diverged a bit from the main task (converting the C# program) in order to create a simple “hello world” program in CIL, which we then assembled and executed.

    In this final part, we'll complete the conversion of our C# prime number program into CIL. This will involve learning local variables, mathematical operations and loops in CIL, which we'll all take step-by-step.

    For convenience, here is the C# program from the last article, in its entirety:


    using System;


    public class FindPrimes

    {

     public static void Main(string[] args)

    {

     for (int i = 2; i <= 1000000; i++)

    {

     bool prime = true;

     int limit = (int)Math.Sqrt(i);

     for (int f = 2; f <= limit; f++)

    {

     if (i % f == 0)

    {

     prime = false;

     break;

    }

    }

     if (prime)

    {

     Console.WriteLine(i);

    }

    }

     Console.WriteLine("Done!");

    }

    }


    In addition, here is the converted CIL program so far:


    .assembly extern mscorlib {}

    .assembly FindPrimes {}


    .class public FindPrimes

    {

    .method public static void Main(string[] args)

    {

    .entrypoint

    }

    }


    More ASP.NET Articles
    More By Peyton McCullough


       · Hello,This is a continuation of the last article. It finishes the main example...
     

    ASP.NET ARTICLES

    - Adding Content to a Static ASP.NET Website
    - Building a Static ASP.NET Website in a Basic...
    - Develop Your First ASP.NET Website with Visu...
    - Run ASP.NET in Windows XP Home with Cassini ...
    - How to Test a Web Application
    - How to Add Code and Validation Controls to a...
    - Working in Source and Split Views to Build a...
    - How to Build a Web Form for a One-Page Web A...
    - How to Develop a One-Page Web Application
    - An ASP.NET Web Application in Action
    - Developing ASP.NET Web Applications
    - An Introduction to ASP.NET Web Programming
    - Introduction to the ADO.NET Entity Framework...
    - Completing an In-Text Advertising System und...
    - Programming an In-Text Advertising System un...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek