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

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

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

问题

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

  1. JCC
  2. JCS
  3. JCXZL
  4. JEQ
  5. JGE
  6. JGT
  7. JHI
  8. JLE
  9. JLS
  10. JLT
  11. JMI
  12. JNE
  13. JOC
  14. JOS
  15. JPC
  16. JPL
  17. JPS

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

英文:

Go's 6a assembler has conditional jump instructions:

  1. JCC
  2. JCS
  3. JCXZL
  4. JEQ
  5. JGE
  6. JGT
  7. JHI
  8. JLE
  9. JLS
  10. JLT
  11. JMI
  12. JNE
  13. JOC
  14. JOS
  15. JPC
  16. JPL
  17. JPS

But how do they map to x86 conditional jumps?

答案1

得分: 12

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

  1. JCC JAE
  2. JCS JB
  3. JCXZL JECXZ
  4. JEQ JE,JZ
  5. JGE JGE
  6. JGT JG
  7. JHI JA
  8. JLE JLE
  9. JLS JBE
  10. JLT JL
  11. JMI JS
  12. JNE JNE, JNZ
  13. JOC JNO
  14. JOS JO
  15. JPC JNP, JPO
  16. JPL JNS
  17. 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.

  1. JCC JAE
  2. JCS JB
  3. JCXZL JECXZ
  4. JEQ JE,JZ
  5. JGE JGE
  6. JGT JG
  7. JHI JA
  8. JLE JLE
  9. JLS JBE
  10. JLT JL
  11. JMI JS
  12. JNE JNE, JNZ
  13. JOC JNO
  14. JOS JO
  15. JPC JNP, JPO
  16. JPL JNS
  17. JPS JP, JPE

答案2

得分: 2

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

  1. instructions["JA"] = x86.AJHI
  2. instructions["JAE"] = x86.AJCC
  3. instructions["JB"] = x86.AJCS
  4. 等等

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

英文:

The Go assembler's arch.go says:

  1. instructions["JA"] = x86.AJHI
  2. instructions["JAE"] = x86.AJCC
  3. instructions["JB"] = x86.AJCS
  4. 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:

确定