Guest User

Untitled

a guest
Jun 20th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.65 KB | None | 0 0
  1. Module Module1
  2.  
  3. Sub Main()
  4. Dim x = 0
  5. Console.WriteLine(PlusEqual1(x))
  6. Console.WriteLine(Add1(x))
  7. Console.WriteLine(PlusEqual2(x))
  8. Console.WriteLine(Add2(x))
  9. Console.ReadLine()
  10. End Sub
  11.  
  12. Public Function PlusEqual1(ByVal x As Integer) As Integer
  13. x += 1
  14. Return x
  15. End Function
  16.  
  17. Public Function Add1(ByVal x As Integer) As Integer
  18. x = x + 1
  19. Return x
  20. End Function
  21.  
  22. Public Function PlusEqual2(ByVal x As Integer) As Integer
  23. x += 2
  24. Return x
  25. End Function
  26.  
  27. Public Function Add2(ByVal x As Integer) As Integer
  28. x = x + 2
  29. Return x
  30. End Function
  31.  
  32. End Module
  33.  
  34. .method public static int32 Add1(int32 x) cil managed
  35. {
  36. .maxstack 2
  37. .locals init (
  38. [0] int32 Add1)
  39. L_0000: nop
  40. L_0001: ldarg.0
  41. L_0002: ldc.i4.1
  42. L_0003: add.ovf
  43. L_0004: starg.s x
  44. L_0006: ldarg.0
  45. L_0007: stloc.0
  46. L_0008: br.s L_000a
  47. L_000a: ldloc.0
  48. L_000b: ret
  49. }
  50.  
  51. .method public static int32 Add2(int32 x) cil managed
  52. {
  53. .maxstack 2
  54. .locals init (
  55. [0] int32 Add2)
  56. L_0000: nop
  57. L_0001: ldarg.0
  58. L_0002: ldc.i4.2
  59. L_0003: add.ovf
  60. L_0004: starg.s x
  61. L_0006: ldarg.0
  62. L_0007: stloc.0
  63. L_0008: br.s L_000a
  64. L_000a: ldloc.0
  65. L_000b: ret
  66. }
  67.  
  68. static void Main(string[] args)
  69. {
  70. int i = 0;
  71. i += 1;
  72. i = i + 1;
  73. Console.WriteLine(i);
  74. }
  75.  
  76. private static void Main(string[] args)
  77. {
  78. int i = 0;
  79. i++;
  80. i++;
  81. Console.WriteLine(i);
  82. }
  83.  
  84. static void Main(string[] args)
  85. {
  86. int x = 2;
  87. int y = 3;
  88. x += 1;
  89. y = y + 1;
  90. Console.WriteLine(x);
  91. Console.WriteLine(y);
  92. }
  93.  
  94. x=x+1
  95.  
  96. x+=1
  97.  
  98. instruction type example cycles
  99.  
  100. ADD reg,reg add ax,bx 1
  101. ADD mem,reg add total, cx 3
  102. ADD reg,mem add cx,incr 2
  103. ADD reg,immed add bx,6 1
  104. ADD mem,immed add pointers[bx][si],6 3
  105. ADD accum,immed add ax,10 1
  106.  
  107. INC reg inc bx 1
  108. INC mem inc vpage 3
  109.  
  110. MOV reg,reg mov bp,sp 1
  111. MOV mem,reg mov array[di],bx 1
  112. MOV reg,mem mov bx,pointer 1
  113. MOV mem,immed mov [bx],15 1
  114. MOV reg,immed mov cx,256 1
  115. MOV mem,accum mov total,ax 1
  116. MOV accum,mem mov al,string 1
  117. MOV segreg,reg16 mov ds,ax 2, 3
  118. MOV segreg,mem16 mov es,psp 2, 3
  119. MOV reg16,segreg mov ax,ds 1
  120. MOV mem16,segreg mov stack_save,ss 1
  121. MOV reg32,controlreg mov eax,cr0 22
  122. mov eax,cr2 12
  123. mov eax,cr3 21, 46
  124. mov eax,cr4 14
  125. MOV controlreg,reg32 mov cr0,eax 4
  126. MOV reg32,debugreg mov edx,dr0 DR0-DR3,DR6,DR7=11;
  127. DR4,DR5=12
  128. MOV debugreg,reg32 mov dr0,ecx DR0-DR3,DR6,DR7=11;
  129. DR4,DR5=12
  130.  
  131. ;for i = i+1 ; cycles
  132. mov ax, [i] ; 1
  133. add ax, 1 ; 1
  134. mov [i], ax ; 1
  135.  
  136. ;for i += 1
  137. ; dunno the syntax of instruction. it should be the pointers one :S
  138.  
  139. ;for i++
  140. inc i ; 3
  141. ;or
  142. mov ax, [i] ; 1
  143. inc ax ; 1
  144. mov [i], ax ; 1
  145.  
  146. ;for ++i
  147. mov ax, [i] ; 1
  148. ;do stuff ; matters not
  149. inc ax ; 1
  150. mov [i], ax ; 1
  151.  
  152. int i = 0;
  153. i = i + 5.5; // doesn't compile.
  154. i += 5.5; // compiles.
Add Comment
Please, Sign In to add comment