Computer architecture · A level · OCR H446 1.2.4, AQA 7517 4.7.3.3, Eduqas A500QS 2.1 · about 20 min
Opcodes, operands and instruction formats; immediate, direct, indirect and indexed addressing.
[1 mark]Address 30 holds 45 and address 45 holds 8. The operand is 30. What value does indirect addressing use?
[1 mark]Which addressing mode is best suited to stepping through an array in a loop?
[1 mark]In immediate addressing, the operand is...
[1 mark]An instruction is 16 bits: 5 bits of opcode and 11 bits of operand. What is the largest address direct addressing can reach?
[1 mark]Why will a program compiled for an x86 processor not run on an ARM processor?
[1 mark]An 8-bit instruction has a 4-bit opcode then a 4-bit operand. What does this print?
instruction = 0b10110110 print(instruction >> 4, instruction & 0b1111)
Memory is the list memory (addresses 0 to 9) and the index register ix holds 2. Write operand_value(mode, operand):
- mode is one of the strings "immediate", "direct", "indirect" or "indexed";
- operand is a whole number from 0 to 9;
- it returns the value an instruction would use in that mode, as defined in the table above.
For each operand in [2, 5], and for each mode in the order immediate, direct, indirect, indexed, print a line in the form direct 2 -> 1: the mode, the operand, ->, then the value. That is eight lines. The robot does not move.
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
memory = [4, 7, 1, 9, 5, 3, 8, 0, 6, 2]
ix = 2
def operand_value(mode, operand):
return operandPlan your program here, then type it in and press Run.