spim

Getting result from mult in mips

心不动则不痛 提交于 2019-12-10 19:23:21
问题 I am new to assembly language, and I am really confused over multiplying. I was reading the quick tutorial here:http://logos.cs.uic.edu/366/notes/mips%20quick%20tutorial.htm It says after I use mult $t0, $t1 the results are stored in Hi and Lo, I understand these are special registers for mult and div , but how do I access them? Lets say I do mult $t0, $t1 where $t0 and $t1 are both 2. How do I get the result? (4) 回答1: You have to use MFHI and MFLO to move data from HI and LO to general

Reading an integer into a local variable in MIPS

做~自己de王妃 提交于 2019-12-09 10:58:15
问题 How can I read an integer into a local variable in MIPS ? Is it possible? The problem asks me to use the concept of assigning integer variables as local variables. #A question from my text book. And by the way , not a homework! Thanx in advance! :D 回答1: li $v0, 5 syscall move $t0, $v0 The value is now in $t0. This will read the integer from the console. 来源: https://stackoverflow.com/questions/6900762/reading-an-integer-into-a-local-variable-in-mips

MIPS: Size of .asciiz?

一笑奈何 提交于 2019-12-07 12:30:54
问题 When determining the size of .asciiz string, should I take into consideration the terminating character ? For example: .data string: .asciiz "Hello" The size of "string" is 5 or 6 (byte) ? Thank you in advance. 回答1: if you are asking about how many bytes in memory the string is stored in then it's 6 bytes if you are asking about what should be returned by a function that count the string length (strlen C function for example) it should be 5 回答2: This particular asciiz string requires 6 bytes

MIPS: Size of .asciiz?

限于喜欢 提交于 2019-12-05 20:53:07
When determining the size of .asciiz string, should I take into consideration the terminating character ? For example: .data string: .asciiz "Hello" The size of "string" is 5 or 6 (byte) ? Thank you in advance. if you are asking about how many bytes in memory the string is stored in then it's 6 bytes if you are asking about what should be returned by a function that count the string length (strlen C function for example) it should be 5 This particular asciiz string requires 6 bytes of storage. In programming situations, you will measure the string size to be 5. As in strlen() . When using this

Reading an integer into a local variable in MIPS

与世无争的帅哥 提交于 2019-12-03 15:08:10
How can I read an integer into a local variable in MIPS ? Is it possible? The problem asks me to use the concept of assigning integer variables as local variables. #A question from my text book. And by the way , not a homework! Thanx in advance! :D li $v0, 5 syscall move $t0, $v0 The value is now in $t0. This will read the integer from the console. 来源: https://stackoverflow.com/questions/6900762/reading-an-integer-into-a-local-variable-in-mips

MIPS (or SPIM): Loading floating point numbers

♀尐吖头ヾ 提交于 2019-11-29 10:51:47
I am working on a little mini compiler while trying to learn some MIPS here. Here's my issue: MIPS has an instruction li (load immediate) which would work like this li $5,100 which would load 100 into register 5. However, I need to load floats into registers right now and am struggling with figuring out a way to do it...since li $5,2.5 does not work. Anyone have any advice? I am working in C, I was thinking I could somehow get the integer representation of the float I am working with (i.e. so the floats binary representation == the ints binary representation) then load the "integer" into the

MIPS (or SPIM): Loading floating point numbers

百般思念 提交于 2019-11-28 04:09:56
问题 I am working on a little mini compiler while trying to learn some MIPS here. Here's my issue: MIPS has an instruction li (load immediate) which would work like this li $5,100 which would load 100 into register 5. However, I need to load floats into registers right now and am struggling with figuring out a way to do it...since li $5,2.5 does not work. Anyone have any advice? I am working in C, I was thinking I could somehow get the integer representation of the float I am working with (i.e. so

Getting the error: “Instruction references undefined symbol … main” in QTSpim

删除回忆录丶 提交于 2019-11-27 16:29:36
I'm trying to compute (a * c) - (b / d), and so far my assembly code is: .data A: .word 5 B: .word 6 C: .word 3 D: .word 2 .text lw $t0, A lw $t1, C mul $t0, $t0, $t1 lw $t1, B lw $t2, D div $t1, $t1, $t2 sub $t0, $t0, $t1 li $v0, 1 move $a0, $t0 syscall li $v0, 10 syscall But when I run it, I get the error. I am new to QTSpim and assembly so I would appreciate some help if possible. Thank you! edit: the exact error is: "Instruction references undefined symbol at 0x00400014 [0x00400014] 0x0c000000 jal 0x0000000 [main] ;188: jal main" The default startup code expects your program to have a

Getting the error: “Instruction references undefined symbol … main” in QTSpim

纵然是瞬间 提交于 2019-11-26 18:40:10
问题 I'm trying to compute (a * c) - (b / d), and so far my assembly code is: .data A: .word 5 B: .word 6 C: .word 3 D: .word 2 .text lw $t0, A lw $t1, C mul $t0, $t0, $t1 lw $t1, B lw $t2, D div $t1, $t1, $t2 sub $t0, $t0, $t1 li $v0, 1 move $a0, $t0 syscall li $v0, 10 syscall But when I run it, I get the error. I am new to QTSpim and assembly so I would appreciate some help if possible. Thank you! edit: the exact error is: "Instruction references undefined symbol at 0x00400014 [0x00400014]