1 / 18

IF ((x < y) and (z > t)) or (a <>b) then

IF ((x < y) and (z > t)) or (a <>b) then. Compiler Generated Code mov cl, 1 mov ax, x cmp ax, y jl istrue mov cl, 0 ; if false set cl =0 istrue: mov ax, z cmp ax, t jg andtrue mov cl, 0 ; if false set cl =0. IF ((x < y) and (z > t)) or (a <>b) then.

corbin
Télécharger la présentation

IF ((x < y) and (z > t)) or (a <>b) then

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. IF ((x < y) and (z > t)) or (a <>b) then • Compiler Generated Code mov cl, 1 mov ax, x cmp ax, y jl istrue mov cl, 0 ; if false set cl =0 istrue: mov ax, z cmp ax, t jg andtrue mov cl, 0 ; if false set cl =0 Lecture 27

  2. IF ((x < y) and (z > t)) or (a <>b) then andtrue: mov al, a cmp al, b je orfalse mov cl, 1 ; if true set cl =1 orfalse: cmp cl,1 jne endif then: ……. ……. endif: Lecture 27

  3. IF ((x < y) and (z > t)) or (a <>b) then • Optimized Code mov ax, a cmp ax, b jne then mov ax, x cmp ax, y jnl endif Lecture 27

  4. IF ((x < y) and (z > t)) or (a <>b) then mov ax, z cmp ax, t jng endif then: ……… ……… endif: Lecture 27

  5. If (a=b) then c=d else b=b+1 mov ax, a cmp ax, b jne else mov ax, d mov c, ax jmp endif else: inc b endif: IF THEN ELSE statement Lecture 27

  6. While Loop • Do while (op1 < op2) • ……….. • ……….. • enddo Lecture 27

  7. i = 0 while (i < 100) do i=i+1 mov i, 0 whilelp: cmp i, 100 jge whiledone inc i jmp whilelp whiledone: While Loop Lecture 27

  8. do while (op1 < op2) Statement1 If (op2=op3) then Statement2 Statement3 else statement4 endif enddo whiledo: cmp op1, op2 jnl whiledone statement1 cmp op2, op3 jne else statement2 statement3 jmp endif If statement nested in a While Loop Lecture 27

  9. do while (op1 < op2) Statement1 If (op2=op3) then Statement2 Statement3 else statement4 endif enddo else: statement4 endif: jmp whiledo whiledone: If statement nested in a While Loop Lecture 27

  10. Repeat Loop • Repeat • Statement1 • Statmenet2 • Statement3 • Until (op1 = op2) Lecture 27

  11. Repeat Statement1 Statement2 Statement3 Until (op1=op2) or (op1 > op3) repeat: Statement1 Statement2 Statement3 test1: cmp op1,op2 je endrepeat Repeat Loop Lecture 27

  12. Repeat Statement1 Statement2 Statement3 Until (op1=op2) or (op1 > op3) test2: cmp op1,op3 jng repeat endrepeat: Repeat Loop Lecture 27

  13. Case statement (switch) • Case I of • 0: statement1 • 1: statement2 • 2: statement3 • end Lecture 27

  14. Case statement (switch) • if i=0 then statement1 • else if i=1 then statement2 • else if i=2 then statement3 Lecture 27

  15. Case statement (switch) • mov bx, i • shl bx, 1 • jmp cs: jmptbl[bx] • jmptbl word stmt0, stmt1, stmt2 • stmt0: ……… • ……… • jmp endcase • stmt1: ……… • ……… • jmp endcase • stmt2: ……… • ……… • endcase: Lecture 27

  16. Case I of 5: statement1 8: statement2 10: statement3 12: statement4 15: statement5 otherwise statement6 end mov bx, i cmp bx, 5 jl otherwise cmp bx, 15 jg otherwise shl bx, 1 jmp cs: jmptbl-10[bx] Non consecutive case Lecture 27

  17. Non consecutive case • otherwise: • statement6 • jmp case done • jmptbl word stat1, otherwise, otherwise, stat2 • word otherwise, stat3, otherwise, stat4 • word otherwise, otherwise, stat5 Lecture 27

  18. Case I of 0: statement1 1: statement2 2: statement3 100: statement4 otherwise statement5 end mov bx, i cmp bx, 100 je is100 cmp bx, 2 ja otherwise shl bx, 1 jmp cs:jmptabl[bx] Non consecutive case Lecture 27

More Related