Skip to content

Commit

Permalink
Change decode to instruction name file
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsc2 committed Jul 15, 2023
1 parent f5cb5c3 commit 759c788
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
1 change: 0 additions & 1 deletion src/decode.c

This file was deleted.

9 changes: 9 additions & 0 deletions src/instruction.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "instruction.h"

unsigned int size(Instruction ins)
{
if (ins.op1_addr == Imm)
return 2;
else
return 1;
}
35 changes: 24 additions & 11 deletions src/decode.h → src/instruction.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef DECODE_H
#define DECODE_H
#ifndef INS_H
#define INS_H

// Structure of the 63-bit that form the first word of each instruction.
// See Cairo whitepaper, page 32 - https://eprint.iacr.org/2021/1063.pdf.
Expand Down Expand Up @@ -73,19 +73,32 @@ enum Opcode
Ret,
};

// Typedef definitions

typedef enum Res Res;
typedef enum Opcode Opcode;
typedef enum Op1Addr Op1Addr;
typedef enum Register Register;
typedef enum PcUpdate PcUpdate;
typedef enum ApUpdate ApUpdate;
typedef enum FpUpdate FpUpdate;
typedef struct Instruction Instruction;

struct Instruction
{
int off0;
int off1;
int off2;
enum Register dst_reint;
enum Register op0_register;
enum Op1Addr op1_addr;
enum Res res;
enum PcUpdate pc_update;
enum ApUpdate ap_update;
enum FpUpdate fp_update;
enum Opcode opcode;
Register dst_reint;
Register op0_register;
Op1Addr op1_addr;
Res res;
PcUpdate pc_update;
ApUpdate ap_update;
FpUpdate fp_update;
Opcode opcode;
};

#endif
unsigned int size(Instruction ins);

#endif

0 comments on commit 759c788

Please sign in to comment.