Skip to content

How to implement a 'context stack' in Sleigh? #7173

Answered by GhidorahRex
hippietrail asked this question in Q&A
Discussion options

You must be logged in to vote

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 a FOR loop, AND you'll never have a FMT nested in a FMT - so you still only need a depth counter.

So I would make FENDlike :FEND is fmt>0 & op=0xFB. Then for LOOP 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 and NEXT - how does the parser know whether …

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@hippietrail
Comment options

@GhidorahRex
Comment options

@hippietrail
Comment options

@GhidorahRex
Comment options

Answer selected by hippietrail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants