Assembly Language Worksheet
Assembly Language Worksheet
1 (a) The current contents of main memory and selected values from the ASCII character set are
given.
(i) Trace the program currently in memory using the trace table.
ASCII
Character
value
49 1
50 2
51 3
52 4
65 A
66 B
67 C
68 D
[Turn over
[4]
2
Instruction
Explanation
Opcode Operand
LDD <address> Direct addressing. Load the contents of the location at the given
address to ACC
STO <address> Store contents of ACC at the given address
LDD 100
STO 165
LDD 101
STO 100
LDD 165
STO 101
...........................................................................................................................................
...........................................................................................................................................
[1]
3
(b) The following table shows another part of the instruction set for the processor.
1 0 0 1 0 0 1 1
XOR B00011111
...........................................................................................................................................
...........................................................................................................................................
[1]
1 0 0 1 0 0 1 1
AND B11110000
...........................................................................................................................................
...........................................................................................................................................
[1]
(iii) The current contents of the ACC are:
1 0 0 1 0 0 1 1
OR B11001100
...........................................................................................................................................
...........................................................................................................................................
[1]
(iv) The current contents of the ACC are:
1 0 0 1 0 0 1 1
LSR #2
...........................................................................................................................................
...........................................................................................................................................
[1]
(c) Tick (3) one or more boxes in each row to indicate whether the task is performed in the first
pass or the second pass of a two-pass assembler.
Remove comments.
[2]
5
2 (a) There are two errors in the following register transfer notation for the fetch‑execute cycle.
1 MAR [PC]
2 PC [PC] − 1
3 MDR [MAR]
4 CIR [MDR]
Line
Description of the error Correct statement
number
[4]
6
3 The following table shows part of the instruction set for a processor. The processor has one
general purpose register, the Accumulator (ACC) and an Index Register (IX).
Instruction
Op code Op code Explanation
Operand
(mnemonic) (binary)
Immediate addressing. Load the denary number n to
LDM #n 0000 0001
ACC.
Direct addressing. Load the contents of the location
LDD <address> 0000 0010
at the given address to ACC.
Indirect addressing. At the given address is the
LDI <address> 0000 0101 address to be used. Load the contents of this second
address to ACC.
Indexed addressing. Form the address from
<address> + the contents of the Index Register
LDX <address> 0000 0110
(IX). Copy the contents of this calculated address to
ACC.
LDR #n 0000 0111 Immediate addressing. Load number n to IX.
STO <address> 0000 1111 Store the contents of ACC at the given address.
The following diagram shows the contents of a section of main memory and the Index Register (IX).
(a) Show the contents of the Accumulator (ACC) after each instruction is executed.
IX 0 0 0 0 0 0 1 1
Main
(i) LDM #500
Memory
Address contents
ACC ................................................................[1]
495 13
(ii) LDD 500
496 86
ACC ................................................................[1] 497 92
(b) Each machine code instruction is encoded as 16-bits (8-bit op code followed by an 8-bit
operand).
LDM #17
LDX #97
[3]
(c) Using an 8-bit operand, state the maximum number of memory locations, in denary, that can
be directly addressed.
...............................................................................................................................................[1]
0 0 0 0 0 1 1 1 1 1 0 0 0 0 1 0
.......................................................................................................................................[2]
05 3F
Write the equivalent assembly language instruction, with the operand in denary.
.......................................................................................................................................[2]
(c) The table shows assembly language instructions for a processor which has one general
purpose register, the Accumulator (ACC), and an Index Register (IX).
Instruction
Explanation
Op code Operand
LDM #n Immediate addressing. Load the denary number n to ACC.
Direct addressing. Load the contents of the location at the given address to
LDD <address>
ACC.
Indexed addressing. Form the address from <address> + the contents of the
LDX <address>
Index Register. Copy the contents of this calculated address to ACC.
LDR #n Immediate addressing. Load the denary number n to IX.
STO <address> Store contents of ACC at the given address.
ADD <address> Add the contents of the given address to ACC.
INC <register> Add 1 to the contents of the register (ACC or IX).
CMP #n Compare contents of ACC with denary number n.
JPE <address> Following a compare instruction, jump to <address> if the compare was True.
JPN <address> Following a compare instruction, jump to <address> if the compare was False.
JMP <address> Jump to the given address.
OUT Output to screen the character whose ASCII value is stored in ACC.
END Return control to the operating system.
The current contents of the main memory, Index Register (IX) and selected values from the
ASCII character set are:
IX 0
Trace the program currently in memory using the following trace table. The first instruction
has been completed for you.
65 67 69 69 68 33 0
20 0
[8]