I'm trying to disassemble an old DOS application and got stuck at some point of the VESA graphics handling.

The VESA function to be called will be stored in a global variable, e.g. vesa_fct_dword_749C8 = 0x4f00, 0x4f01, etc. After checking the return value, the application will do some additional magic, which I, frankly, don't understand. My guess is that it will check for a specific error return value (0x01, in particular), but I'm really not quite sure about it and how it's actually done.

Here's the relevant snippet:

cseg01:000159D8 loc_159D8:                              ; CODE XREF: checkForVesa+D4↑j
cseg01:000159D8                 mov     eax, vesa_fct_dword_749C8
cseg01:000159DD                 mov     edx, vesa_fct_dword_749C8
cseg01:000159E3                 sar     edx, 1Fh
cseg01:000159E6                 shl     edx, 8
cseg01:000159E9                 sbb     eax, edx
cseg01:000159EB                 sar     eax, 8
cseg01:000159EE                 and     eax, 0FFh
cseg01:000159F3                 cmp     eax, 1
cseg01:000159F6                 jnz     short loc_15A01
cseg01:000159F8                 mov     [ebp+var_4], 0
cseg01:000159FF                 jmp     short loc_15A29

Maybe someone knows what's up with that part, that would be really appreciated!


This code takes the most significant bit of EAX (msb(EAX)) and then, it subtracts it from AH and compares the result to 1. According to this specification ("VBE Return Status" section):

  • AX = 014F => AH = 1 means "Function call failed "
  • AX = 024F => AH = 2 means "Function is not supported in current hardware configuration "

And the jnz instruction will be executed if msb(EAX) = 1 and AH = 2, or when msb(EAX) = 0 and AH = 1. Unfortunately, I don't know what information is stored in msb(EAX) (maybe something related to VBE version?).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.