# How to set all flags in 8085?

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


## 3 Answers

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.

• Welcome to my computer architecture class, except we used a fictional 1-register microcoded CISC architecture without a stack pointer! – HL-SDK Oct 25 '13 at 13:33
• "Let me tell you about how it was done in 1983..." – HL-SDK Oct 25 '13 at 13:33
• 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. – RBerteig Nov 16 '13 at 2:50
• 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! – RBerteig Nov 16 '13 at 3:03
• It's also difficult to see the point of the actual exercise. Not something that ever arises in practice. – user207421 Jan 14 '14 at 21:43
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

• MVI L,FFH PUSH H POP PSW RAR // upto which will set all flags MVI L,00H PUSH H POP PSW HLT – omkar Oct 6 '18 at 6:33
• Welcome to EE.SE. Your copy/past buttons seem to be stuck in some loop. Please press on edit and reformulate your answer. Add more explanation to the current answer (after you severely improve its formatting). Further, have you gone through this tour? Please consider it! – Hazem Oct 6 '18 at 6:37
MVI L,FFH;
Push H;
Pop PSW;


This is the simplest way!