I am trying to create a simple program for adding two floating point numbers to the MIOP using SPIM simulator. The code is shown below:
.data prompt1: .asciiz "\ nPlease hit it first & lt; enter & gt;:" prompt2: .asciiz "\ nPlease enter the first number And then & lt; enter & gt;: "Result: .sciiz" \ n "is:". Mainly: $ li $ v0, 4 la $ a0, prompt 1 syscall li $ v0, 5 syscall move $ f1, $ V0 li $ v0, 4a $ a0, prompt 2 syscall li $ v0, 5 syscall move $ fp2, $ v0 add.d $ fp4, $ fp2, $ fp0 li $ v0.4 la $ a0, results syscall li $ V0, 1 move $ a0, $ fp4 syscall li $ v0, 10 syscall
When I load a program in the PCSPIM simulator, I get an error message I When I am using normal registers such as $ s0
, $ s1
, $ s2
) instead of floating point registers, two common To add an integer, it works perfectly.
How can I add two floating point numbers using floating point registers?
Floating point registers in MOIS remain in co-processor 1 because co-op Use Cesar 1 to FPU. You need to use the mtc1 command instead of driving directions to move data in a Floating Point Register. It means "go to co-processor 1".
You can refer to this document online for the instruction set manual:
Edit: Naming the floating point is also known as registrar $ f0- $ Not f31 and $ fp0- $ fp31.
No comments:
Post a Comment