Interrupts and FAR calls from DPMI (Developers)
> I want do do some experimetns with PNP BIOS and SMBIOS. These services are
> called by FAR Call with parameters pushed od stack. There is no problem in
> real mode with it but how to do it from DPMI (I want to use realmode
> interface)[...]
> Can you show me some DJGPP C code for it?
> (I will programm it in Freepascal but C is readable for me)
#include <stdio.h>
#include <dpmi.h>
#include <sys/movedata.h>
/*real mode "C" far proc which returns in dx:ax the sum of two 32-bit signed numbers*/
static char farproc[] = {0x55,0x89,0xe5,0x8b,0x46,0x06,0x8b,0x56,0x08,0x03,0x46,0x0a,0x13,0x56,0x0c,0x5d,0xcb};
int main()
{
        long numbers[] = {12312, -3233232}; 
        __dpmi_regs regs;
        int seg, sel;
        if ((seg = __dpmi_allocate_dos_memory(((sizeof(farproc) + 15) & -16) >> 4, &sel)) == -1)
        {
                printf("Not enough DOS memory\n");
                return -1;
        }       
    dosmemput((void *)farproc, sizeof(farproc), seg << 4);        
        regs.x.cs = seg;
        regs.x.ip = 0;
        regs.x.ss = 0;
        regs.x.sp = 0;
        __dpmi_simulate_real_mode_procedure_retf_stack(®s,sizeof(numbers)/2,(void *)&numbers);
        printf("The result is %d\n", (regs.x.dx << 16) + regs.x.ax);
        __dpmi_free_dos_memory(sel);
        return 0;
}
EDIT: obviously, in case you don't want to call directly int 31h/ax=301h using assembly language.
---
Glory to God for all things
Complete thread:
- Interrupts and FAR calls from DPMI - Laaca, 27.02.2012, 10:03 ![Open in board view [Board]](img/board_d.gif) ![Open in mix view [Mix]](img/mix_d.gif) - Interrupts and FAR calls from DPMI - Khusraw, 27.02.2012, 13:48- Interrupts and FAR calls from DPMI - Laaca, 28.02.2012, 16:02- Interrupts and FAR calls from DPMI - Khusraw, 28.02.2012, 17:19
- Interrupts and FAR calls from DPMI - marcov, 29.02.2012, 10:35
- Interrupts and FAR calls from DPMI - RayeR, 02.03.2012, 20:51- Interrupts and FAR calls from DPMI - Khusraw, 02.03.2012, 20:59- Interrupts and FAR calls from DPMI - RayeR, 02.03.2012, 21:25- Interrupts and FAR calls from DPMI - Laaca, 03.03.2012, 21:31- Interrupts and FAR calls from DPMI - RayeR, 05.03.2012, 15:16- Interrupts and FAR calls from DPMI - Laaca, 07.03.2012, 07:17- Interrupts and FAR calls from DPMI - bretjohn, 07.03.2012, 18:08
 
 
- Interrupts and FAR calls from DPMI - Laaca, 07.03.2012, 07:17
 
- Interrupts and FAR calls from DPMI - RayeR, 05.03.2012, 15:16
 
- Interrupts and FAR calls from DPMI - Laaca, 03.03.2012, 21:31
 
- Interrupts and FAR calls from DPMI - RayeR, 02.03.2012, 21:25
 
- Interrupts and FAR calls from DPMI - Khusraw, 02.03.2012, 20:59
 
 
- Interrupts and FAR calls from DPMI - Laaca, 28.02.2012, 16:02
 
- Interrupts and FAR calls from DPMI - Khusraw, 27.02.2012, 13:48
 Board view
Board view Mix view
Mix view
