I wanted to ask that is there any explicit and easy way to store the values of flags in variables
The easiest way will use a loop. Next code snippets will store the 9 flags that are available on 8086 in byte-sized variables. If the flag is OFF you get 0, if the flag in ON you get 1.
Allowing 3 unused data bytes (simpler)
.data
CF db 0
db 0
PF db 0
db 0
AF db 0
db 0
ZF db 0
SF db 0
TF db 0
IF db 0
DF db 0
OF db 0
...
pushf
pop dx
mov di, offset CF
mov cx, 12
cld
More:
shr dx, 1
mov al, 0
rcl al, 1
stosb
dec cx
jnz More
No unused data bytes (ideal for continuous displaying)
.data
CF db 0
PF db 0
AF db 0
ZF db 0
SF db 0
TF db 0
IF db 0
DF db 0
OF db 0
...
pushf
pop dx
mov di, offset CF
mov cx, 12
mov bx, 0FD5h ; Mask of defined flags
cld
More:
shr dx, 1
mov al, 0
rcl al, 1
shr bx, 1
jnc Skip ; Bit does not correspond to a defined flag
stosb
Skip:
dec cx
jnz More
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…