Go语言汇编的条件跳转指令有哪些?

huangapple go评论70阅读模式
英文:

What are the conditional jump instructions for Go's assembler?

问题

Go语言的6a汇编器具有条件跳转指令:

JCC
JCS
JCXZL
JEQ
JGE
JGT
JHI
JLE
JLS
JLT
JMI
JNE
JOC
JOS
JPC
JPL
JPS

但是它们如何映射到x86条件跳转指令呢?

英文:

Go's 6a assembler has conditional jump instructions:

JCC
JCS
JCXZL
JEQ
JGE
JGT
JHI
JLE
JLS
JLT
JMI
JNE
JOC
JOS
JPC
JPL
JPS

But how do they map to x86 conditional jumps?

答案1

得分: 12

我正在回答这个问题,这样我就不会丢失信息,其他人也不必经历和我一样的搜寻游戏。通过查看optab.cx86跳转指令,我们可以将指令编码进行匹配,解决这个谜题。

JCC		JAE
JCS		JB
JCXZL	JECXZ
JEQ		JE,JZ
JGE		JGE
JGT		JG
JHI		JA
JLE		JLE
JLS		JBE
JLT		JL
JMI		JS
JNE		JNE, JNZ
JOC		JNO
JOS		JO
JPC		JNP, JPO
JPL		JNS
JPS		JP, JPE
英文:

I'm answering this so I don't lose the information, and so other people don't have to go through the same sleuthing game as me. Looking at optab.c and the x86 jumps we can match up the instruction encodings to solve the puzzle.

JCC		JAE
JCS		JB
JCXZL	JECXZ
JEQ		JE,JZ
JGE		JGE
JGT		JG
JHI		JA
JLE		JLE
JLS		JBE
JLT		JL
JMI		JS
JNE		JNE, JNZ
JOC		JNO
JOS		JO
JPC		JNP, JPO
JPL		JNS
JPS		JP, JPE

答案2

得分: 2

Go汇编器的arch.go文件中写道:

instructions["JA"]  = x86.AJHI
instructions["JAE"] = x86.AJCC
instructions["JB"]  = x86.AJCS
等等

这意味着Go汇编中的JHI相当于Intel汇编中的JA,以此类推。

英文:

The Go assembler's arch.go says:

instructions["JA"]  = x86.AJHI
instructions["JAE"] = x86.AJCC
instructions["JB"]  = x86.AJCS
etc

which means that Go asm's JHI means Intel asm's JA, etc.

huangapple
  • 本文由 发表于 2015年5月10日 09:06:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/30146642.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定