golang source code plan9 asm

1.2k Views Asked by At

When I read the source code from golang src,then I can not understand the asm code,such as:

// void gogo(Gobuf*)
// restore state from Gobuf; longjmp
TEXT runtime·gogo(SB), NOSPLIT, $0-8
MOVQ 8(SP), BX // gobuf
MOVQ gobuf_g(BX), DX
MOVQ 0(DX), CX // make sure g != nil
get_tls(CX)
MOVQ DX, g(CX)
MOVQ gobuf_sp(BX), SP // 从 G.sched.sp 恢复 SP 寄存器
MOVQ gobuf_ret(BX), AX
MOVQ gobuf_ctxt(BX), DX
MOVQ $0, gobuf_sp(BX) // clear to help garbage collector
MOVQ $0, gobuf_ret(BX)
MOVQ $0, gobuf_ctxt(BX)
MOVQ gobuf_pc(BX), BX // 将 G.sched.pc,也就是 goroutine 函数地址压⼊入 BX。
JMP BX

I have no idea about the define the function name why with(SB), NOSPLIT, $0-8 etc. and what does this line "MOVQ 8(SP), BX" means.

0

There are 0 best solutions below