You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package mytest
type T int32
func (a T) MyTest(b T) (T, T)
func (p *T) MyTestp(b T) (T, T)
func MyTest(a, b T) (T, T)
func MyTestp(p *T, b T) (T, T)
The corresponding assembly code(generaged by go tool objdump), as follows:
TEXT ·MyTest(SB), $0-16
MOVL a + 0x0(FP), AX
MOVL b + 0x4(FP), BX
MOVL BX, CX
ADDL AX, CX
MOVL CX, r1 + 0x8(FP)
SUBL BX, AX
MOVL AX, r2 + 0xc(FP)
RET
TEXT ·MyTestp(SB), $0-24
MOVQ p + 0x0(FP), CX
MOVL b + 0x8(FP), BX
MOVL (CX), AX
MOVL BX, CX
ADDL AX, CX
MOVL CX, r1 + 0x10(FP)
SUBL BX, AX
MOVL AX, r2 + 0x14(FP)
RET
TEXT ·T·MyTest(SB), $0-16
MOVL a + 0x0(FP), AX
MOVL b + 0x4(FP), BX
MOVL BX, CX
ADDL AX, CX
MOVL CX, r1 + 0x8(FP)
SUBL BX, AX
MOVL AX, r2 + 0xc(FP)
RET
TEXT ·(*T)·MyTestp(SB), $0-24
MOVQ p + 0x0(FP), CX
MOVL b + 0x8(FP), BX
MOVL (CX), AX
MOVL BX, CX
ADDL AX, CX
MOVL CX, r1 + 0xC(FP)
SUBL BX, AX
MOVL AX, r2 + 0x10(FP)
RET
when I compile these assembly code, all is ok except "TEXT
·(*T)·MyTestp(SB), $0-24", error message as follows:
expected identifier, found *
I think objdump using a readable denotion (*T) for output, but for
complier, it is wrong. so do any one know the correct denotion? Thanks in
advance!
The text was updated successfully, but these errors were encountered:
robpike
changed the title
underline implement of golang method using golang assembly language
cmd/objdump: output is not valid assembly input
Aug 30, 2017
It is not a guarantee that objdump output or even compiler output is valid assembly. Even if that assembly were accepted the result would not be a working Go program because it would be missing all the type and method tables.
I wrote a simple go package as follows:
The corresponding assembly code(generaged by go tool objdump), as follows:
when I compile these assembly code, all is ok except "TEXT
·(*T)·MyTestp(SB), $0-24", error message as follows:
I think objdump using a readable denotion (*T) for output, but for
complier, it is wrong. so do any one know the correct denotion? Thanks in
advance!
The text was updated successfully, but these errors were encountered: