Day7 - 9-22 Control Flow • Assembly Control Flow o Jump...

Info iconThis preview shows pages 1–2. 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
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 9-22 Control Flow • Assembly Control Flow o Jump • Conditional Control Flow o Compare • Conditional Jumps o J[conditional] o Eg. j_loop Three classes of conditionals • • • Loop Instruction o Loop o o • [label] jge • Cmpl b,a (b = {r,m,i}*; a = {r,m}*; Performs a-b) General Signed Unsigned [label] E.g. movl • • • $15, %ecx . //Code goes here . Loop .L1 Historical – wraps up a bunch of things together, you shouldn’t do it anymore Only works with register %ecx If…then Assembly o Cmpl [cond exp opers] J[!cond] main_body o [main_body] [true body] Main_body: • For Loop Assembly o Look up • While loop assemply o Look up • Notes for Java Programmers o Declare index variable before for loop Int I; o Int main (int arc, char* argv){ For(i=0; i<n; i++){} Vs For (int i=0; i<n; i++){} Uninitialized variables • • • o /*#of iterations*/ } Error handling: Int i; Factorial(i); Return 0; • No exceptions, must look at return values Command Line Arguments in C o Int main(int argc, char * argv) Argc • • Number of arguments (including program name) Argv • • • • • Array of char*s(that is, an array of ‘C’ strings) Argv[0]: = program name Argv[1]: = first argument … Argv[argc-1]: last argument *r = register, m = memory, i = immediate, jle = jump, less than or equal to ...
View Full Document

This note was uploaded on 12/05/2011 for the course ENGINEERIN 131 taught by Professor Cytron during the Spring '11 term at Washington University in St. Louis.

Page1 / 2

Day7 - 9-22 Control Flow • Assembly Control Flow o Jump...

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