Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define eflags16(x) \
- { \
- __asm__ __volatile__( "pushf;\n\t" \
- "movw (%%esp), %%ax;\n\t" \
- "popf;\n\t" \
- "movw %%ax, %1;\n" \
- : "=r"(x) \
- : \
- :"%ax" \
- ); \
- }
- enum EFlagEnum
- {
- EFLAG_CARRY = 1,
- EFLAG_PARITY = 1<<2,
- EFLAG_ZERO = 1<<6,
- EFLAG_SIGN = 1<<7,
- EFLAG_OVERFLOW = 1<<11
- };
- typedef unsigned short ui16;
- typedef unsigned int ui32;
- int main(void)
- {
- ui32 a=0x3279FA1C, b,c;
- ui16 flags;
- b = rand();
- c = a + b;
- eflags16(flags);
- if(flags & EFLAG_CARRY)
- {
- printf("Carry set.\n");
- }
- if(flags & EFLAG_PARITY)
- {
- printf("Parity set.\n");
- }
- if(flags & EFLAG_ZERO)
- {
- printf("Zero set.\n");
- }
- if(flags & EFLAG_SIGN)
- {
- printf("Sign set.\n");
- }
- if(flags & EFLAG_OVERFLOW)
- {
- printf("Overflow set.\n");
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment