Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
245 views
in Technique[技术] by (71.8m points)

assembly - Three approaches to design conditional instructions

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...