SunQuest
 
       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  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
VeriSign Whitepapers 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
SunQuest
 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
     
    Iron Speed
     
    ADVERTISEMENT

    AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th -1:00PM EST. Register Today!

    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

    - Enhancing PHP Via the ASP.NET AJAX Framework...
    - Enhancing PHP Programming with the ASP.NET A...
    - Classes and ASP.NET AJAX
    - Using ASP.NET AJAX
    - Building a Simple Storefront with LINQ
    - Developing a Dice Game Using ASP.NET Futures...
    - Completing an ASP.NET AJAX Server-Centric Ba...
    - Information Management for an ASP.NET AJAX S...
    - Comment and Order Management for an ASP.NET ...
    - Back-end Management Tasks for an ASP.NET AJA...
    - User Information Management for an ASP.NET A...
    - Adding Comments and Search to an ASP.NET AJA...
    - Order-Related Modules for an ASP.NET AJAX Se...
    - User and Role Management for an ASP.NET AJAX...
    - Programming an ASP.NET AJAX Server-Centric B...

    Click Here




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway