quadruples and intermediate code gen
Hey,
I understand that assignment/copy statements can be saved in a quadruple (three-adress statement implementation) ( op | arg1 | arg2 | result ). Are conditional jumps, such as if, while, etc also saved in these tables? If so, how? If not, where would I put them?
Thanks!
Sure, if you write the engine, then you can determine what the operands mean for each op type.
For example, you could have a 'branch on 0' op that (typically) looks at the top of the stack and branches if the value is 0. The first operand of this tuple could be the statement number to branch to.
Having a stack is, of course, critical to designing such ops.
For example, you could have a 'branch on 0' op that (typically) looks at the top of the stack and branches if the value is 0. The first operand of this tuple could be the statement number to branch to.
Having a stack is, of course, critical to designing such ops.
If it's register calculus you're working with, a branch operation could look at the contents of arg1, and based on a condition inherent in the operation, branch to statement arg2, or somesuch. No stack involved.
Well, if there are any sort of complex expressions (e.g. the IF condition is a complex expression like equations, function calls, etc), a stack is essential. Or, should I say easier?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement