3 ms·
> WORD $0x4cdf2025 // ld1 {v5.16b-v8.16b}, [x1], #64 Why is the code written as words like this instead of just the assembly instructions?
by serge2k 10y ago
> WORD $0x4cdf2025 // ld1 {v5.16b-v8.16b}, [x1], #64
Why is the code written as words like this instead of just the assembly instructions?
- nickcw 10y agoBecause the Go assembler doesn't have those instructions built in most likely. That sort of thing is quite common in Go assembler. The assemblers are a little primitive and they force the assembly language for each processor into a common pattern, so when you are writing ARM assembler for instance, everything is backwards. I imagine having rationalised the assemblers between processors somewhat it makes the core developers lives easier though who have to lightly touch lots of different processor assembler.
- pjmlp 10y agoBackwards from AT&T point of view, right? Because for me it feels very natural, given the Z80 and Intel Assembly.
- fwessels 10y agoThe Golang assembly does not support all instructions, we've created a tool (see https://github.com/minio/asm2plan9s https://github.com/minio/asm2plan9s) to assist in translating instructions into their opcode equivalents.
- chewxy 10y agoDamn. That's neat. I wrote my own python script to translate whatever `as` spits out into BYTE $.... your tool'd have been neat when I wrote this http://blog.chewxy.com/2016/07/25/on-the-memory-alignment-of-go-slice-values/ http://blog.chewxy.com/2016/07/25/on-the-memory-alignment-of...
- fwessels 10y agoNice blog, and the tool would have helped indeed. And also, memory allocation is not the most obvious topic in Go/Golang assembly...