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

In this problem I am suppose to find the answer to PC, A, B, X, Y, and SP. I alr

ID: 2266436 • Letter: I

Question

In this problem I am suppose to find the answer to PC, A, B, X, Y, and SP. I already have the answers, but can someone please explain how to get those answers.

8) (12 pts) Refer to the program listing below. ORG FCB ORG $0200 $86, $75, $64,$53, $42, $31 SB600 00000200 DATA 2 3: 4: 5: 6: 0200 86 75 64 53 42 31 =0000B600 B600 8E 0047 B603 CE 0200 B606 A6 03 B608 16 B609 18FE 0200 B60D 36 B60E 3C B60F D6 45 B611 1B B612 26 FA 3, X LDAA TAB LDYn $020068 8b7S 3471553 8: 9: 10: PSHA PSHX LDAB ABA BNE END LOOP $45.CB 12: 13: 14: After executing instruction 13 (BNE LOOP) for the first time, what will be the contents (in Hex) of the internal registers? If you cannot determine the content of a register, use "??". [A] = [B] = [X] = [Y] = 7 [SP] =

Explanation / Answer

ORG directive declares DATA from 0200 memory location and codes from B600. Can see machine instruction generated by the assembler.

FCB stands for “Form Constant” Byte in line 2 and represented by DATA literal. The bytes are 86, 75, 64, 53, 42 and 31. All are in hex and first byte at 0x0200

Address

Data byte in Hexadecimal form

0x0200

86

0x0201

75

0x0202

64

0x0203

53

0x0204

42

0x0205

31

Now let us discuss program/Instructions sequentially:

Line No.

Instruction

Description

4

LDS #$47

Initialize stack pointer with hex 47

5

LDX #DATA

Initialize stack pointer with 0200

6

LDAA 3, X

Load200 Accumulator by memory contents whose address is 0200 + 3

7

TAB

Transfer A to B register , Hence A = B = (53)16

8

LDY $0200

Load Index register Y with contents of 0200 and 0201, Y = 16 bit reg.

9

PSHA

Push A register contents on Stack pointed by [SP – 1]. [46] = A, SP = SP-1

10

LOOP PSHX

Push index register X contents (0200) on SP and SP-1 location. i.e. 45 and 44. [45] = 02 & [44] = 00

11

LDAB $45

Load B with contents of memory location 45. On 45, X register content (0200) is stored in 45 and 44 location.

12

ABA

Add accumulators A + B and save in A. 53 + 02 = (55)16

13

BNE LOOP

Branch back if not zero. PC gets new address that is B60E. Loop is literal

14

END

Assembler directive to indicate end of program

Few points,

A and B are 8-bit accumulator registers whereas X & Y are 16 bit index registers.

While pushing data on stack, first Stack pointer decrements and then data is stored on stack. Whereas popping from stack is first read and then increment SP.

In 16 bit data, first MSB/LSB can be stored / retrieved based on little/big endian.

Address

Data byte in Hexadecimal form

0x0200

86

0x0201

75

0x0202

64

0x0203

53

0x0204

42

0x0205

31

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote