lecture-05 - Processing control structures Monday,...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Processing control structures Monday, September 26, 2011 If statements if <bool_expr_1> then <stmt_list_1> elseif <bool_expr_2> then <stmt_list_2> ... else <stmt_list_3> endif Monday, September 26, 2011 If statements stmt_list_1 bool_expr_1 if_stmt elseif cond then_block else_list stmt_list_2 bool_expr_2 else cond then_block next ... stmt_list_3 then_block Monday, September 26, 2011 Generating code for ifs if <bool_expr_1> then <stmt_list_1> elseif <bool_expr_2> then <stmt_list_2> else <stmt_list_3> endif <code for bool_expr_1> j<!op> ELSE_1 <code for stmt_list_1> jmp OUT ELSE_1: <code for bool_expr_2> j<!op> ELSE <code for stmt_list_2> jmp OUT ELSE: <code for stmt_list_3> OUT: Monday, September 26, 2011 Notes on code generation The <op> in j<!op> is dependent on the type of comparison you are doing in <bool_expr> When you generate JUMP instructions, you should also generate the appropriate LABELs But you may not put the LABEL into the code immediately e.g. , the OUT label (when should you create this? When should you put this in code?) Instead, generate the labels when you Frst process the if statement (i.e., before you process the children) so that its available when necessary Remember: labels have to be unique! Monday, September 26, 2011 Directly generating binary code Recall difference between assembly code and machine code Assembly code must be processed by assembler, machine code directly executable One job of assembler: decide actual addresses to jump to instead of labels So what happens if we generate binary directly?...
View Full Document

This note was uploaded on 02/19/2012 for the course ECE 468 taught by Professor Test during the Fall '08 term at Purdue University-West Lafayette.

Page1 / 21

lecture-05 - Processing control structures Monday,...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online