Golang:有哪些汇编指令可用?

huangapple go评论167阅读模式
英文:

golang: what assembly instructions are available

问题

我有一个在ARM上运行的程序,我正在用汇编语言编写其中的一个函数。我在这方面取得了很好的进展,尽管有时候我发现很难弄清楚如何编写某些go汇编指令,例如,我没有预料到右移会被写成这样:

MOVW R3>>8, R3

现在我想要进行乘法累加(MLA),根据这份文档,不是所有的操作码都被支持,所以也许MLA不被支持,但我不知道如何判断是否支持。我在golang仓库中看到了关于ARM的MLA的提及,但我不太确定我在那里看到的东西的含义。

有没有地方记录了支持的指令以及如何编写它们?有人能给我一些有用的指引吗?

英文:

I've got a program that I'm running on an ARM and I'm writing one function of it in assembly. I've made good progress on this, although I've found it difficult sometimes to figure out exactly how to write certain instructions for go's assembler, for example, I didn't expect a right shift to be written like this:

MOVW R3>>8, R3

Now I want to do a multiply and accumulate (MLA), according to this doc not all opcodes are supported, so maybe MLA isn't, but I don't know how to tell if it is or not. I see mentions of MLA with regards to ARM in the golang repo, but I'm not really sure what to make of what I see there.

Is there anywhere that documents what instructions are supported and how to write them? Can anyone give me any useful pointers?

答案1

得分: 4

这是我写的一份关于如何编写ARM汇编的简略文档。

我从一个有经验的ARM人员试图弄清楚Go汇编器的工作原理的角度来编写它。

以下是开头的一部分摘录。如果你有更多问题,请随时给我发邮件!


Go汇编器基于Plan 9汇编器,其文档在这里有记录。

http://plan9.bell-labs.com/sys/doc/asm.html

关于ARM的简介

http://www.davespace.co.uk/arm/introduction-to-arm/index.html

操作码

http://simplemachines.it/doc/arm_inst.pdf

指令

  • 目标在最后而不是最前
  • 参数似乎完全颠倒了
  • 可以缩减为2个操作数,所以
    • ADD r0, r0, r1 ; [ARM] r0 <- r0 + r1
    • 被写成
    • ADD r1, r0, r0
    • 或者
    • ADD r1, r0
  • 常量用'$'表示,而不是'#'
英文:

Here is a bit of a scrappy doc i wrote on how to write ARM assembler

I wrote it from the point of view of an experienced ARM person trying to figure out how Go assembler works.

Here is an excerpt from the start. Feel free to email me if you have more questions!


The Go assembler is based on the plan 9 assembler which is documented here.

http://plan9.bell-labs.com/sys/doc/asm.html

Nice introduction to ARM

http://www.davespace.co.uk/arm/introduction-to-arm/index.html

Opcodes

http://simplemachines.it/doc/arm_inst.pdf

Instructions

  • Destination goes last not first
  • Parameters seem to be completely reversed
  • May be condensed to 2 operands, so
    • ADD r0, r0, r1 ; [ARM] r0 <- r0 + r1
    • is written as
    • ADD r1, r0, r0
    • or
    • ADD r1, r0
  • Constants denoted with '$' not '#'

huangapple
  • 本文由 发表于 2014年9月24日 01:54:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/26001623.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定