(a) Address 500 contains the value 100 and address 100 contains the value 20. State the addressing mode and the contents of ACC after LDM #500, LDD 500 and LDI 500. (b) Using only the given instructions, write assembly code to store the constant 20, add it to the value stored in the address contained in variable Y, and store the result in variable Z.
Points that gain marks
- (a) LDM #500: immediate addressing, ACC = 500.
- LDD 500: direct addressing, ACC = 100.
- LDI 500: indirect addressing, ACC = 20.
- (b) LDM #20, then STO Twenty: the constant is stored at a labelled address away from the program code.
- LDI Y loads the value at the address held in Y.
- ADD Twenty adds the constant, using the labelled address.
- STO Z stores the result; Y and Z are labelled addresses away from the code.
In this lab: 'Trace table: four ways to load' compares the addressing modes; 'Exam: constant + pointer' is part (b).