www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/10/21/14:26:56

From: Jon Slaughter <lobo AT iamerica DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: protected mode -> real mode help.
Date: Sun, 20 Oct 1996 18:47:09 -0500
Organization: none
Lines: 75
Message-ID: <326AB9FD.6CDF@iamerica.net>
NNTP-Posting-Host: 205.173.253.125
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I need some help on how to call a real mode interrupt(I think I got
that, though) and how to allocate a real mode buffer. Heres some code
that I need it for. I want to read in a sector off the floppy disk to a
buffer, copy the buffer to the BR struct or just read the sector
directly into the BR struct... any help would be appreciated. Thanks.




#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <conio.h>
#include <string.h>
#include <dpmi.h>
#include <dos.h>
#include <go32.h>

#define word unsigned short
#define byte unsigned char
#define byte unsigned char
#define dword unsigned long

void read_sector(byte *buf);


typedef struct {
char JUMP_OPCODE[3];
char OEM_NAME[8];
word BYTES_PER_SECTOR;
byte SECTORS_PER_UNIT;
word RESERVED_SECTORS;
byte NUMBER_OF_FATS;
word MAX_ROOT_DIRS;
word SECTORS_IN_MEDIA;
byte MEDIA_TYPE;
word FAT_SECTOR_SIZE;
word SECTORS_PER_TRACK;
word TOTAL_HEADS;
dword HIDDEN_SECTORS;
dword SECTORS_IN_DISK;
word PHYSICAL_DRIVE_NUMBER;
byte EXTENDED_BOOT_SIG;
dword VOLUME_SERIAL_NUMBER;
char VOLUME_LABEL[11];
char FILE_SYSTEM_ID[7];
byte filler[512];
} BOOT_RECORD_STRUCT;

BOOT_RECORD_STRUCT *BOOT_RECORD;

byte track,sector,head,drive;
byte *buffer;
void main (void)
{
track = head = drive = 0;
sector = 1;
buffer = (byte*)malloc(512);
read_sector(buffer);

}

void read_sector(byte *buf)
{
	__dpmi_regs r;
        byte *buffer;
        dosmemget(__tb, 512, &buffer);
        r.x.ax = 0x0201;
        r.x.cx = (track << 8) + sector;
        r.x.dx = (head << 8) + drive;
        r.x.es = __tb / 16;
        r.x.bx = __tb && 0x0f;
        __dpmi_int(0x13, &r);

}

- Raw text -


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