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