Housekeeping

This commit is contained in:
Devine Lu Linvega 2024-04-28 21:23:27 -07:00
parent 2f1df92c21
commit 3d9ecb0b7b
1 changed files with 13 additions and 13 deletions

View File

@ -43,24 +43,24 @@ sint(char *s)
static void
device_write(char *s)
{
int acc = 0;
char c = *s, *cap = walk(s), **reg = regs + '0';
/* phase: ALU */
if(*reg) {
int acc = sint(*reg++);
/* 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;
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;
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 = 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;
case '+': for(;*reg != 0; reg++) acc += sint(*reg); break;
case '-': for(;*reg != 0; reg++) acc -= sint(*reg); break;
case '*': for(;*reg != 0; reg++) acc *= sint(*reg); break;
case '/': for(;*reg != 0; reg++) acc /= sint(*reg); break;
case '%': for(;*reg != 0; reg++) acc %= sint(*reg); break;
case '&': for(;*reg != 0; reg++) acc &= sint(*reg); break;
case '^': for(;*reg != 0; reg++) acc ^= sint(*reg); break;
case '|': for(;*reg != 0; reg++) acc |= sint(*reg); break;
case '=': for(;*reg != 0; reg++) acc = acc == sint(*reg); break;
case '!': for(;*reg != 0; reg++) acc = acc != sint(*reg); break;
case '>': for(;*reg != 0; reg++) acc = acc > sint(*reg); break;
case '<': for(;*reg != 0; reg++) acc = acc < sint(*reg); break;
}
/* clang-format on */
dst_ += snprintf(dst_, 0x10, "%d", acc);