<commit_before>/*
 * decoder - this compilation unit defines functions used for decoding binary
 * data into the instructions they represent
 */
#include "core.h"
#include "decoder.h"
#include "risky.h"


#ifdef __cplusplus
extern "C"{
#endif

/*
 * given a pointer to a risky_raw_instruction_t and a pointer to a
 * risky_instruction_t, decode the raw instruction data and write the
 * instruction opcode, flags and operands to the risky_instruction_t.
 * returns a status_t with error / success information
 */
status_t decode_instruction_from_raw(
    risky_raw_instruction_t * raw, risky_instruction_t * instruction
) {
    status_t result = STATUS_UNKNOWN;
    // dummy implementation to avoid 'arguments unused' errors
    instruction->opcode = raw->bytes[0] % 32;
    return result;
}

#ifdef __cplusplus
} // extern "C"
#endif<commit_msg>Add initial proper implementation of instruction decoder This causes the tests for NOP and HLT instructions to now pass<commit_after>/*
 * decoder - this compilation unit defines functions used for decoding binary
 * data into the instructions they represent
 */
#include "core.h"
#include "decoder.h"
#include "risky.h"


#ifdef __cplusplus
extern "C"{
#endif

/*
 * given a pointer to a risky_raw_instruction_t and a pointer to a
 * risky_instruction_t, decode the raw instruction data and write the
 * instruction opcode, flags and operands to the risky_instruction_t.
 * returns a status_t with error / success information
 */
status_t decode_instruction_from_raw(
    risky_raw_instruction_t * raw, risky_instruction_t * instruction
) {
    // copy across opcode
    instruction->opcode = (risky_opcode_t)(raw->bytes[0] >> 3) % 32;
    // set all other fields to 0
    instruction->a_flag = false;
    instruction->b_flag = false;
    instruction->c_flag = false;
    instruction->r = 0;
    instruction->a = 0;
    instruction->b = 0;
    instruction->l = 0;
    status_t result = STATUS_SUCCESS;
    return result;
}

#ifdef __cplusplus
} // extern "C"
#endif
{'fraction_non_alphanumeric': 0.08548707753479125, 'fraction_numerical': 0.005964214711729622, 'mean_word_length': 4.007462686567164, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, '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': '6489773', 'n_tokens_mistral': 628, 'n_tokens_neox': 587, 'n_words': 212}