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

Please interpret this code and fill in the missing comments by decoding the give

ID: 639869 • Letter: P

Question

Please interpret this code and fill in the missing comments by decoding the given instructions.

*****Given Instructions*****

#define HALT 0 /* halt the machine */

#define LOAD 1 /* load accumulator from memory */

#define STORE 2 /* store accumulator to memory */

#define ADDC 3 /* add counter to accumulator */

#define MVAC 4 /* move accumulator to counter */

#define JEQ 5 /* jump to address if counter equals 0 */

#define JLT 6 /* jump to address if counter is less than 0 */

#define JMP 7 /* jump to address */ #define ADD 8 /* accumulator = memory + accumulator */

#define SUB 9 /* accumulator = memory - accumulator */

#define DEC 0xA /* decrement counter */

/* LA takes the memory address from the instruction and loads it into the accumulator (load address) */

#define LA 0xB

/*LIA uses the memory address in the areg to load memory into the accumulator (load indirect address) */

#define LIA 0xC

/* SIA stores the value in the accumulator in the memory address found in the areg (store indirect address) */

#define SIA 0xD

/* MVAA moves the value in the accumulator to the areg */

#define MVAA 0xE

*****Interpret This Code & Fill in the Blanks*****

#
# this program sums an array.
# the instr area and data area are
# separated by a few nulls
#
0xb000   # LA 0 [0]
0x2012   # STORE RESULT   # result set to zero
0xb001   # LA 1
0x9011   # SUB NITEMS
0x4000   # MVAC [4]           # ctr is initialized with NITEMS-1
0x600e   # loop: JLT END   # if (ctr < 0) goto END
0xb013
0x3000
0xe000 # [8[
0xc000
0x8012
0x2012
0xa000
0x7005
0x0 # [0xe]
#
# the offset is 15(0xF) here. The data area starts
# at 0x11, so we need two pad words
# these come in handy if we need more instructions.
0x0000
0x0000
#
# the data area: offset is 0x11
#
0x0008 # NITEMS: The number of elements
0x0000 # RESULT:
0x0004 # (ADDR=0x13)array[0]
0x0008 # array[1]
0x0010 # array[2]
0x0040 # array[3]
0xFFFD # array[4]
0x0009 # array[5]
0xFEDC # array[6]
0x0120 # array[7]

Explanation / Answer

0000   0B         ???
0001   00         BRK
0002   0A         ASL A
0003   00         BRK
0004   02         ???
0005   01 2E      ORA ($2E,X)
0007   EE EE 0B   INC $0BEE
000A   00         BRK
000B   1A         ???
000C   10 90      BPL $FF9E
000E   11 BE      ORA ($BE),Y
0010   04         ???
0011   00         BRK
0012   0A         ASL A
0013   C4 CA      CPY $CA
0015   ED E1 06   SBC $06E1
0018   00         BRK
0019   EE DF C0   INC $C0DF
001C   ED 0B 01   SBC $010B
001F   30 30      BMI $0051
0021   00         BRK
0022   0E 00 08   ASL $0800
0025   0C         ???
0026   00         BRK
0027   00         BRK
0028   80         ???
0029   12         ???
002A   02         ???
002B   01 20      ORA ($20,X)
002D   A0 00      LDY #$00
002F   07         ???
0030   00         BRK
0031   50 00      BVC $0033
0033   EE FF E1   INC $E1FF
0036   50 FE      BVC $0036
0038   EE DA AA   INC $AADA
003B   EA         NOP
003C   AA         TAX
003D   01 1E      ORA ($1E,X)
003F   EE DA DD   INC $DDDA
0042   EE CE AD   INC $ADCE
0045   FE EE DE   INC $DEEE,X
0048   C0 00      CPY #$00
004A   00         BRK
004B   00         BRK
004C   00         BRK
004D   0E DA AA   ASL $AADA
0050   EA         NOP
0051   FF         ???
0052   E0 11      CPX #$11
0054   00         BRK
0055   00         BRK
0056   8E EB EF   STX $EFEB
0059   EE E0 00   INC $00E0
005C   00         BRK
005D   E0 00      CPX #$00
005F   04         ???
0060   AD D0 13   LDA $13D0
0063   AA         TAX
0064   00         BRK
0065   00         BRK
0066   08         PHP
0067   AA         TAX
0068   10 00      BPL $006A
006A   10 AA      BPL $0016
006C   20 00 40   JSR $4000
006F   AA         TAX
0070   30 FF      BMI $0071
0072   FD AA 40   SBC $40AA,X
0075   00         BRK
0076   09 AA      ORA #$AA
0078   50 FE      BVC $0078
007A   DC         ???
007B   AA         TAX
007C   60         RTS
007D   01 20      ORA ($20,X)
007F   AA         TAX
0080              .END