Skip to content

Commit

Permalink
Small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tekknolagi committed May 15, 2019
1 parent d0678d8 commit c0b1914
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions rabbit.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ typedef enum rabbitr {
RB_NUMREGS,
} rabbitr;

const unsigned kZeroFlag = 0x2U;

/* Instructions available for use. */
typedef enum rabbiti {
RB_HALT = 0,
Expand Down Expand Up @@ -177,8 +179,7 @@ int main(int argc, char **argv) {
rabbitw res = abc.b - abc.c;
*abc.dst = res;
if (res == 0) {
/* Set zero flag. */
regs[RB_FLAGS] |= 0x2U;
regs[RB_FLAGS] |= kZeroFlag;
}
break;
case RB_MUL:
Expand Down Expand Up @@ -218,14 +219,14 @@ int main(int argc, char **argv) {
}
case RB_BRZ:
/* Branch if zero is special because it only has one argument. */
if ((regs[RB_FLAGS] & 0x2U) == 0) {
if ((regs[RB_FLAGS] & kZeroFlag) == 0) {
rabbitw src = i.modes.immediate ? fetch_immediate() : regs[i.regc];
regs[RB_IP] = i.modes.regc_deref ? mem[src] : src;
}
break;
case RB_BRNZ:
/* Branch not zero is special because it only has one argument. */
if ((regs[RB_FLAGS] & 0x2U) != 0) {
if ((regs[RB_FLAGS] & kZeroFlag) != 0) {
rabbitw src = i.modes.immediate ? fetch_immediate() : regs[i.regc];
regs[RB_IP] = i.modes.regc_deref ? mem[src] : src;
}
Expand Down
2 changes: 1 addition & 1 deletion rabbit_bif.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ enum BifId {

#define BIF_NAME(id, name) #name,

static const char *bif_table[] = {BIF_TABLE(BIF_NAME)};
const char *bif_table[] = {BIF_TABLE(BIF_NAME)};

#undef BIF_NAME

Expand Down

0 comments on commit c0b1914

Please sign in to comment.