delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/02/08:00:30

From: "Sérgio Vale e Pace" <space AT gold DOT com DOT br>
Newsgroups: comp.os.msdos.djgpp
Subject: The hard way to get VESA info
Date: Fri, 02 Jan 1998 01:08:59 -0200
Organization: RNP - POP-MG
Lines: 132
Message-ID: <34AC5A4A.8AC5A474@gold.com.br>
NNTP-Posting-Host: line0014.horizontes.com.br
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Could somebody out there tell-me why the code below don't work?

I'm trying to get vesa information with custom functions, but my system
crash every time
I try to run this code, and I can't figure why.

-----------------------------cut
here----------------------------------------------
#include <stdio.h>

typedef unsigned char byte;
typedef unsigned int word;
typedef unsigned long dword;


typedef struct {
  byte signature[4];
  word version;
  dword oem;
  dword capabilities;
  dword modelistptr;
  word memory;
  byte reserved[262];
  } svgainfo;

typedef struct RMREGS{
  dword edi;
  dword esi;
  dword ebp;
  dword reserved;
  dword ebx;
  dword edx;
  dword ecx;
  dword eax;
  word  flags;
  word  es;
  word  ds;
  word  fs;
  word  gs;
  word  ip;
  word  cs;
  word  sp;
  word  ss;
  } rmregs;

void setmem(byte source, void* dest, dword size)
{
  __asm__("
    cld
    rep
    stosb"
    :
    :"eax" (source), "ecx" (size), "D" (dest)
    :"eax", "ecx", "di", "memory", "cc");
}

void cpymem(void* source, void* dest, dword size)
{
  __asm__("
    cld
    rep
    movsb"
    :
    :"ecx" (size), "S" (source), "D" (dest)
    :"ecx", "di", "si", "memory", "cc");
}

void* allocdos(word size, dword* segment, dword* selector)
{
  __asm__ ("
    movl $0x0100, %%eax
    addl $15, %%ebx
    shrl $4, %%ebx
    int $0x31"
    :"=eax" (*segment), "=edx" (*selector)
    :"ebx" (size)
    :"eax", "ebx", "edx", "memory", "cc");
  return (void*) ((*segment &0xffff)<<4);
}

void freedos(dword selector)
{
  __asm__ ("
    movl $0x0101, %%eax
    int $0x31"
    :
    :"edx" (selector)
    :"eax", "edx", "memory", "cc");
}

void* getbase(dword selector) {
  __asm__ ("
    movw $0x0006, %%ax
    int $0x31
    shll $16, %%ecx
    addl %%ecx, %%edx
    movl %%edx, %%eax
    "
    :
    :"ebx" (selector)
    :"eax", "ebx", "ecx", "edx", "memory", "cc");
}

inline void rmint(word inter, rmregs* regs)
{
  __asm__ ("
    movl $0x0300, %%eax
    xorl %%ecx, %%ecx
    movw %%ds, %%dx
    movw %%dx, %%es
    int $0x31"
    :
    :"bl" ((byte)inter), "D" (regs)
    :"eax", "ebx", "ecx", "edi", "memory", "cc");
}

int main()
{
rmregs r;
dword sel, seg;
svgainfo* a=(svgainfo*)allocdos(sizeof(svgainfo), &seg, &sel);
setmem (0, &r, sizeof(rmregs));
r.eax=0x4f00;
r.es=(0xffff&seg);
r.edi=0;
rmint(0x10, &r);
printf("%c%c%c%c\n", a->signature[0], a->signature[1], a->signature[2],
a->signature[3]);
return 0;
}


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019