Knowledge

Interrupt flag

Source 📝

33: 284:
into the operating system when the program attempts to use it. The OS then typically stops delivering interrupts to the program until the program executes STI (which would cause another fault). However, the POPF instruction is not privileged and simply fails silently to restore the IF. The result is
271:
programs that use a protected mode DOS extender and install their own interrupt handlers (usually games) use the CLI instruction in the handlers to disable interrupts and either POPF (after a corresponding PUSHF) or IRET (which restores the flags from the stack as part of its effects) to restore it.
288:
There are few satisfactory resolutions to this issue. It is usually not possible to modify the program, as source code is typically not available and there is no room in the instruction stream to introduce an STI without massive editing at the assembly level. Removing CLI's from the program or
346:
In some implementations of the instruction which enables interrupts, interrupts are not enabled until after the next instruction. In this case the sequence of enabling interrupts immediately followed by disabling interrupts results in interrupts not being recognized.
289:
causing the V86 host to ignore CLI completely might cause other bugs if the guest's interrupt handlers aren't designed to be re-entrant (though when executed on a modern processor, they typically execute fast enough to avoid overlapping of interrupts).
285:
that the OS stops delivering interrupts to the program, which then hangs. DOS programs that do not use a protected mode extender do not suffer from this problem, as they execute in V86 mode where POPF does trigger a fault.
255:). CLI and STI are privileged instructions, which cause a general protection fault if an unprivileged application attempts to execute them. The POPF instruction will not modify the 54: 47: 491: 391: 97: 69: 76: 484: 408: 116: 557: 83: 532: 17: 477: 273: 65: 272:
This works if the program was started in real mode, but causes problems when such programs are run in a
381: 220: 212: 146: 713: 588: 313: 232: 687: 517: 281: 437: 682: 364: 43: 402: 166: 606: 547: 328:. This is necessary when modifying multiple associated data structures without interruption. 170: 438:"Intel Architecture Software Developer's Manual, Volume 2: Instruction Set Reference Manual" 90: 149:, which determines whether or not the (CPU) will respond immediately to maskable hardware 8: 718: 582: 677: 463: 231:
In systems that support privileged mode, only privileged applications (usually the OS
594: 512: 397: 325: 309: 321: 672: 600: 527: 360: 340: 305: 301: 280:
under Windows NT or later). Since CLI is a privileged instruction, it triggers a
363:
systems an interrupt handler must use other synchronization mechanisms such as
662: 640: 630: 565: 542: 244: 707: 650: 576: 317: 537: 522: 692: 635: 625: 386: 469: 655: 376: 248: 161:) such interrupts will be disabled until interrupts are enabled. The 150: 32: 308:
mechanism in uniprocessor systems. For example, a CLI is used in
667: 277: 570: 464:
Intel 64 and IA-32 Architectures Software Developer Manuals
414: 337: 298: 268: 240: 182: 142: 138: 276:-based container on modern operating systems (such as 157:maskable interrupts are enabled. If reset (set to 705: 350: 169:(NMIs) or software interrupts generated by the 485: 219:being set or cleared based on the bit in the 211:lags) removes a word from the stack into the 492: 478: 392:Advanced Programmable Interrupt Controller 117:Learn how and when to remove this message 499: 432: 430: 292: 176: 14: 706: 343:enables interrupts by setting the IF. 331: 53:Please improve this article by adding 473: 427: 359:only affects a single processor. In 259:if the application is unprivileged. 185:architecture, the instructions CLI ( 26: 262: 24: 226: 25: 730: 457: 409:Programmable Interrupt Controller 165:does not affect the handling of 31: 533:Low-level programming language 13: 1: 420: 351:Multiprocessor Considerations 55:secondary or tertiary sources 243:system this only applies to 7: 370: 251:code may always modify the 223:from the top of the stack. 10: 735: 382:FLAGS register (computing) 304:CLI is commonly used as a 215:, which may result in the 616: 589:Microsoft Macro Assembler 556: 505: 312:to disable interrupts so 518:Comparison of assemblers 153:. If the flag is set to 167:non-maskable interrupts 466:- Retrieved 2017-09-14 403:Non-maskable interrupt 42:relies excessively on 607:Open Watcom Assembler 548:x86 assembly language 204:nterrupt). The POPF ( 688:Instruction listings 293:Disabling interrupts 177:Setting and clearing 683:Calling conventions 583:High Level Assembly 500:x86 assembly topics 332:Enabling Interrupts 193:nterrupt) and STI ( 678:Processor register 316:code (typically a 181:In a system using 701: 700: 595:Netwide Assembler 513:Assembly language 398:Interrupt handler 326:interrupt handler 310:operating systems 235:) may modify the 127: 126: 119: 101: 16:(Redirected from 726: 714:X86 instructions 494: 487: 480: 471: 470: 451: 450: 448: 447: 442: 434: 263:Old DOS programs 160: 156: 122: 115: 111: 108: 102: 100: 66:"Interrupt flag" 59: 35: 27: 21: 734: 733: 729: 728: 727: 725: 724: 723: 704: 703: 702: 697: 673:Program counter 618: 612: 601:Turbo Assembler 552: 528:Instruction set 501: 498: 460: 455: 454: 445: 443: 440: 436: 435: 428: 423: 373: 353: 341:instruction set 336:The STI of the 334: 322:race conditions 306:synchronization 302:instruction set 295: 265: 229: 227:Privilege level 179: 158: 154: 123: 112: 106: 103: 60: 58: 52: 48:primary sources 36: 23: 22: 15: 12: 11: 5: 732: 722: 721: 716: 699: 698: 696: 695: 690: 685: 680: 675: 670: 665: 663:Memory address 660: 659: 658: 653: 648: 646:Interrupt flag 643: 641:Direction flag 638: 628: 622: 620: 614: 613: 611: 610: 604: 598: 592: 586: 580: 574: 571:Flat Assembler 568: 562: 560: 554: 553: 551: 550: 545: 543:Microassembler 540: 535: 530: 525: 520: 515: 509: 507: 503: 502: 497: 496: 489: 482: 474: 468: 467: 459: 458:External links 456: 453: 452: 425: 424: 422: 419: 418: 417: 412: 406: 400: 395: 389: 384: 379: 372: 369: 361:multiprocessor 357:Interrupt flag 352: 349: 333: 330: 294: 291: 264: 261: 257:Interrupt flag 253:Interrupt flag 245:protected mode 237:Interrupt flag 228: 225: 221:FLAGS register 217:Interrupt flag 213:FLAGS register 178: 175: 163:Interrupt flag 147:FLAGS register 131:Interrupt flag 125: 124: 39: 37: 30: 9: 6: 4: 3: 2: 731: 720: 717: 715: 712: 711: 709: 694: 691: 689: 686: 684: 681: 679: 676: 674: 671: 669: 666: 664: 661: 657: 654: 652: 651:Overflow flag 649: 647: 644: 642: 639: 637: 634: 633: 632: 629: 627: 624: 623: 621: 615: 608: 605: 602: 599: 596: 593: 590: 587: 584: 581: 578: 577:GNU Assembler 575: 572: 569: 567: 564: 563: 561: 559: 555: 549: 546: 544: 541: 539: 536: 534: 531: 529: 526: 524: 521: 519: 516: 514: 511: 510: 508: 504: 495: 490: 488: 483: 481: 476: 475: 472: 465: 462: 461: 439: 433: 431: 426: 416: 413: 410: 407: 404: 401: 399: 396: 393: 390: 388: 385: 383: 380: 378: 375: 374: 368: 366: 362: 358: 348: 344: 342: 339: 329: 327: 323: 319: 315: 311: 307: 303: 300: 290: 286: 283: 279: 275: 270: 260: 258: 254: 250: 246: 242: 238: 234: 224: 222: 218: 214: 210: 207: 203: 200: 196: 192: 188: 184: 174: 173:instruction. 172: 168: 164: 152: 148: 144: 140: 136: 132: 121: 118: 110: 107:December 2018 99: 96: 92: 89: 85: 82: 78: 75: 71: 68: –  67: 63: 62:Find sources: 56: 50: 49: 45: 40:This article 38: 34: 29: 28: 19: 18:IF (x86 flag) 645: 538:Machine code 523:Disassembler 444:. Retrieved 356: 354: 345: 335: 320:) can avoid 296: 287: 266: 256: 252: 236: 230: 216: 208: 205: 201: 198: 194: 190: 186: 180: 162: 137:) is a flag 134: 130: 128: 113: 104: 94: 87: 80: 73: 61: 41: 617:Programming 719:Interrupts 708:Categories 636:Carry flag 626:Call stack 558:Assemblers 446:2007-07-13 421:References 387:Intel 8259 324:within an 151:interrupts 77:newspapers 44:references 693:Registers 656:Zero flag 377:Interrupt 267:Some old 249:Real mode 566:A86/A386 371:See also 239:. In an 297:In the 141:in the 91:scholar 668:Opcode 619:issues 609:(WASM) 603:(TASM) 597:(NASM) 591:(MASM) 573:(FASM) 506:Topics 394:(APIC) 318:driver 314:kernel 247:code ( 233:kernel 93:  86:  79:  72:  64:  631:Flags 585:(HLA) 579:(GAS) 441:(PDF) 411:(PIC) 405:(NMI) 365:locks 282:fault 278:NTVDM 98:JSTOR 84:books 355:The 274:DPMI 189:ear 129:The 70:news 415:x86 338:x86 299:x86 269:DOS 241:x86 206:Pop 183:x86 171:INT 145:'s 143:CPU 139:bit 46:to 710:: 429:^ 367:. 187:Cl 135:IF 57:. 493:e 486:t 479:v 449:. 209:F 202:I 199:t 197:e 195:S 191:I 159:0 155:1 133:( 120:) 114:( 109:) 105:( 95:· 88:· 81:· 74:· 51:. 20:)

Index

IF (x86 flag)

references
primary sources
secondary or tertiary sources
"Interrupt flag"
news
newspapers
books
scholar
JSTOR
Learn how and when to remove this message
bit
CPU
FLAGS register
interrupts
non-maskable interrupts
INT
x86
FLAGS register
FLAGS register
kernel
x86
protected mode
Real mode
DOS
DPMI
NTVDM
fault
x86

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.