<commit_before>#include "common.h"
#include "cpu.h"
#include "mmu.h"
#include "ea.h"

static int rmw = 0;

static BYTE ea_read_000_b(struct cpu *cpu, int reg)
{
  return cpu->d[reg]&MASK_B;
}

static WORD ea_read_000_w(struct cpu *cpu, int reg)
{
  return cpu->d[reg]&MASK_W;
}

static LONG ea_read_000_l(struct cpu *cpu, int reg)
{
  return cpu->d[reg]&MASK_L;
}

static void ea_write_000_b(struct cpu *cpu, int reg, BYTE data)
{
  cpu->d[reg] = (cpu->d[reg]&0xffffff00)|data;
}

static void ea_write_000_w(struct cpu *cpu, int reg, WORD data)
{
  cpu->d[reg] = (cpu->d[reg]&0xffff0000)|data;
}

static void ea_write_000_l(struct cpu *cpu, int reg, LONG data)
{
  cpu->d[reg] = data;
}

static BYTE ea_read_001_b(struct cpu *cpu, int reg)
{
  return cpu->a[reg]&MASK_B;
}

static WORD ea_read_001_w(struct cpu *cpu, int reg)
{
  return cpu->a[reg]&MASK_W;
}

static LONG ea_read_001_l(struct cpu *cpu, int reg)
{
  return cpu->a[reg]&MASK_L;
}

static LONG ea_addr_010(struct cpu *cpu, int reg)
{
  return cpu->a[reg];
}

static LONG ea_addr_011(struct cpu *cpu, int reg, int size)
{
  if(rmw) {
    return cpu->a[reg];
  } else {
    cpu->a[reg]+=size;
    return cpu->a[reg]-size;
  }
}

static LONG ea_addr_100(struct cpu *cpu, int reg, int size)
{
  if(rmw) {
    return cpu->a[reg];
  } else {
    cpu->a[reg]-=size;
    return cpu->a[reg];
  }
}

static LONG ea_addr_101(struct cpu *cpu, int reg)
{
  int o;

  o = mmu_read_word(cpu->pc);
  if(o&0x8000) o |= 0xffff0000;

  if(!rmw) {
    cpu->pc += 2;
  }
  return cpu->a[reg]+o;
}

static LONG ea_addr_110(struct cpu *cpu, int reg)
{<commit_msg>Stack pointer should be increased or decreased by 2 for post-increment or pre-decrement if the size is byte<commit_after>#include "common.h"
#include "cpu.h"
#include "mmu.h"
#include "ea.h"

static int rmw = 0;

static BYTE ea_read_000_b(struct cpu *cpu, int reg)
{
  return cpu->d[reg]&MASK_B;
}

static WORD ea_read_000_w(struct cpu *cpu, int reg)
{
  return cpu->d[reg]&MASK_W;
}

static LONG ea_read_000_l(struct cpu *cpu, int reg)
{
  return cpu->d[reg]&MASK_L;
}

static void ea_write_000_b(struct cpu *cpu, int reg, BYTE data)
{
  cpu->d[reg] = (cpu->d[reg]&0xffffff00)|data;
}

static void ea_write_000_w(struct cpu *cpu, int reg, WORD data)
{
  cpu->d[reg] = (cpu->d[reg]&0xffff0000)|data;
}

static void ea_write_000_l(struct cpu *cpu, int reg, LONG data)
{
  cpu->d[reg] = data;
}

static BYTE ea_read_001_b(struct cpu *cpu, int reg)
{
  return cpu->a[reg]&MASK_B;
}

static WORD ea_read_001_w(struct cpu *cpu, int reg)
{
  return cpu->a[reg]&MASK_W;
}

static LONG ea_read_001_l(struct cpu *cpu, int reg)
{
  return cpu->a[reg]&MASK_L;
}

static LONG ea_addr_010(struct cpu *cpu, int reg)
{
  return cpu->a[reg];
}

static LONG ea_addr_011(struct cpu *cpu, int reg, int size)
{
  if(rmw) {
    return cpu->a[reg];
  } else {
    if((size == 1) && (reg == 7)) size = 2; /* SP should get mad, not even */
    cpu->a[reg]+=size;
    return cpu->a[reg]-size;
  }
}

static LONG ea_addr_100(struct cpu *cpu, int reg, int size)
{
  if(rmw) {
    return cpu->a[reg];
  } else {
    if((size == 1) && (reg == 7)) size = 2; /* SP should get mad, not even */
    cpu->a[reg]-=size;
    return cpu->a[reg];
  }
}

static LONG ea_addr_101(struct cpu *cpu, int reg)
{
  int o;

  o = mmu_read_word(cpu->pc);
  if(o&0x8000) o |= 0xffff0000;

  if(!rmw) {
    cpu->pc += 2;
  }
  return cpu->a[reg]+o;
}

static LONG ea_addr_110(struct cpu *cpu, int reg)
{
{'fraction_non_alphanumeric': 0.16194331983805668, 'fraction_numerical': 0.03788316946211683, 'mean_word_length': 3.817548746518106, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 45, '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': '1574700', 'n_tokens_mistral': 1626, 'n_tokens_neox': 1511, 'n_words': 373}