- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图将一个整数存储到 $s0
中,这是在一个循环标签中。
但问题是我将打印一个整数并将其保存在 $s0
中。
我做了以下事情
sw $t7,0($s0)
addi $s0,$s0,4
我认为下面的代码允许我将每个整数存储在 $s0
中的一个槽中,但是如果我 lw
,我只会得到打印的最后一个整数
下面的代码:以粗体显示,我试图存储一个单词,但就像你说的那样,它会覆盖这是一道作业题,所以我很想学习,请指点一下,下次我就知道了
.data
n1: .asciiz "\n" #ASCII for a new line
.align 2
name: .asciiz "Fibonacci\n\n\n" #Lab Title and Student Name
.align 2
msg1: .asciiz "Fibonacci result " #note the space
.align 2
msg2: .asciiz " is " #note the space
.align 2
**array: .space 20 #define the array**
.text #
.globl main #declare main to be global
main:
la $a0,name #load the ram address of "name" into $a0
li $v0,4 #system call, type 4, print a string, $a0
syscall #call the "OS" to perform operation
li $t2,0 # $t2 :=0; initial value of F(n-2)
li $t1,1 # $t1 :=1; initial value of F(n-1)
li $t4,0 #index, n.
#loop is a local Variable
li $t5,11 #loading immediate preset value for $t5
**la $t7,array #load address (array) into $t7**
loop: addu $t0,$t1,$t2 # F(n) = F(n-1) + F(n-2)
**#Only print the last 5 numbers**
sub $t3,$t5,$t4
li $t6,5
bgt $t3,$t6,Printl
la $a0,msg1 # $a0 := address of message 1
li $v0,4 #system call, type 4, print a string
syscall #call the "OS"
move $a0,$t4 # $t4 contains the current value of n
li $v0,1 #system call, type 1, print an integer $a0
syscall #call the "OS"
la $a0,msg2 # $a0:=address of "msg2"
li $v0,4 #system call, type 4, print a string
syscall #call the "OS"
move $a0,$t0 # $a0 :=$t0, which is F(n)
li $v0,1 #system call, type 1, print an integer $a0
syscall #call the "OS"
**sw $s0, 4($t7)**
la $a0,n1 # $a0 := address of "n1"
li $v0,4 #system call, type 4, print a string
syscall #call the "OS"
addi $t4,1 # $t4 := $t4 + 1; increment n
move $t2,$t1 # $t2 := $t1; old F(n-2) because old F(n-1)
move $t1,$t0 # $t1 := $t0; old F(n-2) because old F(n)
beq $t5,$t4,Exit #Conditional Check | exit
j loop # branch unconditionally to loop ($t3 != 0)
Exit:
la $a0,n1 # $a0 := address of message 1
li $v0,4 #system call, type 4, print a string
syscall #call the "OS"
#la $t7,array
#li $v0,1
#sw $s0, 4($t7)
#syscall
li $v0,10 #system call, type 10, standard exit
syscall #call the "OS"
Printl:
addi $t4,1
move $t2,$t1
move$t1,$t0
j loop
最佳答案
不确定你是否还在这里。 :) 但如果你是,并且在两个学期后你仍然偶然参加 MIPS,那么这里可能会有帮助。
您已经注意到 sw $s0, 4($t7)
将把$s0 的内容写入$t7 + 4 指向的地址。由于 $t7 的值永远不会改变,您将不断地将 $s0 的内容反复写入同一地址。
如果要将$s0的内容存储到以array
开始的连续单词中,您将需要初始化指针,用它做您想做的事,然后递增它。
la $t7,array
loop:
# do something to set $s0
sw $s0, 0($t7)
# do something to break out of loop if condition is met
addi $t7, 4
j loop
不要忘记您已经定义了 array
20 字节 - 这只是 5 个单词。
关于assembly - MIPS 存储字 (sw),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12500405/
我正在维护一些 Java 代码,我目前正在将它们转换为 C#。 Java 代码是这样做的: sendString(somedata + '\000'); 在 C# 中,我正在尝试做同样的事情: sen
如何确定函数中传递的参数是字符串还是字符(不确定如何正确调用它)文字? 我的函数(不正确): void check(const char* str) { // some code here }
我真的不知道如何准确地提出这个问题,但我希望标题已经说明了这一点。 我正在寻找一种方法(一个框架/库),它提供了执行 String.contains() 函数的能力,该函数告诉我给定的字符串是否与搜索
我正在尝试编写一些读取 Lambda 表达式并输出 beta 缩减版本的东西。 Lambda 的类型如下:\variable -> expression,应用程序的形式为 (表达式) (表达式)。因此
StackOverflow 上的第 1 篇文章,如果我没能把它做好,我深表歉意。我陷入了一个愚蠢的练习,我需要制作一个“刽子手游戏”,我尝试从“.txt”文件中读取单词,然后我得到了我的加密函数,它将
我想在 Groovy 中测试我的 Java 自定义注释,但由于字符问题而未能成功。 Groovyc: Expected 'a' to be an inline constant of type cha
当我尝试在单击按钮期间运行 javascript location.href 时,出现以下错误“字 rune 字中的字符过多”。 最佳答案 这应该使用 OnClientClick相反? 您可能还想停
我想要类似的东西: let a = ["v".utf8[0], 1, 2] 我想到的最接近的是: let a = [0x76, 1, 2] 和 "v".data(using: String.Encod
有没有办法在 MySQL 中指定 Unicode 字 rune 字? 我想用 Ascii 字符替换 Unicode 字符,如下所示: Update MyTbl Set MyFld = Replace(
阅读 PNG 规范后,我有点惊讶。我读过字 rune 字应该用像 0x41 这样的二进制值进行硬编码,而不是在(程序员友好的)'A' 中。问题似乎是在具有不同底层字符集的不同系统上编译期间字 rune
考虑一个具有 UTF-8 执行字符集的 C++11 编译器(并且符合要求 char 类型为有符号 8 位字节的 x86-64 ABI) . 字母 Ä(元音变音)具有 0xC4 的 unicode 代码
为什么即使有 UTF-8 字符串文字,C11 或 C++11 中也没有 UTF-8 字 rune 字?我知道,一般来说,字 rune 字表示单个 ASCII 字符,它与单字节 UTF-8 代码点相同,
我怎样才能用 Jade 做到这一点? how would I do this 我几乎可以做任何事情,除了引入一个 span 中间句子。 最佳答案 h3.blur. how would I do t
这似乎是一个非常简单的问题,但我只是想澄清我的疑问。我正在查看其他开发人员编写的代码。有一些涉及 float 的计算。 示例:Float fNotAvlbl = new Float(-99); 他为什
我想知道第 3 行“if dec:”中的“dec”是什么意思 1 def dec2bin(dec): 2 result='' 3 if dec:
我试图在字符串中查找不包含任何“a”字符的单词。我写了下面的代码,但它不起作用。我怎么能对正则表达式说“不包括”?我不能用“^”符号表示“不是”吗? import re string2 = "asfd
这个问题在这里已经有了答案: Is floating point math broken? (31 个答案) Is floating point arbitrary precision availa
我正在创建一个时尚的文本应用程序,但在某些地方出现错误(“字 rune 字中的字符太多”)。我只写了一个字母,但是当我粘贴它时,它会转换成许多这样的字母:“\uD83C\uDD89”,原始字母是“🆉
我正在尝试检查用户是否在文本框中输入了一个数字值,是否接受了小数位。非常感谢任何帮助。 Private Sub textbox1_AfterUpdate() If IsNumeric(textbox1
我知道一个 Byte 是 8 位,但其他的代表什么?我正在参加一个使用摩托罗拉 68k 架构的汇编类(class),我对目前的词汇感到困惑。 最佳答案 如 operator's manual for
我是一名优秀的程序员,十分优秀!