<commit_before>package YakaC.Target;

import YakaC.javacc.Yaka;
import YakaC.Event.*;
import YakaC.Target.YVM;
import java.io.OutputStream;
import java.io.PrintWriter;

public class Tasm extends Writer
{
  public static final int StackValueSize = 2;

  protected int m_strIndex;

  public Tasm(final Yaka yaka, OutputStream os)
  {
    super(yaka, os);
    m_strIndex = 0;
    final EventManager manager = yaka.eventManager();

    manager.register(YakaC.Parser.ErrorBag.Event.Error, new EventHandler() {
      public void execute(Object params) {
        manager.unregister("ASM");
        write("Stopping ASM code generation due to error");
      }
    }, "ASM");

    manager.register(YVM.Event.Header, new EventHandler() {
      public void execute(Object params) {
        write(".model SMALL");
        write(".586");
        write(".CODE");
        write("debut:");
        write(1, "STARTUPCODE");
      }
    }, "ASM");

    manager.register(YVM.Event.StackDefinition, new EventHandler() {
      public void execute(Object params) {
        write(1, "mov bp, sp");
        write(1, "sub sp, " + (Integer)params);
      }
    }, "ASM");

    manager.register(YVM.Event.IConst, new EventHandler() {
      public void execute(Object params) {
        write(1, "push " + params);
      }
    }, "ASM");
<commit_msg>Added extern functions imports (ASM)<commit_after>package YakaC.Target;

import YakaC.javacc.Yaka;
import YakaC.Event.*;
import YakaC.Target.YVM;
import java.io.OutputStream;
import java.io.PrintWriter;

public class Tasm extends Writer
{
  public static final int StackValueSize = 2;

  protected int m_strIndex;

  public Tasm(final Yaka yaka, OutputStream os)
  {
    super(yaka, os);
    m_strIndex = 0;
    final EventManager manager = yaka.eventManager();

    manager.register(YakaC.Parser.ErrorBag.Event.Error, new EventHandler() {
      public void execute(Object params) {
        manager.unregister("ASM");
        write("Stopping ASM code generation due to error");
      }
    }, "ASM");

    manager.register(YVM.Event.Header, new EventHandler() {
      public void execute(Object params) {
        String[] functions = {
          "lirent",
          "ecrch",
          "ecrent",
          "ecrbool",
          "ligsuiv"
        };

        for (String function: functions) {
          write("extrn " + function + ":proc");
        }

        write(".model SMALL");
        write(".586");
        write(".CODE");
        write("debut:");
        write(1, "STARTUPCODE");
      }
    }, "ASM");

    manager.register(YVM.Event.StackDefinition, new EventHandler() {
      public void execute(Object params) {
        write(1, "mov bp, sp");
        write(1, "sub sp, " + (Integer)params);
      }
    }, "ASM");

    manager.register(YVM.Event.IConst, new EventHandler() {
      public void execute(Object params) {
        write(1, "push " + params);
      }
    }, "ASM");

{'fraction_non_alphanumeric': 0.1358321870701513, 'fraction_numerical': 0.006189821182943604, 'mean_word_length': 2.62266500622665, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 3, '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': '6236246', 'n_tokens_mistral': 920, 'n_tokens_neox': 886, 'n_words': 214}