In Go assembly on arm64, I have created a table of values
DATA table<>+0(SB)/4, 0x00000001
DATA table<>+4(SB)/4, 0x00000002
DATA table<>+8(SB)/4, 0x00000003
DATA table<>+12(SB)/4, 0x00000004
But what I want to be able to do is load up a value into a register from this table, but based on a variable.
If I had a constant I could do
MOVD table<>+4(SB), R1
so R1=0x00000002
but how can I do it with a variable? Something like...
MOVD $4, R0
MOVD table<>+R0(SB), R1
Or better yet, can I get the address and load a vector directly?
I guess the answer in normal are is ADR, but when I try that in go
ADR table<>(SB), R0
I just get
asm: illegal combination: 00280 [...] ADR table<>(SB), R9 ADDR NONE NONE REG, 3 7
Which is maybe the least useful error message I've ever seen.
Okay, so ADR works if I do PC relative addressing, but that's obviously not right.
question from:
https://stackoverflow.com/questions/65838452/how-do-i-lookup-a-value-in-a-table 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…