Housekeeping
This commit is contained in:
parent
2f1df92c21
commit
3d9ecb0b7b
26
src/modal.c
26
src/modal.c
|
@ -43,24 +43,24 @@ sint(char *s)
|
||||||
static void
|
static void
|
||||||
device_write(char *s)
|
device_write(char *s)
|
||||||
{
|
{
|
||||||
int acc = 0;
|
|
||||||
char c = *s, *cap = walk(s), **reg = regs + '0';
|
char c = *s, *cap = walk(s), **reg = regs + '0';
|
||||||
/* phase: ALU */
|
/* phase: ALU */
|
||||||
if(*reg) {
|
if(*reg) {
|
||||||
|
int acc = sint(*reg++);
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
switch(c) {
|
switch(c) {
|
||||||
case '+': for(acc = sint(*reg++); *reg != 0; reg++) acc += sint(*reg); break;
|
case '+': for(;*reg != 0; reg++) acc += sint(*reg); break;
|
||||||
case '-': for(acc = sint(*reg++); *reg != 0; reg++) acc -= sint(*reg); break;
|
case '-': for(;*reg != 0; reg++) acc -= sint(*reg); break;
|
||||||
case '*': for(acc = sint(*reg++); *reg != 0; reg++) acc *= sint(*reg); break;
|
case '*': for(;*reg != 0; reg++) acc *= sint(*reg); break;
|
||||||
case '/': for(acc = sint(*reg++); *reg != 0; reg++) acc /= sint(*reg); break;
|
case '/': for(;*reg != 0; reg++) acc /= sint(*reg); break;
|
||||||
case '%': for(acc = sint(*reg++); *reg != 0; reg++) acc %= sint(*reg); break;
|
case '%': for(;*reg != 0; reg++) acc %= sint(*reg); break;
|
||||||
case '&': for(acc = sint(*reg++); *reg != 0; reg++) acc &= sint(*reg); break;
|
case '&': for(;*reg != 0; reg++) acc &= sint(*reg); break;
|
||||||
case '^': for(acc = sint(*reg++); *reg != 0; reg++) acc ^= sint(*reg); break;
|
case '^': for(;*reg != 0; reg++) acc ^= sint(*reg); break;
|
||||||
case '|': for(acc = sint(*reg++); *reg != 0; reg++) acc |= sint(*reg); break;
|
case '|': for(;*reg != 0; reg++) acc |= sint(*reg); break;
|
||||||
case '=': for(acc = sint(*reg++); *reg != 0; reg++) acc = acc == sint(*reg); break;
|
case '=': for(;*reg != 0; reg++) acc = acc == sint(*reg); break;
|
||||||
case '!': for(acc = sint(*reg++); *reg != 0; reg++) acc = acc != sint(*reg); break;
|
case '!': for(;*reg != 0; reg++) acc = acc != sint(*reg); break;
|
||||||
case '>': for(acc = sint(*reg++); *reg != 0; reg++) acc = acc > sint(*reg); break;
|
case '>': for(;*reg != 0; reg++) acc = acc > sint(*reg); break;
|
||||||
case '<': for(acc = sint(*reg++); *reg != 0; reg++) acc = acc < sint(*reg); break;
|
case '<': for(;*reg != 0; reg++) acc = acc < sint(*reg); break;
|
||||||
}
|
}
|
||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
dst_ += snprintf(dst_, 0x10, "%d", acc);
|
dst_ += snprintf(dst_, 0x10, "%d", acc);
|
||||||
|
|
Loading…
Reference in New Issue