- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我一直在帮助实验室进行 ARM7 汇编语言类(class),今天遇到一个问题,学生输入了以下表达式:
MUL R0, R0, R1
代码未编译。解决方案是将表达式更改为:
MUL R0, R1, R0
即MUL 的前两个参数不能是同一个寄存器。我已经知道这一点,因为它是 ARM 文档的一部分: http://infocenter.arm.com/help/topic/com.arm.doc.dui0489i/DUI0489I_arm_assembler_reference.pdf
学生很高兴他们的问题得到了解决,但我很沮丧,因为我不知道为什么 ARM7 要求这样传递参数。我认为这可能与乘法器移位和加法时用于存储中间值的寄存器之一有关,但我什至不确定乘法在 ARM 上是否是这样工作的(事实上,我相当清楚)当然不是)。为什么参数的顺序在这里如此重要?
最佳答案
“在 ARMv6 之前的架构中,Rn 必须与 Rd 不同”这一事实表明,这是原始三级 ARM 流水线中如何实现乘法的设计限制。 ARMv6 之前是指采用 ARM7 或更早设计的 CPU,这些 CPU 都使用简单的三级管道。与大多数指令不同,乘法需要多个周期来执行,并且根据指令集限制,您的怀疑似乎是正确的,目标寄存器Rd在每个周期都会被修改以计算结果。
论文Verifying ARM6 Multiplication by Anthony Fox ,通过图 4(下面重新格式化以适应 Stack Exchange 标记的限制)显示了在 ARM6 内核执行乘法指令期间如何修改 Rd 来支持这一点:
t3
- Fetch an instruction
- Increment the program counter
- Set
mul1
toreg[Rs]
- Set
borrow
to falseSet
count1
to zeroSet
reg[Rd]
toreg[Rn]
if accumulate, otherwise zero- Set
mul
tomul1[1:0]
- Set
mul2
tomul1[31:2]
- Set
borrow2
toborrow
- Set
mshift
toMSHIFT2(borrow,mul,count1)
tn
- Set
alub
toreg[Rm]
shifted left bymshift
- Set
alua
toreg[Rd]
- Set
mul1
tomul2[29:0]
- Set
borrow
tomul[1]
Set
count1
tomshift[4:1] + 1
Set
reg[Rd]
toALU6<sup>*</sup>(borrow2,mul,alua,alub)
- Set
mul
tomul1[1:0]
- Set
mul2
tomul1[31:2]
- Set
borrow2
toborrow
- Set
mshift
toMSHIFT2(borrow,mul,count1)
- Update
NZC
flags ofCPSR
(ifS
flag set)- If the last iteration then decode the next instruction
Fig. 4: ARM6 implementation of the multiply instructions. Each cycle is split into two phases. The tn cycle is repeated until
MULX(mul2,borrow,mshift)
is true. RegisterRd
is not updated whenRd
is equal toRm
or fifteen.
自 reg[Rd]
在初始设置周期 t3 和重复 tn 周期期间进行修改,结果将是垃圾如果 Rd == Rm
因为步骤“将 alua
设置为 reg[Rm]
左移 mshift
”期望读取 Rm 的原始未修改值,而不是存储在 Rd 中的当前中间值>.
某些 ARM7 CPU 有一个“快速乘法器”,每个周期处理 8 位,而不是如上所述的每个周期处理 2 位,但它似乎也会在计算过程中修改寄存器。
关于assembly - 为什么 ARM7 上 MUL 表达式的前两个参数不能相同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33046876/
MUL CL CL 是 BYTE 大小,它等于 AX = AL * CL MUL BX BX 是 WORD 大小,它等于 DX:AX = AX * BX MUL EBX EBX 是 DWORD 大小,
我正在尝试学习 Tensor Flow,因此我遵循了 https://pythonprogramming.net/tensorflow-neural-network-session-machine-l
我的代码中有错误,我已经阅读了文档,但仍然错误,维度必须相等是什么意思?但实际上我已经在代码中添加了一些层 model.fit() 这是我的代码: # USAGE # python train_sim
假设我已经在汇编机中实现了所有ADD、AND、SHF、JUMP、BR、LDW、LDB(加载字加载字节...)......除了MUL(多个)指令。现在我想编写汇编代码来操作MUL指令,该指令接收存储在0
我正在为 ARMv7 处理器编写指令。我想知道为什么我不允许在 MUL 指令本身中有一个常量值?您可以使用 ADD 和 SUB 指令,为什么不使用 MUL? 干杯 最佳答案 如果您查看 instruc
我已经实现了Point3D结构: use std::ops; #[derive(Debug, PartialEq)] pub struct Point3D { pub x: f32,
这就是问题所在:在第二个 mul 时,溢出标志被设置为 1;乘法是一个简单的 120*(-6) = -720,它包含在 16 位中......我不明白为什么。 .model small
我有以下 assembly 线: ... MOV ECX, 0x36EE80 MOV EDX, 0x95217CB1 MUL EDX SHR EDX, 0x15 MOV DWORD PTR SS:[E
我正在使用一个 MySQL 查询,该查询对四个表执行三个表连接。其中两个连接位于一对 MUL key 上。第三个连接是在一对主键上。查询需要一整分钟才能获取 100 行。 我相信两对 MUL key
全部, 假设我有以下 mysql 表testtable: +----------+------------------------------+------+-----+---------+-----
我有一个现有的表,我通过一个脚本过夜填充该表,该脚本读取二进制格式文件并将其转换为通过管道传输到 mysql 的一系列 replace 语句。该脚本存在错误,并且对每个二进制文件循环两次,因此每个 r
我正在用 Rust 创建一个简单的矩阵结构,我正在尝试实现一些基本的运算符方法: use std::ops::Mul; struct Matrix { cols: i32, rows:
这个问题在这里已经有了答案: Automatically implement traits of enclosed type for Rust newtypes (tuple structs wit
这个问题在这里已经有了答案: x86 Multiplication with 3: IMUL vs SHL + ADD (1 个回答) 关闭 1 年前。 让我们考虑以下函数: #include u
我有一个时间索引的 DataFrame,其中只有一部分数据是有效的(出于某些“外部”原因)。 我已经为有效数据制作了一个时间索引的Series 1 和数据无效的 NaN,所以我可以使用这是我的 Dat
数据 1 import pandas as pd #data 01 df_products = pd.DataFrame([{'Product ID' : 4109,'Price' : 5.0,'Pr
我有这段代码,它使用了 PBC 库: element_t pk, pk_temp; element_init_G2(pk, pairing); element_init_G2(pk_temp, pai
我正在尝试对附加了单位的求解评估的输出进行舍入。 例如: solve(Eq(x, 22/7 * seconds), x)[0] 输出: 3.14285714285714*s 有没有办法在保留 s 的同
HLSL 的 mul( x, y) 的参数表示 here : 这么说 如果 x 是 vector ,则将其视为行 vector 。 如果 y 是 vector ,则将其视为列 vector 。 这是否
// main.rs #[derive(Clone, Copy)] struct A(f64, f64); impl Mul for A where f64: From, T: Cop
我是一名优秀的程序员,十分优秀!