Only get reg id once

This commit is contained in:
Devine Lu Linvega 2024-04-24 11:20:34 -07:00
parent 3136ae834f
commit 986a1b47dd
2 changed files with 4 additions and 2 deletions

View File

@ -13,6 +13,8 @@ debug: all bin/modal-debug
@ bin/modal-debug examples/hello.modal
test: all bin/modal-debug bin/modal
@ bin/modal -v
@ bin/modal-debug -q examples/fizzbuzz.modal
@ bin/modal-debug -q examples/sierpinski.modal
@ bin/modal-debug -q examples/tests.modal
install: bin/modal
cp bin/modal ~/bin/

View File

@ -129,9 +129,9 @@ apply_rule(Rule *r, char *s)
if(!(c = *s) || spacer(c)) {
char *b = r->b, *origin = dst_;
while((c = *b++)) {
if(c == '?' && (unsigned int)(*b - '0') < 9) {
if(c == '?') {
unsigned int id = *b - '0';
if((reg = regs[id])) {
if(id < 9 && (reg = regs[id])) {
b++;
if(!write_reg(r->key[id], reg) && dst_ != origin) dst_--;
} else