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

static void andi_to_ccr(struct cpu *cpu, WORD op)
{
  WORD d;

  ENTER;

  ADD_CYCLE(20);
  d = mmu_read_word(cpu->pc)&0x1f;
  cpu->pc += 2;
  cpu_set_sr(cpu->sr&d);
}

static struct cprint *andi_to_ccr_print(LONG addr, WORD op)
{
  struct cprint *ret;

  ret = cprint_alloc(addr);

  strcpy(ret->instr, "ANDI");
  sprintf(ret->data, "#$%x,CCR", mmu_read_word_print(addr+ret->size)&0xff);
  ret->size += 2;
  
  return ret;
}

void andi_to_ccr_init(void *instr[], void *print[])
{
  instr[0x023c] = andi_to_ccr;
  print[0x023c] = andi_to_ccr_print;
}


<commit_msg>We need to do the AND only to the lower byte, not the whole word of SR<commit_after>#include "common.h"
#include "cpu.h"
#include "mmu.h"

static void andi_to_ccr(struct cpu *cpu, WORD op)
{
  WORD d;
  WORD sr;

  ENTER;

  ADD_CYCLE(20);
  d = mmu_read_word(cpu->pc)&0x1f;
  cpu->pc += 2;
  sr = cpu->sr;
  sr = (sr&0xff00)|((sr&0xff)&d);
  cpu_set_sr(sr);
}

static struct cprint *andi_to_ccr_print(LONG addr, WORD op)
{
  struct cprint *ret;

  ret = cprint_alloc(addr);

  strcpy(ret->instr, "ANDI");
  sprintf(ret->data, "#$%x,CCR", mmu_read_word_print(addr+ret->size)&0xff);
  ret->size += 2;
  
  return ret;
}

void andi_to_ccr_init(void *instr[], void *print[])
{
  instr[0x023c] = andi_to_ccr;
  print[0x023c] = andi_to_ccr_print;
}



{'fraction_non_alphanumeric': 0.16727009413468502, 'fraction_numerical': 0.024619840695148443, 'mean_word_length': 4.335907335907336, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '1600861', 'n_tokens_mistral': 661, 'n_tokens_neox': 628, 'n_words': 126}