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

Question: #1

Open
meritos opened this issue Aug 21, 2017 · 2 comments
Open

Question: #1

meritos opened this issue Aug 21, 2017 · 2 comments

Comments

@meritos
Copy link

meritos commented Aug 21, 2017

Hi Michael,

Watched your presentation about assembly usage,
and dived into trying this stuff, most of it works
for me, but I have some problem:

I want to move SB - Static Base pointer
like this

MOVQ SB R1

but I get: illegal use of pseudo-register.... The same I have
with FP and PC and only SP "moves" well Now I know
I can access the data by var1+0(SB) but I want the actuall
address for further analysis.

Can you help here?

Thanks.

@mundaym
Copy link
Owner

mundaym commented Aug 21, 2017

Hi @meritos,

SB isn't a real register and doesn't have a value (in Go assembly). Rather it is used to as a symbol to represent the base address for global variables. On amd64 (and I think most of the other architectures at this point) global variables will actually be accessed using relative addressing.

In general the pseudo (fake) registers (SB, FP, PC and in some circumstances SP) are used by the assembler to calculate addresses/offsets. There isn't any code in the assembler to materialize any of them directly except SP (a real register), which is why your moves fail. They are only usable in specific situations (with a variable for SB, an offset and a variable for FP, and with an instruction offset for PC).

Hope that helps.

@meritos
Copy link
Author

meritos commented Aug 21, 2017

Thanks, but anything I can do to fetch those values? Maybe any real regs that double them?
some REX or similar?

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