JamesUWF Posted October 14, 2009 Report Share Posted October 14, 2009 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 Quote Link to comment Share on other sites More sharing options...
JamesUWF Posted October 15, 2009 Author Report Share Posted October 15, 2009 ... 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..." Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.