Comments (1)
package main
//go:noinline
func add(a, b int32) (int32, bool) { return a + b, true }
func main() { add(10, 32) }
版本:go1.16.15 amd64
go1.16.15 tool compile -S -N -l main.go
后,add的Go汇编:
"".add STEXT nosplit size=31 args=0x10 locals=0x0 funcid=0x0
0x0000 00000 (main.go:4) TEXT "".add(SB), NOSPLIT|ABIInternal, $0-16
0x0000 00000 (main.go:4) FUNCDATA $0, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
0x0000 00000 (main.go:4) FUNCDATA $1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
0x0000 00000 (main.go:4) MOVL $0, "".~r2+16(SP)
0x0008 00008 (main.go:4) MOVB $0, "".~r3+20(SP)
0x000d 00013 (main.go:4) MOVL "".a+8(SP), AX
0x0011 00017 (main.go:4) ADDL "".b+12(SP), AX
0x0015 00021 (main.go:4) MOVL AX, "".~r2+16(SP)
0x0019 00025 (main.go:4) MOVB $1, "".~r3+20(SP)
0x001e 00030 (main.go:4) RET
[pseudo SP + 8]
定位到实参a
,[pseudo SP + 12]
定位到实参b
,所以pseudo SP
的值应该是parent return address
的起始位置?
from advanced-go-programming-book.
Related Issues (20)
- 这一章节有错误: 1.5.6 基于Channel的通信 HOT 4
- 6.5 负载均衡 HOT 1
- 能不能换下封面页的图片 HOT 1
- 1.6 常见的并发模式中改进的素数筛实现有错误 HOT 1
- 1.4开头对init函数中启动新goroutine的描述有错误 HOT 1
- 2.7.2 C临时访问传入的Go内存
- 1.4.1 函数 闭包传值问题 HOT 1
- golang1.18版本的形参使用的寄存器传参? 和汇编章节使用栈的不太一样 HOT 2
- 关于附录A中的"独占CPU导致其它Goroutine饿死"
- 3.5.3 for 循环 的算法有问题 HOT 2
- 转为 mdbook 格式,gitbook 可以退了 HOT 3
- 第 3 章 3.6.1 节 的 “图 3-13 函数调用参数布局” 有点小问题 HOT 1
- getg build error: relocation target runtime.convT2E not defined HOT 2
- When run examples/ch2.1/hello-03/main.go , an error occurred
- 关于 “1.5.3 顺序一致性内存模型”中的疑问 HOT 3
- 2.7.4 针对Go指针检查的原理描述错误 HOT 1
- 4.1.2 更安全的 RPC 接口
- github.com/golang/protobuf/protoc-gen-go/generator已经被废弃
- 2.11 笔误
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 advanced-go-programming-book.