lecture-06

lecture-06 - Processing control structures Tuesday, October...

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

View Full Document Right Arrow Icon
Processing control structures Tuesday, October 12, 2010
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 2
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
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background image of page 4
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
Background image of page 5

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

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

Page1 / 20

lecture-06 - Processing control structures Tuesday, October...

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