I've seen a one picture presenting 3 approaches to desing conditional instruction. It looks like:
1. One step:
bz s1, label ; branch if s1 = 0
jecxa label ; branch if ecx = 0
2. Two steps with tags:
CP A, 0 ; set flags
JR Z, MULEND ; jump if Z = 1
cmp eax, 0 ; set flags
jz mulend ; jump if zf = 1
3. Two step with predicates:
cmp.eq p1, p2 = r1, r2 ; if r1=r2
(p1) add r3 = 1, r3 ; then r3 := r3 +1
(p2) add r3 = 3, r3 ; else r3 := r3 + 3
And I don't what's going on. I could search in google but I cannot find anything. If someone knows what is it, please reference me to somewhere.
I would like to compare those free ways of controlling a flow of the program:
So:
Advantages:
1. There is no data-dependency ( flag register)
2. None?
3. There is less branch instruction in implementation of if-then-else
Disadvantages:
1. None?
2. There is data-dependency ( flag register)
3. Data-dependency of registers for the true-predicate and the false-predicate
Please mark it and say something else.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…