Added logic operators to ALU
This commit is contained in:
parent
0a1b6bfb5c
commit
c9e932765a
|
@ -47,8 +47,8 @@ device_write(char *s)
|
|||
char c = *s, *cap = walk(s), **reg = regs + '0';
|
||||
/* phase: ALU */
|
||||
if(*reg) {
|
||||
switch(c) {
|
||||
/* clang-format off */
|
||||
switch(c) {
|
||||
case '+': for(acc = sint(*reg++); *reg != 0; reg++) acc += sint(*reg); break;
|
||||
case '-': for(acc = sint(*reg++); *reg != 0; reg++) acc -= sint(*reg); break;
|
||||
case '*': for(acc = sint(*reg++); *reg != 0; reg++) acc *= sint(*reg); break;
|
||||
|
@ -57,8 +57,12 @@ device_write(char *s)
|
|||
case '&': for(acc = sint(*reg++); *reg != 0; reg++) acc &= sint(*reg); break;
|
||||
case '^': for(acc = sint(*reg++); *reg != 0; reg++) acc ^= sint(*reg); break;
|
||||
case '|': for(acc = sint(*reg++); *reg != 0; reg++) acc |= sint(*reg); break;
|
||||
/* clang-format on */
|
||||
case '=': for(acc = sint(*reg++); *reg != 0; reg++) acc = acc == sint(*reg); break;
|
||||
case '!': for(acc = sint(*reg++); *reg != 0; reg++) acc = acc != sint(*reg); break;
|
||||
case '>': for(acc = sint(*reg++); *reg != 0; reg++) acc = acc > sint(*reg); break;
|
||||
case '<': for(acc = sint(*reg++); *reg != 0; reg++) acc = acc < sint(*reg); break;
|
||||
}
|
||||
/* clang-format on */
|
||||
dst_ += snprintf(dst_, 0x10, "%d", acc);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue