31
GCSE Computing Sample Assessment Material Write Up Mr Travi Royal Grammar School No 1 Introduction to the Little Man Computer

GCSE Computing

  • Upload
    gaura

  • View
    33

  • Download
    1

Embed Size (px)

DESCRIPTION

GCSE Computing. Sample Assessment Material Write Up Mr Travi Royal Grammar School No 1 Introduction to the Little Man Computer. Introduction. - PowerPoint PPT Presentation

Citation preview

Page 1: GCSE Computing

GCSE Computing Sample Assessment Material Write Up

Mr Travi Royal Grammar School

No 1 Introduction to the Little Man Computer

Page 2: GCSE Computing

Introduction

In this practical investigation I am going to look at the Littleman Computer Simulation. The software for this is provided at www.atkinson.yorku.ca/~sychen/research/LMC/LMCHome.htmlThe Littleman Computer Simulation simulates simple microprocessor and contains the following elementsProgram counter – this tells the program where the next instruction is going to be executed fromAccumulator is a register in which intermediate arithmetic and logic results are stored whilst the program is being assembledInbox – this is where the user enters data that the program is going to executeOutbox – this is where the data that is processed and produced by the program is going to be displayed

Page 3: GCSE Computing

Using the Little Man Computer Simulation The LMC responds to commands in the same as any high level programming language and has its own instruction set.

Instruction Mnemonic Machine Code Comments

Load LDA 5xx Load what is stored a location into the accumulator in the accumulator into for example LDA count – this would load the contents of whatever is store location count and place this into the accumulator

Store STA 3xx Store the contents of the input box into a storage location. For example STA COUNT this would store the contents into location count which would be the next available storage location in the littleman computer simulation

Add ADD 1xx Add One – add the contents of storage location one to the accumulator

Subtract SUB 2xx Subtract One – Subtract the contents of storage location one to the accumulator

Input INP 901 Read in the contents of the input box into the accumulator

Output OUT 902 Display the contents of the accumulator in the output box

End HLT 000 End the program

Branch if zero BRZ 7xx This is selection / iteration statements Branch if the contents of the accumulator are zero -

Branch if zero or

positive BRP 8xx Branch if the contents of the accumulator

are zero or positive-

Page 4: GCSE Computing

Branch always BRA 6xx Branch always if the contents of the accumulator are not zero

Data storage DAT DAT – declares the names of storage locations and value

Count DAT – declares count as a location ONE DAT 1 - declares one as a location with a set value of 1

Instruction set Continued

As part of this assessment I am going to look at the working of 2 of the sample programs / tutorials which came with the LMC software and explain how these operate. The two programs I have chosen are 1.Produce a program using the LMC to input 2 integer values and output the add output the largest then the smallest2.Produce a program using the LMC to input 2 integer values and add them together I am going to illustrate how the LMC with a further 3 programs as well 1.Produce a program which use the LMC instruction set to write a program to add the first 2 values together and subtract the third integer value and store the results into the accumulator and display it in the out box together 2 integer values and then terminate2.Produce a program using the LMC that will output the values from 1 to 10 I am going to modify this program so that the user can chose what number to input between 1 and 10. I will then change the program so that it counts down3.Produce a program which will give the user a chance of a range of numbers and output odd and even numbers between these totals These programs will demonstrate the use of branching statements within the LMC

Task 1

Page 5: GCSE Computing

Program 1 Using selection to find out which number is the largest of 2 numbers entered

1) This represents the flowchart / algorithm for the program to be entered into the littleman ting

2) This shows the instructions being loaded into the computer simulators memory location now click on run

Page 6: GCSE Computing

Program 1 Coded example

INP

STA first Input first value store in location first

INP

STA second Input first value store in location first

SUB FIRST Subtract first from second number

BRP SECONDBIG Is what is left a positive number if so

LDA FIRST Load the contents of first into the accumulator and display to output

OUT

BRA PROGRAMEND If not load the Load the contents of second into the accumulator and display to output

SECONDBIG LDA SECOND

OUT

PROGRAMEND HLT End the program

first DAT Declare memory location first

second DAT Declare memory location second

Page 7: GCSE Computing

INPSTA FIRSTINPSTA SECONDSUB FIRSTBRP SECONDBIGLDA FIRSTOUTBRA PROGRAMENDSECONDBIG LDA SECONDOUT PROGRAMEND HLTFIRST DATSECOND DAT

The first number is loaded and then stored in memory location firstThe second number is loaded and then stored in memory location secondThe second number is subtracted from the first and the result stored in the accumulator Are the results in the accumulator greater than or equal to zero? If so load the results of storage location first and load then into the accumulator and output them – end that part of the programElse Load the contents of storage location second and load then into the accumulator and output them – end that part of the program

Page 8: GCSE Computing

Program 1 Using selection to find out which number is the largest of 2 numbers entered

In this video (called largestof2numbers.avi) I tested this program.

Page 9: GCSE Computing

Test Data Expected Outcome Actual Outcome

1 I am going to enter 65 as the first number 64 as the second number

65 should come out as the largest As expected

2 I am going to enter 64 as the first number 65 as the second number

65 should come out as the largest As expected

Program 1 Using selection to find out which number is the largest of 2 numbers entered test plan and table

The program loads the instruction set 64 is entered - stored in the first memory location65 is entered – stored in the second memory location INP opcode 901 stored in 0 STA opcode 312 result stored in 12 on the LMC stored in 1INP opcode 901 stored in 2 STA opcode 313 result stored in 13 on the LMC stored in 3 Sub FIRST opcode 212 stored in 4BRP SECONDBIG opcode 809 – branch if positive stored in 5

Page 10: GCSE Computing

LDA FIRST – load the result of first and place into accumulator stored at 6Out – display results of accumulator to output box stored at 7Branchalways if value in accumulator is not postive stored at 8LDA second load the result off first and place into accumulator stored at 9Out – display results of accumulator to output box stored at 10End program

Page 11: GCSE Computing

Produce a program using the LMC to input 2 integer values and add them together

inp Input a value into the input and copy this into the accumulator

sta first Store this value in store location called first LMC allocates this to the first memory location available

inp Input a value into the input and copy this into the accumulator

sta second Store this value in store location called first LMC allocates this to the next memory location available

add first Add the contents of the accumulator to what is stored in memory location first and return these values to the accumulator

out Output these values

first dat Define memory location first dat

Second dat Define memory location Second dat

Test Data Expected Outcome Actual Outcome1 I am going to enter4 as the

first number 4 as the second number

The result in the accumulator should be 6

As expected

Page 12: GCSE Computing

2) Produce a program using the LMC to input 2 integer values and add them together

In this video (called adding2nos.avi) I tested this program. I have enclosed the video as a standalone file in case this does not load and shows the test mentioned above

Page 13: GCSE Computing

3) Produce a program using the LMC that will output the values from 1 to 10 counting up I am going to modify this program so that the user can chose what number to input between 1 and 10. I will then change the program so that it counts down

INP STA COUNTOUTLOOPTOP LDA COUNTADD ONEOUTSTA COUNTSUB TWENTYBRP ENDLOOPBRA LOOPTOPENDLOOP HLTONE DAT 001TWENTY DAT 020COUNT DAT

Start

Input a number and store in count

Load the result into the accumulator

Add the contents of memory location 1 to the accumulator

Subtract the contents of memory location 1 to the accumulator (20)

Is the result positive?

Output the results to the accumulator

NoYes

End

Page 14: GCSE Computing

Test Data Expected Outcome Actual Outcome1 I am going to 4 into the

accumulator The program will output all the numbers between 4 and 10 in increments of 1

As expected

2 I am going to 1 into the accumulator

The program will output all the numbers between 1 and 10 in increments of 1

As expected

3) Produce a program using the LMC that will output the values from 1 to 10 counting up I am going to modify this program so that the user can chose what number to input between 1 and 10. I will then change the program so that it counts down test plan

In this video (called countingprog1to10) I tested this program. I have enclosed the video as a standalone file in case this does not load and shows the test mentioned above

Page 15: GCSE Computing

Video Counting prog and testing counting up 1 to 10

Page 16: GCSE Computing

3) I am going to modify the program in 3a so that it counts down. I will then change the program so that it counts down test plan

Test Data Expected Outcome Actual Outcome1 I am going to enter 19 as the

first number 19 should come out and the program should count down in increments of 1 until it reaches 0

As expected

2 I am going to enter 2 as the first number

2 should come out and the program should count down in increments of 1 until it reaches 0

As expected

INP Input value

STA COUNT store value in memory location count

OUT output value

LOOPTOP LDA COUNT load the value into the accumulator

BRZ ENDLOOP is the value 0 if so go to endloop sub if not

SUB ONE subtract 1

OUT load the value into the accumulator

STA COUNT store value in memory location count

SUB TWENTY subtract 20 from the value in count

BRA LOOPTOP go back to loopcount

ENDLOOP HLT end the program

ONE DAT 001 one declared as memory location with a value of 1

TWENTY DAT 020 twenty declared as memory location with a value of 20COUNT DAT count declared as variable

Page 17: GCSE Computing

Video Counting prog and testing counting down 20 to 1

I have saved this as countprog20to1.avi and this will show the program working counting back from 19 in increments of 1 to 0 and from 2 in increments of 1 to 0

Page 18: GCSE Computing

Produce a program which will give the user a chance of a range of numbers and output odd and even numbers between these totals

INP Number initally input

LOOP STA ODD start loop save this number in storage location ODD located at 111

LDA NUM load the contents of number into the accumulator

SUB ODD subtract from the contents of number the vale in ODD

BRP MORE Branch if the number is postive

END HLT end the program

MORE LDA ODD if not load the contents of odd

OUT send this to display in the out box

ADD TWO add the value of storage location two (which is 2) and loop againBRA LOOP

TWO DAT 2 Declaration of variable TWO with value 2

ODD DAT 1 Declaration of variable ONE with value 1

NUM DAT 99 Declaration of variable NUM with value 99

Test Data Expected Outcome Actual Outcome1 I am going to enter 1 as the

first number 1 should come out and the program should count down in increments of 2 until it reaches 99

As expected

2 I am going to enter 57 as the first number

57 should come out and the program should count down in increments of 1 until it reaches 99

As expected

Page 19: GCSE Computing

Video Counting prog and testing counting up from a user defined no to 99 in increments of 2

I have produced a video called countprog1TO99ODDNOS which I have embedded here and have included with this portfoilio

Page 20: GCSE Computing

For the second task I have been given a number of programming tasks to tackle1) Write programs to run in LMC: a) Produce a multiplication table from 1 to 10 for any number input by the user b) Modify this program so that a user can enter a value and it produces the square of that number for example if the user entered 5 it would produce 25c) Modify the program so that a can user can enter a value and it produces the cube of that number for example if the user entered 2 it would produce the number 8 (which is 2*2*2)(d) Produce evidence to show that you have planned, written and tested your code.(e) Produce an evaluation of your solutions. 2) Write a conclusion about the possibility of writing effective and complex programs with only a limited instruction set.

Page 21: GCSE Computing

a) Produce a multiplication table from 1 to 10 for any number input by the user

Start

Input a first number and store in Number1

Subtract the contents of the accumulator by the contents in memory location ONE

Input a number

Store the result of this in memory location number2

Load the contents of storage location RESULTS into the accumulator

Add the contents of number1 into the accumulator

Store the result into memory location RESULT

Load the contents of memory location TWO and load this into the accumulator

subtract the contents of this by the contents in memory location ONE

Store the result into memory location Number2

Is the result positive?

yesLoad the contents of result into the accumulator and display in the output boc

End

Page 22: GCSE Computing

INP Input a number

STA NUMBER1 store this number in memory location number1

INP Input a number

SUB ONE subtract the contents of this by the contents in memory location ONE

STA NUMBER2 store this number in memory location number2

LOOPTOP LDA RESULT load the contents of store location result and load this into the accumulator

ADD NUMBER1 add the contents of memory location number1

STA RESULT store the result of this into memory location result

LDA NUMBER2 load the contents of store location number2 and load this into the accumulator

SUB ONE subtract the contents of this by the contents in memory location ONE

STA NUMBER2 store this number in memory location number2

BRP LOOPTOP is the result postive? If yes go back to top of looptop and load result again

LDA RESULT if no load the result into the accumulator

OUT output this result to the accumulator

HLT end the program

BRA LOOPTOP

ONE DAT 001 ONE memory location declared initialised

NUMBER1 DAT Number 1 memory location declared

NUMBER2 DAT Number 2 memory location declared

RESULT DAT 000 Result memory location declared initialised

Test Data Expected Outcome Accepted outcome 1 I am going to enter

12 in memory location number1 and 12 in memory location 2

The program will add 12 together 12 times and will display 144 in the accumulator at the end

As expected

2 I am going to enter 12 in memory location number1 and 12 in memory location 2

The program will add 9 together 8 times and will display 72 in the accumulator at the end

As expected

Page 23: GCSE Computing

a) Produce a multiplication table from 1 to 10 for any number input by the user

I have produced a video called mulplicationof2nos. which I have embedded here and have included with this portfoilio

Page 24: GCSE Computing

b) Modify this program so that a user can enter a value and it produces the square of that number for example if the user entered 5 it would produce 25

INP Input a number STA FIRST store this number in memory location FIRSTSTA SECOND store this number in memory location SecondSUB ONE subtract the contents of this by the contents in memory location ONE STA SECOND store this number in memory location SecondLDA FIRST load the contents of store location First and load this into the accumulator LOOPTOP ADD FIRST add the contents of memory location FirstSTA RESULT store the result of this into memory location resultLDA SECOND load the contents of store location Second and load this into the accumulator SUB ONE subtract the contents of this by the contents in memory location ONE STA SECOND store this number in memory location SecondBRZ LOOKIFZERO is the result zero? If no go back to top of looptop and load result againLDA RESULT if no load the result into the accumulator BRA LOOPTOP output this result to the accumulator LOOKIFZERO LDA RESULT if second is zero load the result into the accumulator and outputOUT STA RESULT Store the contents of the accumulator into the memory location resultsHLT end the program FIRST DAT First memory location declaredSECOND DAT Second memory location declaredONE DAT 1 one memory location declared and initialised RESULT DAT Result memory location declared initialised

Test Data Expected Outcome Accepted outcome 1 I am going to enter 6 The program will add 6 together 6 times and

will display 36 in the accumulator at the end As expected

2 I am going to enter 31

The program will add 31 together 31 times and will display 961 in the accumulator at the end This is the highest that the LMC could display using this program

As expected

Page 25: GCSE Computing

I have produced a video called squareof2nos. which I have embedded here and have included with this portfoilio

b) Modify this program so that a user can enter a value and it produces the square of that number for example if the user entered 5 it would produce 25

Page 26: GCSE Computing

c) Modify the program so that a can user can enter a value and it produces the cube of that number for example if the user entered 2 it would produce the number 8 (which is 2*2*2)

INP Input a number

STA FIRST store this in memory location first

STA COUNTER store this in memory location counter

SUB ONE subtract this from the contents held in memory location one

STA COUNTER store this in memory location counter

LDA FIRST load the contents of memory location FIRST into the accumulator

LOOPTOP ADD FIRST add the contents of memory location FIRST into what is currently in the accumulator

STA RESULT store this number in memory location result

LDA COUNTER load the contents of memory location Counter into the accumulator

SUB ONE subtract this from the contents held in memory location one

STA COUNTER store this number in memory location counter

BRZ LOOKIFZERO is this result zero?

LDA RESULT no load the result into the accumulator

BRA LOOPTOP go back to looptop

LOOKIFZERO LDA RESULT if counter = 0, load the contents in memory location result into the accumulator

OUT and display in out box

Page 27: GCSE Computing

Prog C continued STA RESULT Store this number in memory location result LDA FIRST load the contents of memory location FIRST into the accumulator STA COUNTER store this in memory location counterLDA RESULT load the contents of memory location result into the accumulator STA number Store this number in memory location numberLOOPTOP1 LDA result load the contents of memory location result into the accumulator ADD NUMBER add the contents of memory location NUMBER into what is currently in the accumulatorSTA result Store this number in memory location RESULTLDA Counter load the contents of memory location counter into the accumulator SUB ONE subtract this from the contents held in memory location oneSTA counter store this in memory location counterBRZ LOOKUP is this result zero?LDA RESULT load the contents of memory location result into the accumulator SUB NUMBER subtract this from the contents held in memory location NUMBERBRA LOOPTOP1 go back to looptop1LOOKUP LDA RESULT if counter = 0, load the contents in memory location result into the accumulator SUB NUMBER subtract this from the contents held in memory location NUMBEROUT Send this to the outboxHLT end the program FIRST DAT First memory location declared where inital number to be processed is declaredCounter DAT Counter memory location declaredONE DAT 1 one memory location declared and initialised RESULT DAT Result memory location declared initialised Number DAT Number memory location declared where result of first calculation is stored

Page 28: GCSE Computing

Test Data Expected Outcome Accepted outcome 1 I am going to

enter 2The program add 2 to together 2 times giving a result of 4 and take that result and perform the same calculation again leaving a result of 8

As expected

2 I am going to enter 9

The program will add 9 together 9 times giving a result of 81 and will perform the same calculation again giving a result of 729

As expected

Testing stage

Page 29: GCSE Computing

Modify the program so that a can user can enter a value and it produces the cube of that number for example if the user entered 2 it would produce the number 8 (which is 2*2*2)

I have embedded a video which shows the results of the program being run testing 2 * 2 * 2 and 9 * 9 * 9. This is also available as a standalone video called cubeof1nos

Page 30: GCSE Computing

(e) Produce an evaluation of your solutions and (f) Write a conclusion about the possibility of writing effective and complex programs with only a limited instruction set. .

For each of the programs I have as produced detailed code and shown my solution through the videos which are attached to this presentation and have been submitted as standalone products. In each case I have tested the programs at the extreme ends of what the LMC simulator is capable of doing.

The LMC is limited in its functionality as this will support numbers upto a 1000, will not accept decimal or real numbers or data types and can only perform limited arithmetic operations namely addition and division. This is a severely limiting factor on the use of the LMC but this does highlight the basic principles of machine architecture in that it shows the fetch execute cycle in action and the respective role of the registers.

If the LMC or programs like it were to be used for the calculations then a lot of processing is going to be undertaken by the program and the result will not be as accurate owing to its (the LMC’s) operation when compared to modern software applications and high level programming compilers

Page 31: GCSE Computing

Bibliography

Slide 2 Definitions and ideas taken from Wikipedia and adapted Slide 3 Instruction set taken from http://www.atkinson.yorku.ca/~sychen/research/LMC/LMCHome.html