Skip to content

Commit

Permalink
avoid branch
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoChen1024 committed Dec 2, 2020
1 parent 7a43824 commit ae95995
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions libbrainfunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ EXEC(a)
EXEC(mul)
{
/* *(Current + offset) += Current * mul */
if(cpu->mem[cpu->ptr] != 0)
cpu->mem[(cpu->ptr + cpu->code[cpu->pc].arg.dual.offset) % cpu->size.mem] += cpu->mem[cpu->ptr] * cpu->code[cpu->pc].arg.dual.mul;
cpu->mem[(cpu->ptr + cpu->code[cpu->pc].arg.dual.offset) % cpu->size.mem] += cpu->mem[cpu->ptr] * cpu->code[cpu->pc].arg.dual.mul;
cpu->pc++;
return _CONT;
}
Expand Down
4 changes: 2 additions & 2 deletions libstdbfc.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pid_t p=0;

typedef uint8_t memory_t;
memory_t *memory;
int ptr=0;
unsigned int ptr=0;

#define current (memory[ptr])

Expand All @@ -61,7 +61,7 @@ void panic(char *msg)
#define a(x) \
current += x
#define mul(mul, offset) \
if(memory[ptr]) memory[ptr + offset] += current * mul
memory[(ptr + offset) % MEMSIZE] += current * mul
#define s(x) \
current = x
#define f(x) \
Expand Down

0 comments on commit ae95995

Please sign in to comment.