lecture-06-6up - If statements Processing control...

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

View Full Document Right Arrow Icon
Processing control structures Tuesday, October 12, 2010 If statements if <bool_expr_1> then <stmt_list_1> elseif <bool_expr_2> then <stmt_list_2> ... else <stmt_list_3> endif Tuesday, October 12, 2010 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 Tuesday, October 12, 2010 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: Tuesday, October 12, 2010 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, pass LABEL around to routine which does need to generate it Remember: labels have to be unique! Tuesday, October 12, 2010 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? Need to insert JMP instructions before knowing where the label
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the 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.

Page1 / 4

lecture-06-6up - If statements Processing control...

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

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