Presentation is loading. Please wait.

Presentation is loading. Please wait.

central heating system

Similar presentations


Presentation on theme: "central heating system"— Presentation transcript:

1 central heating system
eReader Lego® Mindstorms® robot Starter car Where can a microprocessor be found? smart glasses Raspberry Pi® smartphone tablet fitness band digital TV washing machine camera games console central heating system

2 Assembly Language 4.2.3

3 Learning Objectives 4.2.3 Understand the function of assembly code and
be able to interpret a block of assembly code using a given set of commands Teacher: Make sure there are paper or on-line accessible copies of assembly language mnemonics

4 Assembly Language What is it? What does it look like?
How is it connected to what I know?

5 Assembly Language: What is it?
Can you name some? Easy or difficult for humans to read or understand? High level languages Python, Java, JavaScript, Scratch, Lego Mindstorms Humans can easily read the words/symbols Assembly languages Use mnemonics (abbreviations) in place of words Lets programmers manipulate data directly in registers Machine code Binary digits 0s and 1s, all strung together Difficult for humans to interpret Easy or difficult for humans to read or understand? What is a register? Where are registers? What does it look like? Easy or difficult for humans to read or understand? More on why we use assembly languages in next lesson.

6 Assembly Language: What does it look like?
Use mnemonics (abbreviations) instead of words Programmers manipulate data directly in registers What is MOV a mnemonic for? SUB? MUL? ADD? What could R3 be the name for? R1? R2? MOV R3, #5 SUB R1, R1, #2 MUL R0, R1, R3 ADD R1, R1, R3 MOVE SUBTRACT MULTIPLY ADD Register 3 Register 1 Register 2 Mnemonic What could the # symbol mean? You can already read assembly code That means the denary value 5, as opposed to R5. More in a minute on how these instructions are put together.

7 Assembly Language: Why two parts?
Operation code ‘Opcode’ Operation to perform Operands Items to act upon or use Opcode Operands Means Possible Machine Code MOV R3, #5 R3 = 5 SUB R1, R1, #2 R1 = R1 - 2 MUL R0, R1, R3 R0 = R1 * R3 ADD R1, R1, R3 R1 = R1 + R3

8 Assembly Language: How is it connected to what I already know?
MOV R3, #5 SUB R1, R1, #2 MUL R0, R1, R3 ADD R1, R1, R3 Each assembly language line is exactly one instruction in memory The fetch-decode-execute cycle deals with exactly one instruction at a time The fetch moves instruction and data from memory to registers The arithmetic logic unit performs the operation Remember this diagram? Remember the jobs of the different parts?

9 Specification Page 42-44 You do need to know how to read these instructions. You do not need to memorise them. The tables will be reproduced for you in the exam paper, like formulas.

10 Example: 11 + 22 The assembly code The assembly mnemonics
A trace table Line R3 R4 Line R3 R4 2 11 3 33 Can you fill it in? A blank cell means that no change has taken place. Teacher Guide

11 Your Turn – Simple Example
5 min Your Turn – Simple Example A trace table Line R2 R3 R4 Line R2 R3 R4 7 3 8 4 9 12 10 6 11 18 The assembly code What arithmetic expression is this? 3 * = 18 The assembly mnemonics

12 Branching – Changing flow control
Jumping around blocks of code not to be executed Like an ‘if’ statement Jumping to blocks of code that need executing Like calling a ‘subprogram’ The destination line has a label, like ‘LABEL1:’ or ‘TOP:’

13 Labels: Destination for next instruction
5 min Your Turn - Branching Complete the trace table What did you find? The assembly code Line R3 R4 13 11 14 33 15 Line R3 R4 Labels: Destination for next instruction B always branches, so this code loops forever.

14 Conditional Branching
The CMP should be followed by a BRANCH To check the condition, an extra mnemonic is added to the B for Branch BEQ indicates a ‘Branch If Equal’ condition BGT indicates a ‘Branch If Greater’ condition Comments are bounded by /* and */ Example: /* This is a comment */

15 Conditional Branching – Selection (IF)
5 min Conditional Branching – Selection (IF) Complete the trace table Line R2 R3 19 20 5 21 10 22 23 9 27 Line R2 R3 The assembly code What is the final value in R2? 9 This is the equivalent pseudo-code: Teacher: Make sure there are paper or on-line accessible copies of assembly language mnemonics

16 Conditional Branching – Repetition (LOOP)
5 min Conditional Branching – Repetition (LOOP) Line R1 R2 38 3 39 40 41 2 42 43 5 1 6 44 Line R1 R2 The assembly code Complete the trace table What is the final value in R2? 6 Why have we put in numbers of lines that didn’t change register contents? This is the equivalent pseudo-code: So we can see flow of the program. Teacher: Make sure there are paper or on-line accessible copies of assembly language mnemonics

17 Plenary ADD R1,R2,R3 What are these shortened words, like ADD called?
Mnemonic Which is the opcode? ADD Which are the operands? R1,R2,R3 What does this instruction do? Adds R2 and R3, then puts it into R1 Translate this instruction to pseudo-code. R1 = R2 + R3 ADD R1,R2,R3

18 The assembly mnemonics
Comments are bounded by /* and */ Example: /* This is a comment */


Download ppt "central heating system"

Similar presentations


Ads by Google