quadruples and intermediate code gen

Started by
2 comments, last by OldGuy 15 years, 10 months ago
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!
"Through me the road to the city of desolation,Through me the road to sorrows diuturnal,Through me the road among the lost creation."
Advertisement
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.
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.
RIP GameDev.net: launched 2 unusably-broken forum engines in as many years, and now has ceased operating as a forum at all, happy to remain naught but an advertising platform with an attached social media presense, headed by a staff who by their own admission have no idea what their userbase wants or expects.Here's to the good times; shame they exist in the past.
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