设计条件指令的三种方法 [英] Three approaches to design conditional instructions

查看:108
本文介绍了设计条件指令的三种方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过一张图片,展示了3种设计条件指令的方法.看起来像:

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

我不知道这是怎么回事.我可以在Google中搜索,但找不到任何东西.如果有人知道这是什么,请把我引到某个地方.

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.

推荐答案

您还需要哪种其他信息?我本来打算将其发布为评论,但它可能可以作为答案.

What kind of other information do you want? I was going to post this as a comment, but it might work as an answer.

谓词版本对我来说似乎很奇怪,但这可能是因为我习惯于看到谓词指令只是将标志用作输入.

The predicate version looks pretty weird to me, but that's probably because I'm used to seeing predicated instructions just use the flags as inputs.

cmp产生两个相反的结果似乎很奇怪.这真的比让指令使用谓词的逆数简单吗? (2结果cmp与每个谓词指令编码中的额外位)

And it seems really weird for cmp to produce two separate results, inverse of each other. Is that really easier than letting instructions use the inverse of a predicate? (2-result cmp vs. an extra bit in the encoding of every predicated instruction)

除此之外,如果您已经看过x86,那么一切看起来都非常明显和直接. IIRC,MIPS更像是一步一步"版本,因为它的比较指令不是使用FLAGS寄存器,而是使用GP寄存器作为输出.

Other than that, everything looks really obvious and straightforward, if you've seen x86. IIRC, MIPS is more like the "One step" version, since instead of a FLAGS register, its compare instructions use GP registers as outputs.

这篇关于设计条件指令的三种方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆