How to implement a 'context stack' in Sleigh? #7173
-
The instruction set I'm working with has different interpretations of most opcodes after
But it turns out the This means I need a context stack rather than just depth. But I'm stuck trying to implement it. Can I actually use structs/objects or only integers for these context registers? I can't find any evidence that anything other than integers can be used but haven't fully internalized the docs despite several readings. So assuming the alternative is a shift register where a How can I check the low bit of my
I've tried with various combinations of parentheses around the logic. I've also tried to add a second context variable representing just the bit at the top of the stack. But
I added the What am I doing wrong? Or am I missing an easier way to achieve this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
You can definitely only use integers for context. The trouble isn't the opcode overlap as much as the nested FOR loops, although you can't really solve the overlap without solving the nested loops. The good news is that you won't ever have a So I would make That should at least get you through some of the parsing issues, but the next challenge is properly representing the loop counts. Also I'm unsure of the difference between But if you wanted to reference the a specific bit of a context field, you need to make a sub-variable such as:
I know the doc mentions |
Beta Was this translation helpful? Give feedback.
You can definitely only use integers for context. The trouble isn't the opcode overlap as much as the nested FOR loops, although you can't really solve the overlap without solving the nested loops. The good news is that you won't ever have a
FMT
nested in aFOR
loop, AND you'll never have aFMT
nested in aFMT
- so you still only need a depth counter.So I would make
FEND
like:FEND is fmt>0 & op=0xFB
. Then forLOOP
we have:LOOP LoopAddr is (fmt < 1) & op=0xFB & LoopAddr
That should at least get you through some of the parsing issues, but the next challenge is properly representing the loop counts. Also I'm unsure of the difference between
LOOP
andNEXT
- how does the parser know whether …