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
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.
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;
This is the simplest way!