食譜

Examplets.org

Common Intermediate Language Daily (March 22, 2017)

 

Date 2011/4/9
Name Add Two Numbers
Description Add Two Numbers using Common Intermediate Language
Filename AddTwoNumObjC.c
Content
  1. Using the Standard input stream to enter different numbers or text
  2. Find two integers each time and,
  3. Display output the sum to the standard output stream.
  4. Repeat the all the steps until an EOF (End of File) signal received
Sample Input: 123 3.5 dsfasd 4 fdsafds 6
Sample Output: 126 0
Expected Test Command: ilasm HelloFriendCIL.il
HelloFriendCIL.exe

.assembly extern mscorlib{}
.assembly HelloFriendCIL{}
.class private auto ansi beforefieldinit HelloFriendCIL extends [mscorlib]System.Object{
	.method public hidebysig static void Main() cil managed{
		.entrypoint
		.maxstack  2
		.locals init (string V_0, bool V_1)
		START:	ldstr      "Your name\?"
				call       void [mscorlib]System.Console::Write(string)
				call       string [mscorlib]System.Console::ReadLine()
				stloc.0
				ldloc.0
				ldnull
				ceq
				stloc.1
				ldloc.1
				brtrue.s   EOF
				ldstr      "Hello, "
				ldloc.0
				call       string [mscorlib]System.String::Concat(string, string)
				call       void [mscorlib]System.Console::WriteLine(string)
				br.s   START
		EOF:	ret
	} 
}


Date 2011/4/8
Name Hello Friend
Description Ask user's name and echo greeting message to user using Common Intermediate Language
Filename HelloFriendCIL.il
Content
  1. Using the Standard output stream to prompt your:"Your name?"
  2. Then use the input stream to receive input from user.
  3. Display the greeting message "Hello, [user name]!" using standard output stream.
  4. Repeat all the steps until users press CTRL-Z (MS windows) or CTRL-D (Mac) or receive the EOF signal.
Sample Input: Peter Pan
Sample Output: Hello, Peter Pan!
Expected Test Command: ilasm HelloFriendCIL.il
HelloFriendCIL.exe

.assembly extern mscorlib{}
.assembly HelloFriendCIL{}
.class private auto ansi beforefieldinit HelloFriendCIL extends [mscorlib]System.Object{
	.method public hidebysig static void Main() cil managed{
		.entrypoint
		.maxstack  2
		.locals init (string V_0, bool V_1)
		START:	ldstr      "Your name\?"
				call       void [mscorlib]System.Console::Write(string)
				call       string [mscorlib]System.Console::ReadLine()
				stloc.0
				ldloc.0
				ldnull
				ceq
				stloc.1
				ldloc.1
				brtrue.s   EOF
				ldstr      "Hello, "
				ldloc.0
				call       string [mscorlib]System.String::Concat(string, string)
				call       void [mscorlib]System.Console::WriteLine(string)
				br.s   START
		EOF:	ret
	} 
}


Date 2011/4/7
Name Hello World
Description Display greeting message to user using Common Intermediate Language
Filename HelloWorldCIL.il
Content
  1. Display the greeting message "Hello, World!" using standard output stream by Common Intermediate Language
Sample Input:  
Sample Output: Hello, World!
Expected Test Command: ilasm HelloWorldCIL.il
HelloWorldCIL.exe

.assembly extern mscorlib{}
.assembly HelloWorldCIL{}
.class private auto ansi beforefieldinit HelloWorldCIL extends [mscorlib]System.Object{
  .method public hidebysig static void Main() cil managed{
    .entrypoint
    ldstr      "Hello, World!"
    call       void [mscorlib]System.Console::WriteLine(string)
    ret
  } 
}

6502 MPU and assembly


Latest Blog Articles from CloudGen wordpress blog!


Copyright 2008-2017

Cloud-Gen