Problem 6Write
the assembly code to set all the 8086 flags to '1' at one go without
using any arithmetic or logical instructions.
Answer:
We normally use instructions
like STD/CLD (set/clear direction flag), STI/CLI (set/clear interrupts)
and so forth to modify individual control flags. But the conditional
flags are modified only indirectly as a result of arithmetic or logical
operations.
However, it is
possible to set/reset individual flags or all the flags at one go
using the following code:
MOV AX, 0FFFFh
PUSH AX
POPF
AX is filled with
ones and pushed onto the stack. Then it is popped into the flags register,
which sets all of the flags to '1'. To set individual bits of the
flags register, just fill AX with the appropriate value and push it
onto the stack.
Contributor:
Naveen P N
5-01
NEXT Q&A
|