Keep input format during arithmetic
This commit is contained in:
parent
f88bb1f137
commit
5419d9579a
|
@ -2,4 +2,9 @@
|
||||||
?(?: ?:) \101
|
?(?: ?:) \101
|
||||||
?(?: ?:) \#6c
|
?(?: ?:) \#6c
|
||||||
?(?: ?:) \108
|
?(?: ?:) \108
|
||||||
?(?: ?:) \#6f
|
?(?: ?:) \#6f
|
||||||
|
|
||||||
|
?(?: ?:) \#ce
|
||||||
|
?(?: ?:) \#bb
|
||||||
|
|
||||||
|
?((?: ?0 ?1) ?:) + #34 #67
|
||||||
|
|
|
@ -59,7 +59,7 @@ device_write(char *s)
|
||||||
char **reg = regs + '0';
|
char **reg = regs + '0';
|
||||||
/* phase: ALU */
|
/* phase: ALU */
|
||||||
if(*reg) {
|
if(*reg) {
|
||||||
int acc = sint(*reg++);
|
int hex = **reg == '#', acc = sint(*reg++);
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
switch(*s) {
|
switch(*s) {
|
||||||
case '+': while(*reg) acc += sint(*reg++); break;
|
case '+': while(*reg) acc += sint(*reg++); break;
|
||||||
|
@ -76,7 +76,7 @@ device_write(char *s)
|
||||||
case '<': while(*reg) acc = acc < sint(*reg++); break;
|
case '<': while(*reg) acc = acc < sint(*reg++); break;
|
||||||
}
|
}
|
||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
dst_ += snprintf(dst_, 0x10, "%d", acc);
|
dst_ += snprintf(dst_, 0x10, hex ? "#%x" : "%d", acc);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
/* phase: string */
|
/* phase: string */
|
||||||
|
|
Loading…
Reference in New Issue