Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Lab Questi ons - type your answers here rite instructions to store the digits 0-

ID: 3590432 • Letter: L

Question

Lab Questi ons - type your answers here rite instructions to store the digits 0-9 in locations starting at $1200 using the ORG and DC.B directives. Start with an thw program shell. Run the following code in Code Warrior and fill out 2. e. In the "Assembly" window, right click and choose Format->hex, right- click again and choose Display Code LOOP CLRA LDX #$1500 STAA 0, X STAA PORTB STAA $1500 BRA LOOP Addressing Mode Instruction IP Address Opcode Operand CLRA LDX #$1500 STAA 0, X STAA PORTB STAA $1500 BRA LOOP 3. Does the STAA instruction always have the same opcode? If not, why do you think it differs? 4. Is the operand for the BRA instruction above a positive or negative number? What does this number mean in terms of branching?

Explanation / Answer

3. The opcode for the STAA instruction will always be A (Accumulator)
as the instruction itself states that STAA means store the content of Accumulator to the memory location specified in the operand.
Operands may differ for the different instructions, I.e., the operand may be direct memory location or indirect memory location etc.,
Examples:
a. LDAA #$80 loads the A register with the hex number $80
b. STAA #$1000 stores the contents of the A register at memory location $1000. etc.,

4. BRA Loop instruction:
The operand of this instruction will be negative,
Explanation: here the operand will the displacement between the program counters of address of "loop" to the program counter address of current instruction. On this case the loop address will be smaller and he program counter of the BRA instruction is higher. The difference will always be negative. So the operand will the negative
Let us assume the IP address for CLR A is 100 and thd IP address for the BRA will be around 116(approx) when the BRA going to be execute, the difference 100- 116 will be the operand i.e operand will be -16. While branching the operand value will be added to the current IP address value and branched to the resultant IP address. In this case -16 will add to 116 and the result is 100 and it will branch to the 100 address location.

I hope this is clear, Feel free to comment if you have a doubt.

Please rate it if you find the answer is helpful.... Thanks....:)