MSIL C#.NET Software Development. MSIL AKA CIL What all.NET languages compile to What all.NET languages compile to Binary Intermediate Language Binary.

Slides:



Advertisements
Similar presentations
By Sam Nasr September 28, 2004 Understanding MSIL.
Advertisements

Chapter 16 Java Virtual Machine. To compile a java program in Simple.java, enter javac Simple.java javac outputs Simple.class, a file that contains bytecode.
Cosc 2150 Arrays in assembly code. Variables and addresses Uncompiled ld [a], %r1 addcc %r1, 2, %r3 ARC has three addressing modes —immediate, direct,
1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 2: Data types and addressing modes dr.ir. A.C. Verschueren.
Chapter 8 ICS 412. Code Generation Final phase of a compiler construction. It generates executable code for a target machine. A compiler may instead generate.
Chapter 1 IDE and Tools for Developing CLR-based Programs Yingcai Xiao.
Instruction Set Architecture Classification According to the type of internal storage in a processor the basic types are Stack Accumulator General Purpose.
IT253: Computer Organization Lecture 6: Assembly Language and MIPS: Programming Tonga Institute of Higher Education.
COSC 2006 Chapter 7 Stacks III
Performance evaluation of plagiarism detection method based on the intermediate language Vedran Juričić Tereza Jurić Marija Tkalec.
Infix to postfix conversion Process the tokens from a vector infixVect of tokens (strings) of an infix expression one by one When the token is an operand.
CS 536 Spring Code generation I Lecture 20.
S. Barua – CPSC 240 CHAPTER 10 THE STACK Stack - A LIFO (last-in first-out) storage structure. The.
Stacks (Revised and expanded from CIT 591). What is a stack? A stack is a Last In, First Out (LIFO) data structure Anything added to the stack goes on.
Stacks. 2 What is a stack? A stack is a Last In, First Out (LIFO) data structure Anything added to the stack goes on the “top” of the stack Anything removed.
Chapter 4 H1 Assembly Language: Part 2. Direct instruction Contains the absolute address of the memory location it accesses. ld instruction:
Chapter 16 Java Virtual Machine. To compile a java program in Simple.java, enter javac Simple.java javac outputs Simple.class, a file that contains bytecode.
From C++ to C#. Web programming The course is on web programming using ASP.Net and C# The course is on web programming using ASP.Net and C# ASP.Net is.
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 18: 0xCAFEBABE (Java Byte Codes)
Lab 1 – Assembly Language and Interfacing Start date: Week 3 Due date: Week 4 1.
Application Security Tom Chothia Computer Security, Lecture 14.
What is TINY? 1.Base-10 Machine (emulator currently runs on Windows-based machines.) 2.Only 1,000 ‘bytes’ of memory 3.Only 5 registers 4.~26 machine instructions.
DEV490 .NET Framework: CLR – Under The Hood
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
Java Bytecode What is a.class file anyway? Dan Fleck George Mason University Fall 2007.
ITEC 352 Lecture 20 JVM Intro. Functions + Assembly Review Questions? Project due today Activation record –How is it used?
.NET Security and MSIL Tom Roeder CS fa. MSIL Common intermediate language really CIL in ECMA standard MSIL is common name Very close to C# (and.
Microprocessors The ia32 User Instruction Set Jan 31st, 2002.
Basic Data Structures Stacks. A collection of objects Objects can be inserted into or removed from the collection at one end (top) First-in-last-out.
Arithmetic Expressions Addition (+) Subtraction (-) Multiplication (*) Division (/) –Integer –Real Number Mod Operator (%) Same as regular Depends on the.
EEL5708/Bölöni Lec 8.1 9/19/03 September, 2003 Lotzi Bölöni Fall 2003 EEL 5708 High Performance Computer Architecture Lecture 5 Intel 80x86.
Object Oriented Software Development 4. C# data types, objects and references.
Bank Account Example public class BankAccount { private double balance; public static int totalAccounts = 0; public BankAccount() { balance = 0; totalAccounts++;
ECE 447 Fall 2009 Lecture 4: TI MSP430 Architecture and Instruction Set.
A Microsoft.NET Front-End for GCC Bernhard Rabe Martin von Löwis Jan Möller Operating Systems & Middleware Group Hasso-Plattner-Institute, University of.
Overview CNS 3260 C#.NET Software Development. 2.NET Framework Began in 2000 Developed in three years (2000 to 2003) Operating System Hardware.NET Framework.
Winter 2016CISC101 - Prof. McLeod1 Today Numeric representation (or “How does binary and hexadecimal work?”). How can a CPU understand instructions written.
Click to edit Master text styles Stacks Data Structure.
METADATA IN.NET Presented By Sukumar Manduva. INTRODUCTION  What is Metadata ? Metadata is a binary information which contains the complete description.
RealTimeSystems Lab Jong-Koo, Lim
7-Nov Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Oct lecture23-24-hll-interrupts 1 High Level Language vs. Assembly.
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics Advanced.NET Programming I 7 th Lecture Pavel Ježek
Computer Architecture. Instruction Set “The collection of different instructions that the processor can execute it”. Usually represented by assembly codes,
Overview of Instruction Set Architectures
.NET Security and MSIL Tom Roeder CS fa.
Assembly Language Programming of 8085
Microprocessor T. Y. B. Sc..
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
CS216: Program and Data Representation
The Forth Language CSC 507 – Roy Ford November 22, 2005.
Lecture 4: MIPS Instruction Set
Cinda Heeren / Geoffrey Tien
A Closer Look at Instruction Set Architectures
Computer Architecture and Organization Miles Murdocca and Vincent Heuring Chapter 4 – The Instruction Set Architecture.
Copyright ©2012 by Pearson Education, Inc. All rights reserved
STACK CHAPTER 03 Developed By :- Misha Ann Alexander Data Structures.
Visit for more Learning Resources
CS360 Windows Programming
Chapter 1 IDE and Tools for Developing CLR-based Programs
Stacks Chapter 5 Adapted from Pearson Education, Inc.
Java Byte Codes (0xCAFEBABE) cs205: engineering software
Lecture 4: MIPS Instruction Set
Winter 2018 CISC101 11/29/2018 CISC101 Reminders
Lecture 19: 0xCAFEBABE (Java Byte Codes) CS201j: Engineering Software
Fundamentals of Computer Organisation & Architecture
Other ISAs Next, we’ll first we look at a longer example program, starting with some C code and translating it into our assembly language. Then we discuss.
Other ISAs Next, we’ll first we look at a longer example program, starting with some C code and translating it into our assembly language. Then we discuss.
Stack Applications Lecture 29 Thu, Apr 5, /23/2019
CISC101 Reminders Labs start this week. Meet your TA! Get help with:
Some Assembly (Part 2) set.html.
Presentation transcript:

MSIL C#.NET Software Development

MSIL AKA CIL What all.NET languages compile to What all.NET languages compile to Binary Intermediate Language Binary Intermediate Language check out: check out: C:\Program Files\Microsoft Visual Studio.NET 2003\SDK\v1.1\Tool Developers Guide\docs C:\Program Files\Microsoft Visual Studio.NET 2003\SDK\v1.1\Tool Developers Guide\docs Partition II Metadata.doc Partition II Metadata.doc Partition III CIL.doc Partition III CIL.doc StartDocs.htm StartDocs.htm

Making MSIL Readable ILDasm.exe ILDasm.exe Disassembles MSIL to MSIL Assembly Language Disassembles MSIL to MSIL Assembly Language ILAsm.exe ILAsm.exe Assembles MSIL Assembly Language to MSIL Assembles MSIL Assembly Language to MSIL

MSIL: A Stack Machine All operations are executed on the stack All operations are executed on the stack Parameters Parameters Variables Variables Return values Return values Expression evaluation Expression evaluation When a command is executed it: When a command is executed it: pushes operands (parameters) on the stack pushes operands (parameters) on the stack Executes the command or function Executes the command or function The called function pops its own parameters off the stack The called function pops its own parameters off the stack The called function pushes it’s return value onto the stack (if needed) The called function pushes it’s return value onto the stack (if needed) Read the result from the stack (if available) Read the result from the stack (if available)

Onto the Stack... Value-types are placed directly on the stack Value-types are placed directly on the stack Reference-types place only the reference on the stack Reference-types place only the reference on the stack (But you knew that already) (But you knew that already) IL Commands: IL Commands: ld (load: loads a value onto the stack) ld (load: loads a value onto the stack) st (store: stores a value in a variable and removes it from the stack) st (store: stores a value in a variable and removes it from the stack)

“Hello IL World”.entrypoint.entrypoint describes the function as the program entry point describes the function as the program entry point.maxstack 1.maxstack 1 tells ilasm that the stack will only reach a depth of 1 tells ilasm that the stack will only reach a depth of 1 ldstr ldstr loads a string onto the stack loads a string onto the stack call call calls the specified function calls the specified function ret ret returns from the function (clearing anything put on the stack) returns from the function (clearing anything put on the stack)

Loading an Integer ldc.i4.7 ldc.i4.7 ldc: load constant ldc: load constant i4: 4-byte integer i4: 4-byte integer 7: value 7 7: value 7 stloc.0 stloc.0 Pops the stack into the first local variable Pops the stack into the first local variable Type has to match initialization type Type has to match initialization type for the first 4 locals you can say stloc.n (3 > n > 0) for the first 4 locals you can say stloc.n (3 > n > 0) for locals number 4 – 255, use stloc.s n for locals number 4 – 255, use stloc.s n ldloc.0 ldloc.0 Loads local at index 0 onto the stack Loads local at index 0 onto the stack

Doing Some Math ldc.r4 (A4 AA 8A 40) ldc.r4 (A4 AA 8A 40) Loads the hex value as a 4-byte floating point Loads the hex value as a 4-byte floating point conv.r4 conv.r4 converts the top value of the stack to r4 converts the top value of the stack to r4 add add adds the top values of the stack, removes them, pushes the result adds the top values of the stack, removes them, pushes the result sub sub subtracts the top values of the stack subtracts the top values of the stack

Try if-else bne.un.s IL_000f bne.un.s IL_000f branch (jump) if the top two operands are not equal branch (jump) if the top two operands are not equal br.s IL_0012 br.s IL_0012 branch unconditionally branch unconditionally box box unbox unbox switch (next demo) switch (next demo)

Building Classes Constructors Constructors stfld stfld stores a field stores a field Property Property newobj newobj Creates a new object Creates a new object

Exceptions.try.try catch catch finally finally callvirt callvirt Calls a virtual function (or Property) Calls a virtual function (or Property)

Talk about GC!