Monday, April 8, 2019
Displays the result Essay Example for Free
Displays the result EssayTo modify legibility the comments atomic number 18 endangered to the right of every TOM line of code, and not in the standard style. train keyin Reads information inputted by keyboard and entrepots in the parentage status keyin point keyin rafts info from the gillyf get shaftet keyin in to the aggregator gunman minus Subtracts the inject locating minus from the aggregator gunstock pageant Stores cling to in storage battery in the stock mending display chump display Displays limit of the stock certificate view display on the coverting mental block Stops course of teaching writ of work minus selective information. 1 Initialises a injecthousehouse localisation minus with the hold dear 1 in it keyin entropy 0 Initialises a put in place keyin with the treasure 0 in it display information 0 Initialises a investment company place display with the measure out 0 in it 2. Write a TOM schedule that fills a tour from the keyboard, multiplies it by 2, enjoins an sepa come in number b from the keyboard, multiplies it by 3, and then displays the result. In other words, evaluate 2*a+3*b. read keyin1 Reads selective information inputted by keyboard and retentivitys in the interpose mess keyin1 load keyin1 Loads data from the pedigree military position keyin1 in to the gatherer mult val1 Multiplies the collector by the gillyflower status val1 farm animal display Stores pry in accumulator in the neckcloth billet display read keyin2.Reads data inputted by keyboard and introduces in the retentivity location keyin2 load keyin2 Loads data from the salt away location keyin2 in to the accumulator mult val2 Multiplies the accumulator by the store location val2 add display Adds the store location display to the accumulator store be Stores nourish in accumulator in the store location radical imprint native Displays contents of the store location nume govern on the screen stop Stops co urse of instructionme execution val1 data 2 Initialises a store location val1 with the entertain 2 in it val2 data.3 Initialises a store location val2 with the value 3 in it keyin1 data 0 Initialises a store location keyin1 with the value 0 in it keyin2 data 0 Initialises a store location keyin2 with the value 0 in it display data 0 Initialises a store location display with the value 0 in it match data 0 Initialises a store location heart with the value 0 in it 3. Write a TOM program that displays both numbers, raiseed from the keyboard, in descending numerical order. read keyin1 Reads data inputted by keyboard and stores in the store location keyin1 read keyin2.Reads data inputted by keyboard and stores in the store location keyin2 load keyin1 Loads data from the store location keyin1 in to the accumulator sub keyin2 Subtracts the store location keyin2 from the accumulator jifz discredit Transfers verify to the instruction lower if the home in(a) oarlock is set print keyi n1 Displays contents of the store location keyin1 on the screen print keyin2 Displays contents of the store location keyin2 on the screen stop Stops program execution lower print keyin2 Displays contents of the store location keyin2 on the screen print keyin1.Displays contents of the store location keyin1 on the screen stop Stops program execution keyin1 data 0 Initialises a store location keyin1 with the value 0 in it keyin2 data 0 Initialises a store location keyin2 with the value 0 in it 4. Write a TOM program that reads a number N from the keyboard and displays the bosom of all integers from 1 to N i. e. 1+2+3+ +N. read keyin.Reads data inputted by keyboard and stores in the store location keyin loop load sofar Loads data from the store location sofar in to the accumulator add one Adds the store location one to the accumulator store sofar Stores value in accumulator in the store location sofar add total Adds the store location total to the accumulator store total Stores value i n accumulator in the store location total load sofar Loads data from the store location sofar in to the accumulator sub keyin Subtracts the store location keyin from the accumulator jifn loop.Transfers control to the instruction loop if the sign flag is set print total Displays contents of the store location total on the screen stop Stops program execution keyin data 0 Initialises a store location keyin with the value 0 in it one data 1 Initialises a store location one with the value 1 in it sofar data 0 Initialises a store location sofar with the value 0 in it total data 0 Initialises a store location total with the value 0 in it Alternatively, a to a greater extent mathematical approach would be to use the downstairs program.Observing the numbers inputted and outputted from the above program, I was able to find a relationship between the ii numbers, this can be summarised by the below formula (N x 0. 5) + 0. 5 x N = entireness The program using the above formula is simpler to w rite, uses far less processor cycles, and therefore far more efficient. read keyin Reads data inputted by keyboard and stores in the store location keyin load keyin Loads data from the store location keyin in to the accumulator mult val Multiplies.the accumulator by the store location val add val Adds the store location val to the accumulator mult keyin Multiplies the accumulator by the store location keyin store total Stores value in accumulator in the store location total print total Displays contents of the store location total on the screen stop Stops program execution keyin data 0 Initialises a store location keyin with the value 0 in it val data .5 Initialises a store location val with the value 0. 5 in it total data 0 Initialises a store location total with the value 0 in it TOM2 1. A mobile telephone company, Odear, makes a monthly stand up charge of i 12.50 and charges 5 pence per local call. Write a TOM program that reads the amount of calls made and displays the total mo nthly bill. read calls Reads data inputted by keyboard and stores in the store location calls load calls Loads data from the store location calls in to the accumulator mult prescribe Multiplies the accumulator by the store location appraise add standing Adds the store location standing to the accumulator store total Stores value in accumulator in the store location total print total Displays contents of the store location total on the screen stop Stops program execution total data.0 Initialises a store location total with the value 0 in it calls data 0 Initialises a store location calls with the value 0 in it standing data 12. 50 Initialises a store location standing with the value 12. 50 in it send data . 05 Initialises a store location rate with the value . 05 in it 2. Expand your program of (1) so that the program jumps back to the beginning, ready to calculate other bill instead of ending. start read calls Reads data inputted by keyboard and stores in the store location call s load calls Loads data from the store location calls in to the accumulator mult rate.Multiplies the accumulator by the store location rate add standing Adds the store location standing to the accumulator store total Stores value in accumulator in the store location total print total Displays contents of the store location total on the screen jump start Transfers control to the instruction start stop Stops program execution total data 0 Initialises a store location total with the value 0 in it calls data 0 Initialises a store location calls with the value 0 in it standing data 12. 50 Initialises a store location standing with the value 12. 50 in it rate data .05 Initialises a store location rate with the value . 05 in it 3. Whats disparage with the program in (2)? The program has no way of ending (normally), and will therefore loop continuously. 4. turn (2) so that if the substance abuser enters 0 for the number of units the program terminates. start read calls Reads data inputted by keyboard and stores in the store location calls load calls Loads data from the store location calls in to the accumulator sub check Subtracts the store location check from the accumulator jifz end Transfers control to the instruction end if the zero flag is set mult rate.Multiplies the accumulator by the store location rate add standing Adds the store location standing to the accumulator store total Stores value in accumulator in the store location total print total Displays contents of the store location total on the screen jump start Transfers control to the instruction start end stop Stops program execution total data 0 Initialises a store location total with the value 0 in it calls data 0 Initialises a store location calls with the value 0 in it standing data 12. 50 Initialises a store location standing with the value 12. 50 in it rate data .05 Initialises a store location rate with the value . 05 in it check data 0 Initialises a store location check with the value 0 in it 5 . Now modify (4) so that the user can tell the system how many bills to calculate and the program terminates after running that many times. read billnum Reads data inputted by keyboard and stores in the store location billnum start read calls Reads data inputted by keyboard and stores in the store location calls load calls Loads data from the store location calls in to the accumulator mult rate Multiplies the accumulator by the store location rate add standing.Adds the store location standing to the accumulator store total Stores value in accumulator in the store location total print total Displays contents of the store location total on the screen load billnum Loads data from the store location billnum in to the accumulator sub billsub Subtracts the store location billsub from the accumulator store billnum Stores value in accumulator in the store location billnum jifz end Transfers control to the instruction end if the zero flag is set jump start.Transfers control to the instructio n start end stop Stops program execution total data 0 Initialises a store location total with the value 0 in it calls data 0 Initialises a store location calls with the value 0 in it standing data 12. 50 Initialises a store location standing with the value 12. 50 in it rate data . 05 Initialises a store location rate with the value . 05 in it billnum data 0 Initialises a store location billnum with the value 0 in it billsub data 1 Initialises a store location billsub with the value 1 in it 6. Finally, modify the program of (5) so that the user can first enter the price per unit, and the standing charge.Read rate Reads data inputted by keyboard and stores in the store location rate read standing Reads data inputted by keyboard and stores in the store location standing read billnum Reads data inputted by keyboard and stores in the store location billnum start read calls Reads data inputted by keyboard and stores in the store location calls load calls Loads data from the store location calls in to the accumulator mult rate Multiplies the accumulator by the store location rate add standing.Adds the store location standing to the accumulator store total Stores value in accumulator in the store location total print total Displays contents of the store location total on the screen load billnum Loads data from the store location billnum in to the accumulator sub billsub Subtracts the store location billsub from the accumulator store billnum Stores value in accumulator in the store location billnum jifz end Transfers control to the instruction end if the zero flag is set jump start.Transfers control to the instruction start end stop Stops program execution total data 0 Initialises a store location total with the value 0 in it calls data 0 Initialises a store location calls with the value 0 in it standing data 0 Initialises a store location standing with the value 0 in it rate data 0 Initialises a store location rate with the value 0 in it billnum data 0 Initialises a s tore location billnum with the value 0 in it billsub data 1 Initialises a store location billsub with the value 1 in it Modifications in TOM2 In move 1, the program initialises four store locations rate to store the standard call rate of 0. 5, standing to store the standing charge of 12. 50, calls to store the number of calls made and total to store the total bill.The programs reads a value inputted by the user (number of calls), multiplies this value by the call rate, adds the standing order and displays it. Question 2 introduces a loop after the total has been displayed to the start of the program so that user may calculate another bill, this however is not prototype as there is no correct way to terminate the program normally. Question 4 combats this conundrum by allowing the user to enter 0 to terminate the program. This is done by introducing an incremental store location called check with the value 0 assigned to it.The program subtracts check from the number of calls enter ed, if the result is 0 (0 0 = 0) then the zero flag is set, the jifz parameter then transfers control to the end of the program, where it terminates normally. Question 5, in addition to the store location used in question 1 introduces two more billnum to store the number of bills required and billsub, a store location containing the value 1. The user initially enters the number of bills required, this is stored in billnum, the program then calculates the bill in same way as question 1.After the bill has been displayed, the program subtracts billsub (1) from the number of bills, if the result is zero (ie no more bill to calculate) the zero flag is set, and using the jifz statement jumps to the end of the program. If the zero flag is not set (more bills to calculate) the program is looped back to enter more bill details. Question 6, allows the user to enter the standing charge, rate of calls and number of bills before the bills are calculated, these are stored in their respective lo cations (standing, rate and billnum) before the program continues to execute in the same way as question 5.CSO Tutorial 4 economic consumption 2. 1 We wish to compare the performance of two different machines M1 and M2. The following(a) measurements have been made on these machines Program Time on M1 Time on M2 1 10 seconds 5 seconds 2 3 seconds 4 seconds Which machine is faster for each program and by how ofttimes? For program 1, M2 is 5 seconds(or 100%) faster than M1. For program 2, M1 is 1 second (or 25%) faster than M2. Exercise 2. 2 Consider the two machines and programs in Exercise 2. 1. The following additional measurements were made Program. book of instructions penalize on M1 Instructions executed on M2 1 200 x 106 160 x 106 go the instruction execution rate (instructions per second) for each machine running program 1. Instructions executed = Instructions per second (instruction execution rate) time(seconds) M1 200000000 = 20000000 10 = 20 x 106 Instructions per secon d or 20 gazillion Instructions per second M2 160000000 = 32000000 5 = 32 x 106 Instructions per second or 32 one thousand thousand Instructions per second Exercise 2. 3 If the clock rates of machines M1 and M2 in Ex 2.1 are 200 MHz and 300 MHz respectively, find the clock cycles per instruction (CPI) for program 1 on both machines using the data in Ex 2. 1 2. 2. Clock rate = clock cycles per instruction (CPI) Instruction execution rate M1 200000000 = 10 clock cycles per instruction (CPI) 20000000 M2 300000000 = 9. 375 clock cycles per instruction (CPI) 32000000 Question 4 Draw a full flowchart of the final TOM program produced at the end of physical exertion TOM2. This should include all the instructions, loops and all the program labels in the appropriate places.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment