Question
The code is (assembly)
Please only answer if you are certain. I'm trying to learn this myself and I can't afford confusing errors.
Given the following program, identify a program instruction from below that represent one of each of the requested data addressing modes.If one does not exist, enter N/A 5) . INCLUDE . EQU VALUE1 - eb10808e11 .EQU VALUE2 0beee80101 .EQU VALUE 3 2 DEF OCREG R21 .DEF REGVALaR6 DEF REGVAL2-R7 .ORG exeee0 .ORG exe81A .ORG 0xee1E MAIN: R3MP MAIN RJMP ?NTONE RJMP INTTWO LDI R16, LOW(RAMEND) OUT SPL, R16 LDI R16, HIGH(RAMEND) OUT SPH, R16 COM OCREG LDI R29, VALUET CLR R28 MOV R26, R28 MOV R27,R29 ADD R26, R16 LDI R16, VALUE1 STS TCCR2A, R16 LDI R16,VALUE2 STS TCCR2B, R16 LDI R16,VALUE3 STS TIMSK2, R16 LDI R16, VALUE4 STS OCR2A, R16 ST Y+, REGVAL LD REGVAL2, X LDD REGVAL,Y+33 SBI DDRB,4 SEI MAINLOOP:R3MP MAINLOOP INTONE NOP RETI INTTWO : NOP RETI . Single register immediate . Two-register · UCO direct, e data direct, . data indirect, data indirect with displacement . data indirect with pre-decrement * data indirect with post-increment Provide the opcode for the** step in the program above
Explanation / Answer
Answer :- The instructions are written below-
Single Register Immeditae :- LDI
Two Register :- MOV, ADD
IO direct :- OUT
Data Direct :- STS
Data Indirect :- ST, LD
Data Indirect with Displacement :- LDD
Data Indirect with pre-decrement :- NA
Data Indirect with post-decrement :- NA
The 16-bit opcode for STS TCCR2B, R16 is 1010_1kkk_rrrr_kkkk. The value in place of rrrr will be 0000 for register R16, since r varies from R16 to R31. The value of k ranges from 0x40 to 0xBF. TCCR2B has a address of 0xB1. Thus k = 0xB1 – 0x40 = 0x71 = 0111_0001. Thus the 16-bit opcode would be-
1010_1111_0000_0001 .