kirililchev3

Debug Instruction Set

Jun 3rd, 2018
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.68 KB | None | 0 0
  1. namespace Debugging_Instruction_Set
  2. {
  3.     using System;
  4.  
  5.     public class Instruction_Set
  6.     {
  7.         public static void Main()
  8.         {
  9.             string command = Console.ReadLine();
  10.  
  11.             while (command.ToLower() != "end")
  12.             {
  13.                 string[] codeArgs = command.Split(' ');
  14.  
  15.                 long result = 0;
  16.                 switch (codeArgs[0])
  17.                 {
  18.                     case "INC":
  19.                         {
  20.                             long operandOne = long.Parse(codeArgs[1]);
  21.                             result = operandOne + 1;
  22.                             break;
  23.                         }
  24.  
  25.                     case "DEC":
  26.                         {
  27.                             long operandOne = long.Parse(codeArgs[1]);
  28.                             result = operandOne - 1;
  29.                             break;
  30.                         }
  31.  
  32.                     case "ADD":
  33.                         {
  34.                             long operandOne = long.Parse(codeArgs[1]);
  35.                             long operandTwo = long.Parse(codeArgs[2]);
  36.                             result = operandOne + operandTwo;
  37.                             break;
  38.                         }
  39.  
  40.                     case "MLA":
  41.                         {
  42.                             long operandOne = long.Parse(codeArgs[1]);
  43.                             long operandTwo = long.Parse(codeArgs[2]);
  44.                             result = operandOne * operandTwo;
  45.                             break;
  46.                         }
  47.                 }
  48.  
  49.                 Console.WriteLine(result);
  50.                 command = Console.ReadLine();
  51.             }
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment