The task is to obtain information about the computer using the int 11h system interrupt, which writes the state word (configuration) to the AX register. Interrupts can be accessed from dos.h , but the function that provides work with int86() interruption was found only in compiler libraries and headers for 1993, MS Visual 1.52 (1993) 16-bit, which does not suit me, due to the presence of 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 a status word in the numeric value of -14302 . And it seems that everything suits, but there are a few, but which could not be solved:

  1. This code is also compiled only by the above specified compiler (I work VirtualBox with Win7 (32 bit)). More precisely, it turned out to compile in MS Visual C ++ 2010 Express, but when the program starts 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 working incorrectly. Can the same status word be on 3 completely different computing devices (tablet, laptop, computer)?
I ask for advice on solving this problem.

  • Something I very much doubt that it is possible to get some real information from this interruption ... It’s very old there. And then, hardly except from under DOS, it can be used. - Harry
  • @Harry, I understand that it is all ancient, but this is a uni lab, not my rules. So I fight with this. - Rob
  • Well, then I can only offer to take a virtual-DOS, something older than Borland C ++ 3.1 and see ... - Harry
  • 2
    The only advice that can be given here is to bury the already stewardess :) In the sense that using only a virtual machine with bare dos, or dosbox, or something like that. In any modern OS, this interruption simply does not make sense, and the list of equipment is completely different. - PinkTux
  • one
    “on 3 completely different computing devices” - by the way, in virtual box, vmware, etc. You can easily customize the hardware configuration. Therefore, everything is simple: connect / disable FDD, for example, and check that int 11h returns in both cases. In the virtual - naked dos, of course. - PinkTux

1 answer 1

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

In order to make an asm insert into gcc. Gcc uses AT & T assembler syntax

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

But you can use 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; } 
  • And do not tell me how to satisfy the Assembler, which gives this: "C: \ Users \ Rob \ AppData \ Local \ Temp \ ccPObhob.s: Assembler messages: C: \ Users \ Rob \ AppData \ Local \ Temp \ ccPObhob.s: 23: Error: operand size mismatch for `int '" - Rob