Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

assembly

go

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?

like image 701
Eloff Avatar asked May 10 '15 01:05

Eloff


People also ask

What are the conditional jump instructions?

A conditional jump instruction, like "je" (jump-if-equal), does a goto somewhere if the two values satisfy the right condition. For example, if the values are equal, subtracting them results in zero, so "je" is the same as "jz".

What is conditional instruction in assembly language?

The conditional instructions transfer the control by breaking the sequential flow and they do it by changing the offset value in IP.

What do you mean by conditional jump?

conditional jump (conditional branch) A jump that takes place only if a specified condition holds, e.g. specified register contents zero, nonzero, negative, etc. A Dictionary of Computing. "conditional jump ."


2 Answers

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
like image 87
Eloff Avatar answered Nov 08 '22 09:11

Eloff


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.

like image 27
Nigel Tao Avatar answered Nov 08 '22 09:11

Nigel Tao