Giter VIP home page Giter VIP logo

Comments (3)

twitchyliquid64 avatar twitchyliquid64 commented on July 18, 2024 1

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.

xaionaro avatar xaionaro commented on July 18, 2024

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.

xaionaro avatar xaionaro commented on July 18, 2024

Yeah. This way works. It veery inconvenient in my case, but much better than nothing :)

Thank you!

from golang-asm.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.