Presentation is loading. Please wait.

Presentation is loading. Please wait.

Question 21 - Exercise 1 List any improvements for the following code segment: load(length) sub(fifty) bgt0(false) load(four) store(height) ba(done) label(false)

Similar presentations


Presentation on theme: "Question 21 - Exercise 1 List any improvements for the following code segment: load(length) sub(fifty) bgt0(false) load(four) store(height) ba(done) label(false)"— Presentation transcript:

1 Question 21 - Exercise 1 List any improvements for the following code segment: load(length) sub(fifty) bgt0(false) load(four) store(height) ba(done) label(false) load(eight) store(height) ba(done) label(done) print(height) halt end(start)

2 Question 21 - Exercise 1 List any improvements for the following code segment: load(length) sub(fifty) bgt0(false) load(four) ba(done) label(false) load(eight) ba(done) label(done) store(height) print(height) halt end(start)

3 Question 21 - Exercise 1 List any improvements for the following code segment: load(length) sub(fifty) bgt0(false) load(four) ba(done) label(false) load(eight) ba(done) label(done) store(height) print(height) halt end(start)

4 Question 21 - Revised List any improvements for the following code segment: load(length) sub(fifty) bgt0(false) load(four) ba(done) label(false) load(eight) label(done) store(height) print(height) halt end(start)

5 Question 21 - Exercise 2 Give the output of the following code segment (length=60, width=30): load(length) sub(fifty) bgt0(true) load(four) store(height) label(true) load(eight) store(height) label(done) print(height) halt end(start)

6 Question 21 - Exercise 3 Given the following code segment: load(length) sub(fifty) ble0(other) load(eight) store(height) label(other) load(four) store(height) print(height) What is the output for length = 30, width = 70? length = 70, width = 60?

7 Question 21 - Exercise 4 Give the output of the following code segment (length=60, width=30): load(length) sub(fifty) bgt0(false) load(4) store(height) label(false) load(8) store(height) label(done) print(height) halt end(start)

8 Question 21 - Exercise 5 label(start) load(length) sub(fifty) store(length) ble0(true) load(length) bgt0(false) label(true) load(four) store(height) label(false) load(eight) store(height) label(done) print(height) Unnecessary; length is in the accumulator

9 Question 21 - Exercise 5 label(start) load(length) sub(fifty) store(length) ble0(true) bgt0(false) label(true) load(four) store(heght) label(false) load(eight) store(height) label(done) print(height)

10 Question 22 - Exercise 1 label(start) label(loop) load(b) sub(onehundred) bgt0(done) load(a) add(b) store(a) load(b) add(one) store(b) ba(loop) label(done) print(a)

11 Question 22 - Exercise 2 label(start) label(loop) load(b) sub(onehundred) blt0(done) load(a) add(b) store(a) load(b) add(one) store(b) ba(loop) label(done) print(a)

12 Question 22 - Exercise 3 label(start) load(a) add(b) store(a) load(b) add(one) store(b) label(loop) load(b) sub(onehundred) bge0(done) load(a) add(b) store(a) load(b) add(one) store(b) ba(loop)


Download ppt "Question 21 - Exercise 1 List any improvements for the following code segment: load(length) sub(fifty) bgt0(false) load(four) store(height) ba(done) label(false)"

Similar presentations


Ads by Google