1
\$\begingroup\$

My Microprocessor teacher of 8085 gave an assignment to set all flags ! I have written this little program to set all except Sign, Please help me out

 MVI A,0FFH
 ANI 01H
 HLT
\$\endgroup\$

3 Answers 3

7
\$\begingroup\$

The five flags on the 8080/8085 are Sign, Zero, Carry, Half-carry and Parity. It looks like your program clears all of them. The result of the ANI is not zero, not negative and has odd parity. Also, logical operations like ANI unconditionally clear both carry flags.

Actually, the most direct way to set all of them is something like this:

LXI H, 0FFFFh
PUSH H
POP PSW

Which your teacher may or may not consider a "cheat". (Actually, I can't think of any other way to get both the Z and S flags set simultaneously.)

I'm amazed that anyone is still teaching this ancient architecture, rather than something that's actually still in production. It's utterly useless knowledge.

\$\endgroup\$
5
  • \$\begingroup\$ Welcome to my computer architecture class, except we used a fictional 1-register microcoded CISC architecture without a stack pointer! \$\endgroup\$
    – HL-SDK
    Oct 25, 2013 at 13:33
  • 1
    \$\begingroup\$ "Let me tell you about how it was done in 1983..." \$\endgroup\$
    – HL-SDK
    Oct 25, 2013 at 13:33
  • 1
    \$\begingroup\$ I still maintain an embedded system that is based on a Z80 for a client. So despite wishful thinking the 8080 architecture is not exactly dead. The 8051 architecture is alive and well, and is at the core of several very popular USB and Bluetooth implementations. Those old 8-bit micro cores are not likely to truly die for a long time. \$\endgroup\$
    – RBerteig
    Nov 16, 2013 at 2:50
  • \$\begingroup\$ Also, given that there are several open source implementations of the 8080 ready to synthesize into your FPGA, you too can have an 8080 based system! \$\endgroup\$
    – RBerteig
    Nov 16, 2013 at 3:03
  • 1
    \$\begingroup\$ It's also difficult to see the point of the actual exercise. Not something that ever arises in practice. \$\endgroup\$
    – user207421
    Jan 14, 2014 at 21:43
2
\$\begingroup\$
MVI L,FFH
PUSH H
POP PSW
RAR   // upto which will set all flags
MVI L,00H
PUSH H
POP PSW
HLT   // upto which it reset all flags
\$\endgroup\$
0
-1
\$\begingroup\$
MVI L,FFH;
Push H;
Pop PSW;

This is the simplest way!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.