Robust programs · GCSE · OCR J277 2.5.1, AQA 8525 3.4.4, Edexcel 1CP2 3.3.1 · about 20 min
High and low level, machine code and assembly; compilers, interpreters and assemblers.
[1 mark]Why must a Python program be translated before it runs?
[1 mark]Which translator turns assembly language into machine code?
[1 mark]Which translator produces a standalone file that runs without it?
[1 mark]Why is an interpreter useful while developing a program?
[1 mark]Which are features of low-level languages?
Tick every answer that is true.
[1 mark]The robot assembly program is LOAD 4, FWD 20, TURN 90, BEEP 660, DEC, JNZ 1, HALT. How many beeps does it play?
Finish the interpreter so it runs the robot assembly program below, which uses LOAD, DEC and JNZ to drive a square with a beep at each corner. Store the value of R in a variable, and make JNZ change the program counter.
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
program = ["LOAD 4", "FWD 20", "TURN 90", "BEEP 660", "DEC", "JNZ 1", "HALT"]
pc = 0
while True:
op, *args = program[pc].split()
if op == "FWD":
forward(60, distance=int(args[0]))
elif op == "TURN":
turn_right(30, angle=int(args[0]))
elif op == "HALT":
break
pc = pc + 1Plan your program here, then type it in and press Run.
WAIT n instruction, and write an assembly program that flashes a beep three times.JMP a, an unconditional jump. What happens if a program jumps back with no way to stop?