Question: ARM Assembly - You are given some code in PA3-2.s that implements a simple vending machine type behavior. The vending machine has three choices, peanuts
ARM Assembly - You are given some code in PA3-2.s that implements a simple vending machine type behavior. The vending machine has three choices, peanuts (75 cents), chocolate ($1.25), and pretzels (90 cents), and also allows the user to select a quantity of the item they want. The code takes their choice, computes the price for that item, and multiplies it by the quantity leaving the result in R2. The program currently uses branches to perform the computation. You must remove all the branches using conditional execution. The behavior of the code must be the same as the code with the branches
. 
Your required header comments go here Vending machine code CSC 2301 vending machine! The choice variable indicates which selection the user wants 2 1 for peanuts 75 cents 2 for chocolate e 125 cents 3 for pretzels 90 cents the quantity variable indicates how many of that selection they want choice DCD quantitY DCD 1 start LDR LDR RO, choice RO, [RO] Your modifications will begin at this point RO, #1 ??? BEQ CMP BEQ ??? BEQ MOV : Check for "peanuts" :If choice was 1 goto peanuts : Check for "chocolate" : If choice was 2 goto choc : Check for "pretzels" :If choice was 3 goto _pretzel : If we get here choice entered is peanut RO, RO, R2 , #2 #3 #-1 choc pretzel : an illegal selection so write -1 into R2 to 3ignal an error and terminate END peanut MOV BAL R3, #75 : Move 75 cents into R3 compute choc MOV BAL R3 , #125 compute : Move 125 cents into R3 _pretzel MOV R3, #90 : Move 90 cents into R3 compute LDR LDR MUL R1, quantity R1, [R1] R2, R3, R1 : Multiply number of cents times quantity : and put result in R2 END
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
