0

In dos.h file I came across below macro:

    #define disable()       __emit__((unsigned char)(0xfa))

On some research I understood that emit function is "a pseudo-function that injects literal values directly into the object code". But unable to understand the meaning of emit(0xfa)

1 Answers1

1

It injects int your code literal machine code. According to the comments int main question this is similar to: (I am using TP7 pascal code here, because I am retro-cool):

BEGIN
   WriteLn('Hello world, now interrupts are disabled');
   ASM
      CLI ; // clear interrupts - to re-enable call STI
   END
END.

See also - https://stackoverflow.com/a/1581729/78712

Another example (this time in C, borrowed from http://borlpasc.narod.ru/english/faqs/written.htm) might be

// jump FFFF:0000
#define reboot  __emit__ 0xEA __emit__ 0x00 __emit__ 0x00 __emit__ 0xFF __emit__ 0xFF

This seems to be an Mircrosoft compiler specific, as I am not sure it is available on GCC. Note that this only will work on 16bit DOS and under win32 this will fail in a funny way. Linux/ARM/AMD64 and other variations are out of the question as well.

See also In C programming, what does "emit" do?

Community
  • 1
  • 1
elcuco
  • 8,948
  • 9
  • 47
  • 69