Computer Organization and Assembly Language: Conditional Processing (Part II)
Computer Organization and Assembly Language: Conditional Processing (Part II)
Computer Organization and Assembly Language: Conditional Processing (Part II)
Week 15-1
Conditional Processing
(Part II)
What's Next
Specific jumps:
JB, JC - jump to a label if the Carry flag is set
JE, JZ - jump to a label if the Zero flag is set
JS - jump to a label if the Sign flag is set
JNE, JNZ - jump to a label if the Zero flag is clear
JECXZ - jump to a label if ECX = 0
Jcond Ranges
Prior to the 386:
jump must be within –128 to +127 bytes from
current location counter
x86 processors:
32-bit offset permits jump anywhere in memory
Jumps Based on Specific Flags
Jumps Based on Equality
Jumps Based on Unsigned
Comparisons
Jumps Based on Signed Comparisons
Applications (1 of 5)
• Task: Jump to a label if unsigned EAX is greater than EBX
• Solution: Use CMP, followed by JA
cmp eax,ebx
ja Larger
cmp eax,ebx
jg Greater
Applications (2 of 5)
cmp eax,Val1
jbe L1 ; below or equal
cmp eax,Val1
jle L1
Applications (3 of 5)
• Compare unsigned AX to BX, and copy the larger of the two
into a variable named Large
mov Large,bx
cmp ax,bx
jna Next
mov Large,ax
Next: