Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/rules/rules.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3119,7 +3119,13 @@ static int16_t rule_create(char **text, struct rules_t *obj) {
jmp = (struct vm_top_t *)&obj->bc.buffer[lastjmp];
if((int8_t)getval(jmp->b) == depth) {
int16_t step = getval(obj->bc.nrbytes);
setval(jmp->a, ((step-lastjmp)/sizeof(struct vm_top_t))+1);
int32_t jump = (step-lastjmp)/(int32_t)sizeof(struct vm_top_t)+1;
if(jump > UINT8_MAX) {
logprintf_P(F("ERROR: rule #%d: conditional jump of %ld instructions exceeds 255"),
getval(obj->nr), (long)jump);
return -1;
}
setval(jmp->a, jump);
setval(jmp->b, 0);
break;
}
Expand Down Expand Up @@ -4253,8 +4259,14 @@ static int16_t rule_create(char **text, struct rules_t *obj) {
if(gettype(obj->bc.buffer[lastjmp]) == OP_JMP) {
jmp = (struct vm_top_t *)&obj->bc.buffer[lastjmp];
if((int8_t)getval(jmp->b) == depth) {
int32_t jump = (step-lastjmp)/(int32_t)sizeof(struct vm_top_t);
if(jump > UINT8_MAX) {
logprintf_P(F("ERROR: rule #%d: conditional jump of %ld instructions exceeds 255"),
getval(obj->nr), (long)jump);
return -1;
}
setval(jmp->b, 0);
setval(jmp->a, ((step-lastjmp)/sizeof(struct vm_top_t)));
setval(jmp->a, jump);
}
}
}
Expand Down
Loading