- What is the difference between direct and indirect addressing?
- Direct addressing: the operand is an address where the data is stored, so LDD 20 loads the contents of address 20. Indirect addressing: the operand is an address that stores the address where the data is stored, so LDI 25 goes to address 25, reads an address from it and loads the contents of that second address.
- What does the first pass of a two-pass assembler do?
- In the first pass the assembler reads the source code one line at a time, removes white space and adds labels to the symbol table. The purpose of the first pass is to create a symbol table. Generating object code is a second-pass action, so it is not the purpose of the first pass.
- How does indexed addressing work in assembly language?
- The address used is the operand plus the contents of the index register IX, so address used = operand + [IX]. For example, with IX holding 1, LDX 22 loads the contents of address 23 into the ACC. Indexed addressing adds the contents of IX to the operand before the data is accessed.
- How do I trace a program using a trace table?
- Execute the program one instruction at a time and make one row of the trace table for each instruction that runs, in the order it runs. A jump changes which address comes next, so some addresses are skipped. Fill a cell only when the instruction changes it, and use the Output column for OUT only.
- What does relative addressing do, and why is it useful?
- In relative addressing the address to be used is an offset number of locations away from a base address, so address = base address + offset. Its purpose is to allow re-locatable code, because all target addresses can be specified by the base address plus the offset.
- Does LDX 110 load the number 110 into the accumulator?
- No. LDX 110 is indexed addressing, so it loads the contents of address 110 + [IX] into the accumulator. A common incorrect result of the first LDX 110 instruction was to load 110 into the accumulator, which then gave an incorrect value stored in memory address 101.