Jump to content
  • Advertisement
Sign in to follow this  
FreJa

quadruples and intermediate code gen

This topic is 3644 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!