Question

Examine the following code and answer the following: 10. Register contents after execution of each instruction Machine code u
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hi,

Please find the solution below and in case any thing is unclear, let me know. (Please note that opcode to machine code mapping is different for different controllers/processors).

Q.)

ORG 0H
MOV R5,#25H
MOV R7,#34H
MOV A,#0
ADD A,R5
ADD A,R7
ADD A,#12H
HERE: SJMP HERE
END

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------

a.) Relevant register and accumulator values are as follows :

Executed Instruction R5 R7 ACC PSW
ORG 0H 0x00 0x00 0x00 0x00
MOV R5,#25H 0x25 0x00 0x00 0x00
MOV R7,#34H 0x25 0x34 0x00 0x00
MOV A,#0 0x25 0x34 0x00 0x00
ADD A,R5 0x25 0x34 0x25 0x01
ADD A,R7 0x25 0x34 0x59 0x00
ADD A,#12H 0x25 0x34 0x6B 0x01
HERE: SJMP HERE 0x25 0x34 0x6B 0x01
END

b.) Machine code(in hex) for the given assembly code (assuming we are working on 8051 microcontroller) would be as follows:

Executed Instruction Address OP -> M.C.(HEX)
ORG 0H
MOV R5,#25H 0000 AD 25
MOV R7,#34H 0002 AF 34
MOV A,#0 0004 E5 0
ADD A,R5 0006 ED
ADD A,R7 0007 EF
ADD A,#12H 0008 E5 12
HERE: SJMP HERE 000A 80 000A
END

c.)

EDSIM51 simulation

EdSim51DI- Version 2.1.20 | simple20190501_1.asnm RST Step Pause New Copy Paste System Clock (MHz)12.0 Time: 130us-Instructio

Note : Examining the code, we can see that at the end of the code there is an "SJMP" (short-jump) from label "HERE" back to the same label "HERE", thus creating an infinite loop.

Add a comment
Know the answer?
Add Answer to:
Examine the following code and answer the following: 10. Register contents after execution of each instruction Machine code using hand assembly EDSIM51 Simulation a. b. c. istart (origin) at 0 ;l...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT