Calculates the odds of winning any of the lottery jackpot

Assignment Help Assembly Language
Reference no: EM131135889

There are many lottery schemes available across the world. Write a MIPS Assembly language program that will calculate the odds of winning the Jackpot prize. For example:

o The Euro Millions lottery requires matching 5 numbers from a pool of 50 numbers and matching 2 numbers from a second pool of 11 numbers.

o The Mega Millions lottery requires matching 5 from 75 and 1 from 15.

o The Thunderball lottery requires matching 5 from 39 and matching 1 from 14.

o The PowerBall lottery requires matching 5 from 69 and 1 from 26.

o The Lotto lottery requires matching 6 from 59.

The subroutine example on the following page, calculates the Factorial of an input integer.

Starting with the code in the example, write a correct program in MIPS - QtSpim assembly language that:

1) Calculates the odds of winning any of the lottery jackpot grand prizes.

2) The calculated value is to be displayed on the QtSpim console screen with an appropriate commentary text. Such as "The odds are 1 in nnnn."

3) The program is to accept as input:

An integer representing the large pool of possible numbers.

A second integer representing the count of numbers to be selected from the large pool.

An integer representing the size of the second pool of numbers.

A fourth integer representing the count of numbers to be selected from the second pool.

4) Test your program by calculating the odds of choosing a set of 2 numbers from a pool of 6 numbers. The value is "1 in 15". Test other combinations.

Note: Because the largest MIPS single precision integer value will not hold the value of more

than 12!, you will need to use some algebra to simplify the calculations. With the

simplifications, all of the math can be done using the integer multiply and divide instructions.

Your program should display a message when it stops.

Use the System Service calls on page A-44 of the textbook for the input and output.

The work products of this assignment are:

1) A copy of the source program text file.

2) Screen captures showing test output results.

# Given n, in register $a0;

# calculates n! and stores the result in register $v0

factrl: sw $ra, 4($sp) # save the return address

sw $a0, 0($sp) # save the current value of n

addi $sp, $sp, -8 # move stack pointer

slti $t0, $a0, 2 # save 1 iteration, n=0 or n=1; n!=1

beq $t0, $zero, L1 # not, calculate n(n-1)!

addi $v0, $zero, 1 # n=1; n!=1

jr $ra # now multiply

L1: addi $a0, $a0, -1 # n = n-1

jal factrl # now (n-1)!

addi $sp, $sp, 8 # reset the stack pointer

lw $a0, 0($sp) # fetch saved (n-1)

lw $ra, 4($sp) # fetch return address

mul $v0, $a0, $v0 # multiply (n)*(n-1)

jr $ra # return value n!

Reference no: EM131135889

Questions Cloud

Prepare a depreciation schedule to be used for tax purposes : Prepare a depreciation schedule to be used for tax purposes for a $110,000 railroad spur (track) using the 200% declining-balance method and a halfyear convention. Ignore any special depreciation allowances.
Show that the differential equation for consumption growth : In the neoclassical growth model with physical and human capital investments described above, the optimal path of physical capital and consumption are given as in the one-sector neoclassical growth model and satisfy the following two differential ..
Plenty of analysts and industry professionals : We are now in 2015 and interest rates are still very low. There are plenty of analysts and industry professionals who argue this has not been the correct approach.
What is the utilization rate of this service system : The Rockwell Electronics Corporation retains a service crew to repair machine breakdowns that occur on an average of 3 per day (approximately Poisson in nature). The crew can service an average of 8 machines per day, with a repair time distribution t..
Calculates the odds of winning any of the lottery jackpot : Calculates the odds of winning any of the lottery jackpot grand prizes. The calculated value is to be displayed on the QtSpim console screen with an appropriate commentary text. Such as "The odds are 1 in nnnn."
Describe the webvan business model : Describe the Webvan business model and then analyze it using the value chain and competitive forces models. - What were the assumptions that drove this business model?
What is the duration of the bond : You purchase a $100 face value U.S 10%, 30-year bond for $110. What is the duration of the bond. what is the current yield of the bond? is it higher or lower than the bond’s ytm? why?. If you sold the bond a the end of 1 year what return would you ha..
Independent standard brownian motions : Let Wt and Bt be independent standard Brownian Motions.Find the characteristic function
Specify the consumer maximization problem in this economy : Characterize the competitive equilibrium, and show that it coincides with the solution to the optimal growth problem.

Reviews

Write a Review

Assembly Language Questions & Answers

  Carefully comment each line of the assembly program

The assembly language code segment below is to be inserted into the main.asm file that takes an input controlled by a potentionmeter, converts that input to a digital value, and displays that value on the LEDs according to the following

  A basic home security system in assembly for an 8051

A basic home security system in assembly for an 8051. needs to have keypad for code and 3 sensors with a panic button.

  Create and use arrays for the students names

Arrays must be used so the flowchart logic can keep track of mulltiple students, each with up to five test scores and a final. So, create and use arrays for the student's names, tests and finals.

  Write a program in assembly language which uses bios

write a program in assembly language which uses bios interrupt int 21 to read current system time and displays it on

  Prepare a assembly program to initialize the led outputs

Write a main.asm file in PSoC designer. Make sure to have the subsequent in place - Initialize the LED outputs to 0's and Set the corresponding bit in INT_MSK0 to 1.

  Write a set of assembly codes in uvision

Write a set of assembly codes in uVision that performs the function described below. Begin with the assumption that 10 randomly selected integer numbers (data) are stored at 0x20002000 to 0x20002024 in sequence in the memory region.

  Application that finds all 4 digit numbers

Create an application that finds all 4 digit numbers (those would be the numbers in the range 1000-9999) whose value is equal to the sum of each digit raised to the fourth power. MEANINGFUL output should be sent to the screen.

  Assembly language program that generates and displays

Write a assembly language program that generates and displays 20 random strings, each consisting of ten letter(A-Z, a-z)s or number(0-9)s.

  Bresenham''s algorithm for drawing a line

This assignment is about writing a line drawing subroutine in ARM assembly language. The following is a C implementation of Bresenham's algorithm for drawing a line between two points.

  Write a mips assembly language program

write a MIPS assembly language program that can be loaded and executed using the MARS simulator.

  Assignment related to arm assembly

The 8-Segment display and LEDs will show status of the safe: U: indicates safe is unlocked, L: indicates safe is locked, P: indicates safe is programming a code, C: indicates safe is confirming a new code

  Find out the largest number from an unordered array

Write an Assembly Language Program to Find out the largest number from an unordered array of 16 numbers( 8-bit) starting at the location 0500H (offset) in the segment 2000H

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd