Created
May 13, 2016 02:45
-
-
Save joshuashaffer/0d1860beeb55e77b0fb14f4809a6347b to your computer and use it in GitHub Desktop.
Example of BorlandC inline ASM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//-------------------------------------------------------------------------- | |
// 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