Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

the code will write on MIPS assembly language Total Price Calculation: Write an MIPS assembly language code to calculate the total price of fruit shopping.

the code will write on MIPS assembly language image text in transcribed
image text in transcribed
Total Price Calculation: Write an MIPS assembly language code to calculate the total price of fruit shopping. The prices are defined by the user at the data segment as float, sequentially. The price of the each fruit is stored at the FruitPriceArray. The user wil enter the amount of the chosen fruit in kg. respectively. The total price is calculated after having all types of fruit. The calculated bill value is displayed at the 10 console. Fruit Name Apple Price 4.45 Orange 2.85 8.25 Strawberry Banana 10.50 Hints: Don't forget to define data and text segments. Don't forget the exit system call. Store the prices in the FruitArray Frul PriceArray: float 4.45, 285, 8.25, 10.50 lwcl $41,0($t2) #load word into coprocessor 1 # Note that the memory address is held in a CPU register, not in a float register mov.s $t1,$0 move $0 to $21 A floating point can be defined at the data segment as number: float 10.5 the defined floating point can be loaded as lwci $t1, number For example: How many of trust did you take 1.25 w many mor of fruit did you take 1.5 How many of fruit did you to how say ise of trus did you take 1.75 Focal price 145.725 - program is interung - Clear The MIPS has a floating point coprocessor (numbered 1) that operates on single precision (32-bit) and double precision (64-bit) floating point numbers. This coprocessor has its own registers, which are numbered $10-$131. Because these registers are only 32-bits wide, two of them are required to hold doubles. To simplify matters, floating point operations only use even-numbered registers-including instructions that operate on single floats. Values are moved in or out of these registers a word (32-bits) at a time by lwcf, swet, mtc1, and mfct instructions or by the ls, ld, S., and s.d pseudoinstructions. The flag set by floating point comparison operations is read by the CPU with its bcft and bett instructions. Special syscalls; addi $v0, $zero, 6 syscall to enter floating points mov.s $$12, $10 addi $v0, $zero, 2 syscall printing out the result to the VO terminal Some useful floating point instructions: c.lt.s FRsrel, FRsrc2 Compare Loss Than Single Compare the floating point single in register FRsrct against the one in FRsc2 and set the condition fag true if the first is less than the second 1wcl FRdest, address Load Floating Point Load the floating float single at address into register FRdest swel FRdest, ddress Store Floating Point Store the floating float single in register FRdest at address mov.s $20, $f1 Move Floating Point Single Move the floating float double (single) from register FRsrc to register Frdest belt L1 Branch to L1 if the flag is set bclf LI + Branch to L1 if the flag is not set cvt.s.W FRdest, FRsrc Convert Single to Integer Convert the double or single precision floating point number in register FRSIC to an integer and put it in register FRdest

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions