BIOS, system interrupts. int 11h, int 12h in C++ / C

The task is to get information about the computer using the system interrupt int 11h, which writes the status (configuration) word to the AX register. Interrupts can be accessed from the dos.h header, but the function that provides work with the int86() interrupt was found only in the libraries and headers of the compiler for 1993, MS Visual 1.52 (1993) 16-bit, which does not suit me, in view of the presence of a 64-bit OS. The following code was written:

/*#include <stdio.h>
int main()
{
  short a=0;
  __asm
  {       
    int 11h
    mov a, ax
  }
  printf("%d",a);    
  return 0;
}

Which displays the status word in numeric form, equal to -14302. And everything seems to be fine, but there are a few buts that could not be solved:

  1. This code is also compiled only by the above compiler (I work with VirtualBox with Win7 (32 bit)). More precisely, it was possible to compile it in MS Visual C++ 2010 Express, but when you start the program, it crashes and the problem is in the line int 11h
  2. This magic number -14302 is the result also on the tablet (Windows 8.1, 32 bit). And on another computer (WinXP, 32 bit).

The second "but" suggests that something is not working correctly. How can the state word be the same on 3 completely different computing devices (tablet, laptop, computer)?
I ask for advice on how to solve this problem.

Author: Rob, 2017-01-29

1 answers

The interrupt processor command int X is an instruction to the processor to call a function whose address is stored in the IDT (Interrupt Descriptor Table) table .) and the vector X. When booting, the BIOS first writes the addresses of its functions, but after loading the OS kernel. The OS writes its addresses to the IDT table. Therefore, in certain operating systems, you will receive the same response.

To make a asm insert in gcc. gcc uses AT&T assembly syntax

#include <stdio.h>
int main()
{
  int a;
  __asm__(
      "int $0x11\n\t"
     :"=a"(a)
     );
  printf("%d",a);    
  return 0;
 }

But you can also use the Intel syntax

#include <stdio.h>
int main()
{
  int a;
  __asm__(
         ".intel_syntax noprefix\n\t"
         "int 11h\n\t"
        :"=a"(a)
        );
  printf("%d",a);    
  return 0;
 }
 2
Author: Yaroslav, 2017-01-30 15:34:19