内联汇编中有什么作用

内联汇编中有什么作用

本文介绍了mrc p15 指令在 ARM 内联汇编中有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ARM 汇编中的这一行是做什么的?

What does this line in ARM assembly do?

mrc p15, 0, %0, c9, c13, 0" : : "r" (counter)

什么是p15?通常寄存器以 r 为前缀,例如 r15.

What is p15? Usually registers are prefixed with r such as in r15.

:: 的符号是什么,作用是什么或c9,c1?

What is the symbol :: and what are the roles or c9, c1?

推荐答案

虽然 MRC 是通用协处理器互操作指令,cp15控制处理器 - 所有现代 ARM CPU 都有,ARM 已经使用它来扩展片上单元的指令集,例如缓存、MMU、性能监控等.

Whilst MRC is a generic co-processor inter-op instruction, cp15 is the control processor - which all modern ARM CPUs have and this has been used by ARM was a means of extending the instruction set for on-chip units such as the cache, MMU, performance monitoring and lots else besides.

一次接受你的指示:

mrc p15, 0, %0, c9, c13, 0" : : "r" (计数器)

根据 ARM Cortex A7 MPCore 参考 指令格式为:

MRC{cond} P15、、、、、

在第 4-11 页,这被描述为将 CPU 寄存器传输到性能监视器计数寄存器(我猜 count=0,这是性能计数器的重置).

And on Page 4-11 this is described as a transfer of a CPU register to the performance monitor count register (I guess count=0 and this is a reset of the performance counter).

至于内联汇编器的语法.有关 x86 概述,请参阅- 这可能类似于 ARM.

As for the syntax of inline assembler. refer to this for a x86 overview - which is probably similar to ARM.

: : "r" (counter) 表示指令有:

  • 需要以局部变量结尾的寄存器中没有输出
  • 从变量counter中获取输入,它所在的寄存器应该用作%0.
  • 没有编译器应该注意的副作用(clobbers)
  • No output in a register that needs to end up in a local variable
  • Takes input from variable counter, and the register this is in should be used as %0.
  • There are no side effects the compiler ought to be aware of (clobbers)

这篇关于mrc p15 指令在 ARM 内联汇编中有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 19:27