Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plan9汇编里面的Scale是什么 #12

Open
jingyugao opened this issue Nov 18, 2019 · 2 comments
Open

plan9汇编里面的Scale是什么 #12

jingyugao opened this issue Nov 18, 2019 · 2 comments

Comments

@jingyugao
Copy link

https://github.com/cch123/golang-notes/blob/master/assembly.md#%E5%9C%B0%E5%9D%80%E8%BF%90%E7%AE%97
这个地方不是很明白。另外,movq也有Scale的概念吗,比如下面的代码。

#define	g(r)	0(r)(TLS*1)
get_tls(CX)
MOVQ	g(CX), AX

展开后是 movq 0(CX)(TLS*1),AX
这是什么鬼?

@cch123
Copy link
Owner

cch123 commented Dec 31, 2019

sorry,之前没 watch 这个仓库,问题都没看到哈

scale 其实就是个乘数,go 的编译器在编译这段的时候有个判断:

// parseScale converts a decimal string into a valid scale factor.
func (p *Parser) parseScale(s string) int8 {
	switch s {
	case "1", "2", "4", "8":
		return int8(s[0] - '0')
	}
	p.errorf("bad scale: %s", s)
	return 0
}

这个 scale 是判断寄存器表达式里面有 * 号的时候,才会去看 scale 对不对

@cch123
Copy link
Owner

cch123 commented Dec 31, 2019

至于第二个问题,应该是和线程本地存储的 TLS 机制相关,这个我没细研究哈哈
这两行是参考 runtime 里的代码来的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants