Skip to content

Instantly share code, notes, and snippets.

@joshuashaffer
Created May 13, 2016 02:45
Show Gist options
  • Save joshuashaffer/0d1860beeb55e77b0fb14f4809a6347b to your computer and use it in GitHub Desktop.
Save joshuashaffer/0d1860beeb55e77b0fb14f4809a6347b to your computer and use it in GitHub Desktop.
Example of BorlandC inline ASM
//--------------------------------------------------------------------------
// FarRead()
//-------------------------------------------------------------------------
boolean FarRead (int handle, char far *dest, long length)
{
if (length>0xffffl)
TrashProg("FarRead doesn't support 64K reads yet!");
asm push ds
asm mov bx,[handle]
asm mov cx,[WORD PTR length]
asm mov dx,[WORD PTR dest]
asm mov ds,[WORD PTR dest+2]
asm mov ah,0x3f // READ w/handle
asm int 21h
asm pop ds
asm jnc good
// errno = _AX;
return false;
good:
asm cmp ax,[WORD PTR length]
asm je done
// errno = EINVFMT; // user manager knows this is bad read
return false;
done:
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment