- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 MIPS (QtSpim) 将 32 位字从 Big Endian 转换为 Little Endian。我在下面显示的内容经过检查且正确无误。但是,我想知道还有哪些其他方式可以让我进行转换。我虽然只是通过使用旋转和移位,但我没有设法做到没有逻辑运算。
所以我的问题是,它可以在没有逻辑运算的情况下完成吗?
li $t0,0x12345678 # number to be converted supposed to be in $t0
rol $t1,$t0,8
li $t2,0x00FF00FF # $t2 contains mask 0x00FF00FF
and $t3,$t1,$t2 # byte 0 and 2 valid
ror $t1,$t0,8
not $t2,$t2 # $t2 contains mask 0xFF00FF00
and $t1,$t1,$t2 # byte 1 and 3 valid
or $t3,$t3,$t1 # little endian-number in $t3
最佳答案
这是一个不使用逻辑运算符的解决方案。然而,这只是一个黑客:
li $t0,0x12345678 # number to be converted supposed to be in $t0
swl $t0, scratch+3
lwl $t1, scratch # Load MSB in LSB
lwr $t1, scratch+3 # Load LSB in MSB
swl $t0, scratch+2
lwr $t2, scratch # Swap second and
lwl $t2, scratch+1 # third bytes
sw $zero, scratch
lwl $t2, scratch # Leave MSB and LSB in zero
lwr $t2, scratch+3
addu $t3, $t1, $t2 # Add partial results to get final result
.data 0x2000 # Where to locate scratch space (4 bytes)
scratch:
.space 4
$t0
,部分结果在
$t1
和
$t2
中,最终结果在
$t3
中。它还使用 4 个字节的内存(位于
scratch
)
关于assembly - Big Endian 到 Little Endian 使用 MIPS 没有逻辑运算?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11158409/
我的老师说你可以像这样简单地将一个字符加载到寄存器中: li $s2 "A" li $s1 "0" 除了,当我将我的文件加载到 Qtspim 中时,它一直向我抛出一个语法错误。有谁知道我的老师是否对我
我正在使用二进制 MIPS 指令,我发现 this helpful document .但是,我需要澄清一下:所有分支指令都具有立即值。这是立即值符号扩展吗? 大多数其他立即数是,如果不是,那将意味着
我有一个寄存器($t2),它有一个随机生成的数字,然后我乘以 4。我的问题是,在使用 lw 指令时,是否可以将 $t2 中的值用作偏移量? 最佳答案 在 MIPS 中,您可以使用寄存器、偏移量或两者的
因此,我正在MIPS中构建一个计算器程序,并且试图编写乘法和除法函数。 目前,我像这样在循环中读取整数: li $v0, 5 syscall 然后根据用户要执行的操作最终调用我的函数multi和div
我们目前正在讨论 MIPS 架构。我逐渐了解了计算机体系结构和 MIPS 汇编,这很好。 但是,我尝试用谷歌搜索这个答案,但没有找到合适的答案。我对 ISA 和微架构设计下面的一层感到困惑。 MIPS
我正在研究分支延迟槽。在 spim 上尝试过。 j some j a j b j c j d ori $9, $0, 13 some: a: b: c: d: 令我惊讶的是,它将 9 美元更改
好吧,这个问题更像是一个讨论。我有一个在 VHDL 中实现 pipelined MIPS 处理器的项目。 我完全熟悉流水线的概念,但我从未用 VHDL 实现它。在VHDL 中学习流水线处理器 的实现有
关于带有流水线和转发的 MIPS 架构: add $s0, $t1, $t2 sw $s0, 0($sp) add 指令将在第 3 步(执行操作)准备好结果,但我假设 sw 指令需要第 2 步(指令解
我刚开始学习 MIPS 指令的异常处理程序。 我需要让我的程序有算术溢出异常,以便我可以测试我的异常处理程序。 我有两个数组 A 和 B。数组 A 有十六进制数,数组 B 有整数。 如何通过添加十六进
我正在学习微编程,但对微指令到底是什么感到困惑。我正在使用 MIPS 架构。我的问题如下 例如,我有 ADD 指令,微指令会是什么样子? add指令有多少条微指令。在网上有什么地方可以看到 MIPS
我需要多少档才能正确执行以下指令。我对我所做的事情有点困惑,所以我在这里看到专家的答案。 lw $1,0($2); beq $1,$2,Label; 请注意,检查是否会发生分支将在解码阶段完成。但是源
.data stack: .word 3, 2 .text .globl main main: la $s1, stack #assign stack start
我正在用 MIPS 编写一个回文检查器,我试图让它不区分重音,这样像“ahà”这样的东西也会被认为是一个回文。然而,它看起来并不像小写和大写字母之间有固定值的不区分大小写的场景那么简单。 我问过我的老
我正在尝试向以下内容添加 jal 功能,但我对它的工作原理感到困惑。我知道它将旧的 PC+4 值存储在 $ra 寄存器中,然后将控制权转移到函数,该函数通过 return $ra 传回控制权 但是如何
我正在学习如何执行 MIPS,但我对乘法感到困惑。假设我正在将以下 C 代码转换为 MIPS。 c = b + a*3 a,b,c分别存放在寄存器$s1,$s2,$s3中。我应该如何在 MIPS 中编
我正在为明天的考试而学习,并且我对加载/存储字节主题感到困惑。我有这个例子: 我完全不明白他是怎么得到红色答案的。有人可以帮我解释一下吗? 最佳答案 add $s3, $zero, $zero
我不明白如何翻译标签。任何人都可以给我一个帮助 假设我们有以下代码: loop: add $t2,$t2,$t1 addi $t2,$t2,4 sw $t2,4($s0)
当我阅读 MIPS 架构时,我遇到了影子寄存器,据说它们是通用寄存器的副本。 我无法理解以下内容:何时使用影子寄存器? 最佳答案 MIPS 影子寄存器用于减少处理中断时的寄存器加载/存储开销。分配了影
您好,我想让 hello world 输出用户输入的次数,比如如果他们写了 3 ,那么 hello world 将被打印 3 次。我该怎么做呢?这是我目前正在使用的: .data n:
我正在使用 MARS MIPS 模拟器,我想在我的程序中打印一个换行符。 .data space: .asciiz "\n" .text addi $v0, $zero, 4 # print
我是一名优秀的程序员,十分优秀!