ARM 内联汇编中的指令 mrc p15 有什么作用? [英] What does the instruction mrc p15 do in ARM inline assembly?

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

问题描述

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.

一点一点地接受你的指导:

Taking your instruction a bit at a time:

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

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

MRC{cond} P15, <Opcode_1>, <Rd>, <CRn>, <CRm>, <Opcode_2>

在第 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 概述,请参阅 this- 这可能类似于 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)

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆