Replaced ari for loop with while

This commit is contained in:
Devine Lu Linvega 2024-04-29 09:50:43 -07:00
parent c619581739
commit 4078919811
1 changed files with 12 additions and 12 deletions

View File

@ -50,18 +50,18 @@ device_write(char *s)
int acc = sint(*reg++);
/* clang-format off */
switch(c) {
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;
case '+': while(*reg) acc += sint(*reg++); break;
case '-': while(*reg) acc -= sint(*reg++); break;
case '*': while(*reg) acc *= sint(*reg++); break;
case '/': while(*reg) acc /= sint(*reg++); break;
case '%': while(*reg) acc %= sint(*reg++); break;
case '&': while(*reg) acc &= sint(*reg++); break;
case '^': while(*reg) acc ^= sint(*reg++); break;
case '|': while(*reg) acc |= sint(*reg++); break;
case '=': while(*reg) acc = acc == sint(*reg++); break;
case '!': while(*reg) acc = acc != sint(*reg++); break;
case '>': while(*reg) acc = acc > sint(*reg++); break;
case '<': while(*reg) acc = acc < sint(*reg++); break;
}
/* clang-format on */
dst_ += snprintf(dst_, 0x10, "%d", acc);