Question

In: Computer Science

Write a MIPS assembly program to first set up 10 bank accounts. Store the 10 account...

Write a MIPS assembly program to first set up 10 bank accounts. Store the 10 account numbers in an array named Accounts and the 10 balances in an array named Balances (hard-code them into your program). Your program will then repeatedly read in an account number, a transaction type (0 for deposit and 1 for withdraw), and a transaction amount. Your program will display the new balance after the transaction. An error massage will be printed if an incorrect account number is entered. A withdraw request will be rejected if not enough fund is in the account. Your program will terminate when -1 is entered as an account number.

Use following account numbers and balances to initialize the arrays:

Account Balance

205 123

212 5000

200 4

203 79

201 987

231 500

209 40

207 904

211 33

250 200

Solutions

Expert Solution

Please find the answer below.
Please do comments in case of any issue. Also, don't forget to rate the question. Thank You So Much.

.data
.data
Accounts : .word 205,212,200,203,201,231,209,207,211,250
balances :.word 123,500,4,79,987,500,40,904,33,200
prompt: .asciiz "\nPlease enter bank account number : "
transMsg: .asciiz "\nEnter 0 for deposit or 1 for withdraw : "
amntMSg: .asciiz "\nPlease enter amount : "
newBalMsg: .asciiz "\nNew Balance is : "
errMsg: .asciiz "\nInsufficient balance"
notFound: .asciiz "\nAccount ID not found!!!"
currBalIsMSg: .asciiz "\nYour current balance is : "
errorTransMsg: .asciiz "\nInvalid transaction type entered!!!"
.globl main
.text
main:

la $a3,Accounts
la $a2,balances
li $s0,10 #size of array
while:
li $v0,4
la $a0,prompt #it will print prompt
syscall
li $v0,5
syscall
beq $v0,-1,exit

li $t0,0 #index
loopSearch:
mul $t1,$t0,4 #get index of i
add $t2,$t1,$a3 #get index of array[i]
lw $t2,($t2) #get value of array[i]
beq $t2,$v0,found
addi $t0,$t0,1 #i++
blt $t0,$s0 loopSearch
li $v0,4
la $a0,notFound #it will print prompt
syscall
j while
found:
add $t3,$t1,$a2 #get index of array[i]
lw $t2,($t3) #get value of array[i]
li $v0,4
la $a0,currBalIsMSg #it will print prompt
syscall
li $v0,1
move $a0,$t2
syscall

li $v0,4
la $a0,transMsg #it will print prompt
syscall
li $v0,5
syscall
move $t7,$v0
beq $t7,0,deposite
beq $t7,1,withDraw
li $v0,4
la $a0,errorTransMsg #it will print prompt
syscall
j exitTransIF
deposite:
li $v0,4
la $a0,amntMSg #it will print prompt
syscall
li $v0,5
syscall
add $t2,$t2,$v0
sw $t2,($t3)
j exitTransIF

withDraw:
li $v0,4
la $a0,amntMSg #it will print prompt
syscall
li $v0,5
syscall
blt $t2,$v0,errorWithd
sub $t2,$t2,$v0
sw $t2,($t3)
j exitTransIF


errorWithd:
li $v0,4
la $a0,errMsg #it will print prompt
syscall
j exitTransIF
exitTransIF:

li $v0,4
la $a0,newBalMsg #it will print prompt
syscall
move $a0,$t2
li $v0,1
syscall

j while
exit:


Related Solutions

Write a MIPS assembly program that prompts the user first for a string, then for a...
Write a MIPS assembly program that prompts the user first for a string, then for a character. The program should then search the string for the character and print out the number of times the character appears in the string. You can use as many restrictions as you want, just be sure to list them. You must allocate space in the .data segment of your program for the user string.
Write a MIPS assembly language program to solve the following problem: For a set of integers...
Write a MIPS assembly language program to solve the following problem: For a set of integers stored in an array, calculate the sum of the even numbers and the sum of the odd numbers. The program should store these numbers in memory variables: evenSum and oddSum. Numbers should be read from the array one at a time with a zero value (0) being used to signal the end of data in the array.
Coding Problem 1: In this program, you are asked to write a program in assembly (MIPS)...
Coding Problem 1: In this program, you are asked to write a program in assembly (MIPS) which works as a simple calculator. The program will get two integer numbers, and based on the requested operation, the result should be shown to the user. a. The program should print a meaningful phrase for each input, and the result. i. “Enter the first number” ii. “Enter the second number” iii. “Enter the operation type” iv. “The result is” b. The user should...
Write a program in MIPS Assembly. This program will ask the user to enter 20 numbers....
Write a program in MIPS Assembly. This program will ask the user to enter 20 numbers. The program will store these numbers in an array in memory (sequential memory locations). It will then print out the list of numbers in three different formats: The numbers will be printed each on a separate line. The numbers will be printed on a single line, with spaces between the numbers. The program will ask the user to enter a number n. The program...
MIPS Assembly LanguageWrite a MIPS assembly language program that asks the user toinput an...
MIPS Assembly LanguageWrite a MIPS assembly language program that asks the user to input an integer and then prints out a string that shows how that integer should be encoded using 16 bits. Your program should handle both positive and negative valued inputs. Your program should also print out an error message if the given input cannot be expressed as a 16 bit signed integer.As an example, if the input is 12, your program should output “0000000000001100”. If the input...
Binary Search. Write a MIPS assembly program to perform a binary search on A[10], which is an array of 10 positive integers.
Binary Search. Write a MIPS assembly program to perform a binary search on A[10], which is an array of 10 positive integers. Your program should have a main routine that does the following:(a) Prompt the user to enter all the 10 integers in the array.(b) Prompt the user to enter the number to be searched.(c) Reads the integer values and makes sure it is a positive integer.(d) Prints the index of the integer. If the input is not available in...
Write a program in MIPS assembly language to perform the calculation of the following equation and...
Write a program in MIPS assembly language to perform the calculation of the following equation and save the result accordingly:    f = 5x + 3y + z Assumptions: - Registers can be used to represent variables x, y, z, and f - Initialize x, y, and z to values of your choice. f can be initialized to zero. - Use comments to specify your register usage and explain your logic
Write a MIPS assembly language program to find the addition of two arrays
Write a MIPS assembly language program to find the addition of two arrays
Write a MIPS assembly program that calculates the sum of all the elements in the following...
Write a MIPS assembly program that calculates the sum of all the elements in the following array: int array[10]={12,21,3,40,15,6,17,8,29,10}
write mips assembly mips assembly (x+a) (bx^2+cx+d) using the pesedo- code with loop ,program should claclute...
write mips assembly mips assembly (x+a) (bx^2+cx+d) using the pesedo- code with loop ,program should claclute six T[i] and display aproper message about roots .the the program should store all T[i] as memory array a = [1, 1, 1, 1, 1, 1]; b = [1, 2, 4, 8, 16, 32]; c = [-6, -4, -2, 2, 4, 6]; d = [-1, -3, -5, -7, -9, -11]; for (i=0 ; i<=6; i++) { T[i] =-4 *b [i] * d[i] +c[i] *...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT