• Join over 1.2 million students every month
  • Accelerate your learning by 29%
  • Unlimited access from just £6.99 per month
Page
  1. 1
    1
  2. 2
    2
  3. 3
    3
  4. 4
    4
  5. 5
    5
  6. 6
    6
  7. 7
    7
  8. 8
    8
  9. 9
    9
  10. 10
    10

Write a TOM program that reads a number from the keyboard, subtracts 1 and displays the result.

Extracts from this document...

Introduction

TOM1 1. Write a TOM program that reads a number from the keyboard, subtracts 1 and displays the result. To improve legibility the comments are displayed to the right of every TOM line of code, and not in the standard style. 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 sub minus Subtracts the store location minus from the accumulator store display Stores value in accumulator in the store location display print display Displays contents of the store location display on the screen stop Stops program execution minus data 1 Initialises a store location minus with the value 1 in it keyin data 0 Initialises a store location keyin with the value 0 in it display data 0 Initialises a store location display with the value 0 in it 2. Write a TOM program that reads a number from the keyboard, multiplies it by 2, reads another 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 data inputted by keyboard and stores in the store location keyin1 load keyin1 Loads data from the store location keyin1 in to the accumulator mult val1 Multiplies the accumulator by the store location val1 store display Stores value in accumulator in the store location display read keyin2 Reads data inputted by keyboard and stores in the store location keyin2 load keyin2 Loads data from the store location keyin2 in to the accumulator mult val2 Multiplies the accumulator by the store ...read more.

Middle

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. What's wrong with the program in (2)? The program has no way of ending (normally), and will therefore loop continuously. 4. Modify (2) so that if the user 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 ...read more.

Conclusion

CSO Tutorial 4 Exercise 2.1 We wish to compare the performance of two different machines: M1 and M2. The following 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 much? 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 Instructions executed on M1 Instructions executed on M2 1 200 x 106 160 x 106 Find 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 second or 20 Million Instructions per second M2 160000000 = 32000000 5 = 32 x 106 Instructions per second or 32 Million 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 exercise TOM2. This should include all the instructions, loops and all the program labels in the appropriate places. ...read more.

The above preview is unformatted text

This student written piece of work is one of many that can be found in our AS and A Level Computer Science section.

Found what you're looking for?

  • Start learning 29% faster today
  • 150,000+ documents available
  • Just £6.99 a month

Not the one? Search for your essay title...
  • Join over 1.2 million students every month
  • Accelerate your learning by 29%
  • Unlimited access from just £6.99 per month

See related essaysSee related essays

Related AS and A Level Computer Science essays

  1. Smart Card System

    server database Failed Password Valid administrator password Passed Invalid administrator password Failed (B) Change Password Form Testing Field Testing Data Result Current Password Same login password Passed Different login password Failed New Password Any characters, digits, or combination of both Passed Confirm New password Same to new password Passed Different from new password Failed (C)

  2. Who is Bill Gates?

    The pool also has its own underwater music system. Attached to his piece of land that touches Lake Washington is a boathouse and also a man-made beach with imported driftwood. A billionaire's mansion would not be complete without a library. Gates hired a New York rare books store to stock up his two thousand one hundred square foot library.

  1. I.C.T. coursework on Computer games retail store.

    > Intel Pentium 4 processor (to make use of high speed processing) > DVD/CD-RW, floppy and hard disk drives (used for storage, transferring and storing data outside the computer). > Pentium operating system (as it gives higher restriction and access levels, and it gives the server option across many computers).

  2. Investigate Data Communications.

    With this system, it is not necessary for the sender and receiver of a message to be connected simultaneously. To be able to use electronic mail you need to have a computer, a Modem, a telephone line, and an electronic mail service.

  1. The Von Neumann Machine

    inside the ALU (6) CPU copied the contents of MBR to Accumulator. (7) CPU adds the contents of register `REG' with Accumulator in a register in ALU and overwrites the old value of accumulator with the answer. Steps involved in executing 3^rd instruction: Fetch Cycle (1)

  2. The Value of Data and the Use of Databases

    is the electronic transmission of business data such as purchase orders and invoices from one firm's computerised information to that of another firm. EDI was developed to provide an interface between two separate computer systems. Each company could have its own way of doing things, but by using EDI, they

  1. Program Code Program DVD_Program; Uses Menuunit, CRT, dos; ...

    then valid:= j; End; validatephone:= valid; if ( valid<> 0) then Begin textcolor(red); gotoxy(12,19); Write( 'SORRY INVALID PHONE NUMBER '); delay(800); gotoxy(12,19); Write (' '); textcolor(blue); gotoxy(37,13); For j:= 1 to 1+1 Do Write (' '); End; End; {------------------------------------------------------------------} {Validates the actor name entered by the user.} Function validateactor (

  2. CP3 - Proposed Solution to a Realistic Problem - Apartment Administration software

    Considering spreadsheet software is dedicated to numerical analysis I do not think that a spreadsheet would be a suitable solution for my system. Neither would it cater for the storage of records like customer details etc and it would not be as appealing as a GUI.

  • Over 160,000 pieces
    of student written work
  • Annotated by
    experienced teachers
  • Ideas and feedback to
    improve your own work