Comments (3)
Have you also set Pcond
?
Heres an example of a conditional jump:
https://github.com/go-interpreter/wagon/blob/master/exec/internal/compile/backend_amd64.go#L895
A few things to note:
- Set type to
obj.TYPE_BRANCH
- Unless you are jumping backward, you need to emit the instruction first before filling in
Pcond
- Set
Pcond
once the instruction you are jumping to has been allocated
EG:
jmpNaN := builder.NewProg()
jmpNaN.As = x86.AJPS // jump parity set. Parity is set for NaN computations.
jmpNaN.To.Type = obj.TYPE_BRANCH
builder.AddInstruction(jmpNaN)
// some instructions ...
writeNaNVal := builder.NewProg()
writeNaNVal.From.Type = obj.TYPE_CONST
writeNaNVal.From.Offset = 0
writeNaNVal.To.Type = obj.TYPE_REG
writeNaNVal.To.Reg = x86.REG_AX
writeNaNVal.As = x86.AMOVQ
jmpNaN.Pcond = writeNaNVal // <--- see what I did there ?
builder.AddInstruction(writeNaNVal)
I'm not sure if you can jump to a constant offset using Go's assembler.
from golang-asm.
Update: It looks like for x86.AJGT
it is required to use obj.TYPE_BRANCH
. But still ignores the Offset
. Investigating...
- 00000000 7f 45
+ 00000000 7f fe
from golang-asm.
Yeah. This way works. It veery inconvenient in my case, but much better than nothing :)
Thank you!
from golang-asm.
Related Issues (4)
- FLD is missing in x86 HOT 6
- bad LICENSE HOT 1
- Suffix for high byte register (e.g. AH, BH) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from golang-asm.