Presentation is loading. Please wait.

Presentation is loading. Please wait.

1. 2 TimeActivity 9:45Welcome and introductions 10:00What is a computer? 10:15What’s inside? 10:45Activity: A simple view of how computers work 11:15Coffee/tea.

Similar presentations


Presentation on theme: "1. 2 TimeActivity 9:45Welcome and introductions 10:00What is a computer? 10:15What’s inside? 10:45Activity: A simple view of how computers work 11:15Coffee/tea."— Presentation transcript:

1 1

2 2

3 TimeActivity 9:45Welcome and introductions 10:00What is a computer? 10:15What’s inside? 10:45Activity: A simple view of how computers work 11:15Coffee/tea break 11:30How a computer executes instructions 12:15Using the Little Man Computer Simulator 12:45Lunch 13:45Exercises: Practise low-level programming 14:30Coffee/tea break 14:45High-level and low level programs 16:00Evaluation and end of day 3

4 4

5 5

6 6

7 Exercise taken from: http://cse4k12.org/how_computers_work/

8 8

9 9 The control unit is one of the most important parts of a microprocessor for the reason that it is in charge of the machine cycle. The CPU deals with each instruction it is given in a series of steps. Each step is repeated for each instruction. This series of steps is called the fetch-execute cycle. It involves: fetching an instruction from memory; decoding the instruction; transferring the data; executing the instruction.

10 10

11

12 12 Fetch Execute Decode

13 13

14 14 1. Little Man reads the address from the location counter 2. He walks over to the mailbox that corresponds to the location counter

15 15 3. And reads the number on the slip of paper (he puts the slip back in case he needs to read it again later)

16 16 1. The Little Man goes to the mailbox address specified in the instruction he just fetched. 2. He reads the number in that mailbox (he remembers to replace it in case he needs it later).

17 17 3. He walks over to the calculator and punches the number in. 4. He walks over to the location counter and clicks it, which gets him ready to fetch the next instruction.

18 18 check the Program Counter for the mailbox number that contains a program instruction (e.g. zero) fetch the instruction from the mailbox with that number increment the Program Counter (so that it contains the mailbox number of the next instruction) decode the instruction (includes finding the mailbox number for the data it will work on) (say it says get data from box 42) fetch the data from the mailbox with the number found in the previous step (for example, store the data in the accumulator) execute the instruction store the new data in the mailbox from which the old data was retrieved repeat the cycle or halt

19 19 Numeric code Mnemonic codeInstruction 1xxADD 2xxSUBSUBTRACT 3xxSTASTORE 5xxLDALOAD 6xxBRABRANCHBRANCH (unconditional) 7xxBRZBRANCH IF ZERO (conditional)conditional 8xxBRPBRANCH IF POSITIVE (conditional) 901INPINPUT 902OUTOUTPUT 000HLTHLT/COBHALT/COFFEE BREAK DATDATA

20 20 IN OUT Op Code Operand (address) INP (input) 901 OUT (output) 902 Slides adapted from herehere

21 21 LDA STO Op Code Operand (address) STA (store) 3xx LDA (load) 5xx

22 22 ADD SUB Op Code Operand (address) ADD1xx SUB2xx

23 23 Input a number Store the number Input a number Add Output the number

24 24 MailboxMnemonicInstruction Description 00INPInput 1 st Number 01STA :NUMstore data at position NUM 02INPinput 2 nd Number 03ADD 99add 1 st # to 2 nd # 04OUToutput result 05HLTstop 06NUM:data label

25 25

26 26 1. Enter program here 2. Compile and load 3. Run program, 4. Instructions appear in the “mailboxes”

27 27 MnemonicInstruction Description INP; input a number OUT; output result HLT; stop

28 28

29 29 Numeric code Mnemonic codeInstruction 1xxADD 2xxSUBSUBTRACT 3xxSTASTORE 5xxLDALOAD 6xxBRABRANCHBRANCH (unconditional) 7xxBRZBRANCH IF ZERO (conditional)conditional 8xxBRPBRANCH IF POSITIVE (conditional) 901INPINPUT 902OUTOUTPUT 000HLTHLT/COBHALT/COFFEE BREAK DATDATA

30 30

31 31

32 32

33 33

34 34 INP //value to subtract STA :FIRST INP // to subtract from SUB :FIRST OUT HLT FIRST: // data item

35 35

36 36

37 37

38 38

39 39

40 40

41 41 START: LDA :ZERO STA :RESULT STA :COUNT INP BRZ :END STA :VALUE LOOP: LDA :RESULT ADD : STA :RESULT LDA :COUNT ADD :ONE STA :COUNT SUB :VALUE BRZ :ENDLOOP BRA :LOOP ENDLOOP: LDA :RESULT OUT BRA :START END: HLT RESULT: COUNT: ONE: 1 / VALUE: ZERO: 1. What does this low-level program do? 2. Add comments then get working in LMC 3. Implement in a high level language What are the differences?

42 42

43 43

44 44

45 45


Download ppt "1. 2 TimeActivity 9:45Welcome and introductions 10:00What is a computer? 10:15What’s inside? 10:45Activity: A simple view of how computers work 11:15Coffee/tea."

Similar presentations


Ads by Google