Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

Interrupts and FAR calls from DPMI (Developers)

posted by Khusraw E-mail, Bucharest, Romania, 27.02.2012, 13:48
(edited by Khusraw on 27.02.2012, 18:14)

> 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(&regs,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;
}
, or use your own preallocated-in-DOS-memory stack and copy the parameters there.
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:

Back to the forum
Board view  Mix view
22760 Postings in 2121 Threads, 402 registered users (1 online)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum