Jump to content
Electronics-Lab.com Community

Re: 8085 weird problem


JamesUWF

Recommended Posts

I'm not sure what kind of 8085A emulator you are using, but a real life 8085A will fetch and execute whatever instruction the Program Counter points to, be it "DCR M" or "DCX rp."  Either of these instructions can be used to decrement a 16-bit number, but if you examine the instruction set closely, you will see there is a critical difference between the two. 

"DCR M" decrements a 16-bit value located in two successive memory locations pointed to by HL and HL+1.  "DCX rp" decrements the 16-bit value of a given register pair.  While both decrement a 16-bit number, the critical flaw with the "DCX rp" instruction is that it does not affect any carry flags, and odds are your delay string uses a "zero" dependent branch instruction to exit the loop.  So when you try to "DCR rp" your way out of the loop, your PC just keeps spinning around through it until there is a hardware interrupt, a hard RESET, or you kill the power. 

I ran into the same problem the first time I coded 16-bit delay loops. 

James

Link to comment
Share on other sites



... the critical flaw with the "DCX rp" instruction is that it does not affect any carry flags, and odds are your delay string uses a "zero" dependent branch instruction to exit the loop. 


Correction.  I meant to say "...the "DCX rp" instruction does not affect any condition flags..."
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
  • Create New...