70 likes | 297 Views
Jump Statements. Assembly. Jump Statement Commands. JMP 0150 JZ 01C2 – zero = 1 JNZ 0240 – zero = 0 JP 012C – sign = 1 JM 11C0 – sign = 0. Comparison Instructions. CMP B – CPI 20 –. Example #1. High Level: Low Level: if amount > 20 then amount := 20 end if. Example #2.
E N D
Jump Statements Assembly
Jump Statement Commands • JMP 0150 • JZ 01C2 – zero = 1 • JNZ 0240 – zero = 0 • JP 012C – sign = 1 • JM 11C0 – sign = 0
Comparison Instructions • CMP B – • CPI 20 –
Example #1 High Level: Low Level: if amount > 20 then amount := 20 end if
Example #2 High Level: Low Level: loop i ++ exit when i >= 5 end loop
Example #3 High Level: Low Level: var sum : int := 0 for i : 1 .. 20sum := sum + i end for