<commit_before>/**
 * MIPSSim: This class emulates a MIPS system
 * 
 * @author <NAME>
 * @version 1.0 May 29, 2013
 */

import java.util.ArrayList;
import java.io.File;
import java.util.Scanner;
import java.io.FileNotFoundException;

public class ImpsTools {
   
   // Instance Variables
   private int[] dataMem;
   private ArrayList<String> instMem;
   private ArrayList<Register> regFile;
   private int pc;
   private Scanner scan;

   /* Initialize dataMem
      Initialize regFile: call initReg() to set up
      Initialize instMem: Scan in all instructions?
   */
   public ImpsTools(File instructions) throws FileNotFoundException {
      dataMem = new int[8192];
      instMem = new ArrayList<String>();
      regFile = new ArrayList<Register>(32);
      pc = 0;

      initReg();
      initInstMem(instructions);
   }

   public void step(int num) {
      String opcode;

      for (int i = 0; i != num && pc < instMem.size(); i++) {
         scan = new Scanner(instMem.get(pc++));
         scan.useDelimiter("[\\s,()]+");

         while (scan.hasNext()) {
            opcode = scan.next();

            if (opcode.equals("add"))
               add(false);
            else if (opcode.equals("addi"))
               addi();
            else if (opcode.equals("and"))
               logic(true);
            else if (opcode.equals("or"))
               logic(false);
            else if (opcode.equals("slt"))
               slt();
            else if (opcode.equals("sw"))
               memIO(true);
            else if (opcode.equals("lw"))
               memIO(false);<commit_msg>Added sub support<commit_after>/**
 * MIPSSim: This class emulates a MIPS system
 * 
 * @author <NAME>
 * @version 1.0 May 29, 2013
 */

import java.util.ArrayList;
import java.io.File;
import java.util.Scanner;
import java.io.FileNotFoundException;

public class ImpsTools {
   
   // Instance Variables
   private int[] dataMem;
   private ArrayList<String> instMem;
   private ArrayList<Register> regFile;
   private int pc;
   private Scanner scan;

   /* Initialize dataMem
      Initialize regFile: call initReg() to set up
      Initialize instMem: Scan in all instructions?
   */
   public ImpsTools(File instructions) throws FileNotFoundException {
      dataMem = new int[8192];
      instMem = new ArrayList<String>();
      regFile = new ArrayList<Register>(32);
      pc = 0;

      initReg();
      initInstMem(instructions);
   }

   public void step(int num) {
      String opcode;

      for (int i = 0; i != num && pc < instMem.size(); i++) {
         scan = new Scanner(instMem.get(pc++));
         scan.useDelimiter("[\\s,()]+");

         while (scan.hasNext()) {
            opcode = scan.next();

            if (opcode.equals("add"))
               add(false);
            else if(opcode.equals("sub"))
               add(true);
            else if (opcode.equals("addi"))
               addi();
            else if (opcode.equals("and"))
               logic(true);
            else if (opcode.equals("or"))
               logic(false);
            else if (opcode.equals("slt"))
               slt();
            else if (opcode.equals("sw"))
               memIO(true);
            else if (opcode.equals("lw"))
               memIO(false);
{'fraction_non_alphanumeric': 0.12936848559166156, 'fraction_numerical': 0.009809932556713672, 'mean_word_length': 2.055243445692884, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2042011', 'n_tokens_mistral': 964, 'n_tokens_neox': 946, 'n_words': 256}