mars-simulator

Handling non-digit user input to a MARS read-integer system call?

独自空忆成欢 提交于 2021-02-05 12:00:36
问题 I'm doing a simple program of car park that takes the input from the user, and branch to a label in accordance of the input. The problem is, the program always ends abruptly if the user enter an input with different data type than integer (like "a" or any alphabets) Below is my code (that relevant to the input part) : li $v0,5 #system call to get input from user syscall li $t1,2 beq $v0,1,park # go to "park" section of codes if input is 1 beq $v0,2,exit # go to "exit" section of codes if

MARS MIPS simulator's built-in assembler aligns more than requested?

大城市里の小女人 提交于 2021-02-01 05:14:17
问题 I have the following data segment .data a: .byte 0x11 .align 1 b: .word 0x22334455 Assuming that address "a" is 0x10010000, then the expected address for the word at b is 0x10010002, but MARS stores the word at 0x10010004, ignoring the explicit ".align" directive. By the way, I used MARS MIPS simulator (Version 4.5 on a MacBook Pro) to assemble the above code. Therefore, my question is: Is this a bug, or is it expected that the behavior of MARS differs from SGI's 1992 documentation for MIPS

MARS MIPS simulator's built-in assembler aligns more than requested?

馋奶兔 提交于 2021-02-01 05:12:18
问题 I have the following data segment .data a: .byte 0x11 .align 1 b: .word 0x22334455 Assuming that address "a" is 0x10010000, then the expected address for the word at b is 0x10010002, but MARS stores the word at 0x10010004, ignoring the explicit ".align" directive. By the way, I used MARS MIPS simulator (Version 4.5 on a MacBook Pro) to assemble the above code. Therefore, my question is: Is this a bug, or is it expected that the behavior of MARS differs from SGI's 1992 documentation for MIPS

MIPS Input floating point number

大憨熊 提交于 2020-12-26 04:34:10
问题 How do you take in an input of a floating number in MIPS? I have tried using: li.s $f0, 6 syscall But I just keep getting that there is an error with the line. 回答1: li $v0, 6 syscall //the float value that is read will be in $f0 register 回答2: you cannot load-immediate a number into float registers li $t0, 6 # load-immediate 6 into an int register mtc1 $t0, $f0 # copies the bit pattern "...110". It is NOT 6.0!! cvt.s.w. $f12, $f0 # convert word to (single) float. $f12 now contains 6.0 回答3: You

MIPS Input floating point number

ぐ巨炮叔叔 提交于 2020-12-26 04:33:25
问题 How do you take in an input of a floating number in MIPS? I have tried using: li.s $f0, 6 syscall But I just keep getting that there is an error with the line. 回答1: li $v0, 6 syscall //the float value that is read will be in $f0 register 回答2: you cannot load-immediate a number into float registers li $t0, 6 # load-immediate 6 into an int register mtc1 $t0, $f0 # copies the bit pattern "...110". It is NOT 6.0!! cvt.s.w. $f12, $f0 # convert word to (single) float. $f12 now contains 6.0 回答3: You

Reading from one file and writing to another - MIPS

↘锁芯ラ 提交于 2020-12-15 05:36:12
问题 I have written some code which opens and reads from a file, input.txt, in a loop. I now want to take each word from the first file, and write it to a new file like so. If file 1 says "This is my file", File 2 would say "This /n is /n my /n file" each on a separate line. I have written a label which opens the file to be written to, now I am unsure of what I should write in order to access each word from my input.txt. file_open: li $v0, 13 la $a0, output_file_name # output.txt li $a1, 1 li $a2,