www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/06/16/12:37:48

Xref: news2.mv.net comp.os.msdos.djgpp:5040
From: "A. Sinan Unur" <asu1 AT cornell DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Maintaining buffers in DOS memory
Date: Sat, 15 Jun 1996 20:10:50 -0400
Organization: Cornell University
Lines: 50
Sender: asu1 AT cornell DOT edu (Verified)
Message-ID: <31C3510A.7889@cornell.edu>
NNTP-Posting-Host: cu-dialup-0031.cit.cornell.edu
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi,

I writing a simple program that communicates with other computers via 
NetBIOS. NetBIOS protocol requires that an NCB (Network Control Block) 
and an IO buffer be set up in DOS memory. When the program wants to 
execute a NetBIOS request, it loads ES with the segment and BX with the 
offset of the NCB in DOS memory and issues an INT 5C.

In my program, I have a structure called ncbms which contains a copy of 
the NCB, the IO buffer, and information about the location of the NCB and 
the IO buffer in DOS memory. Before executing a NetBIOS request, I copy 
the NCB and IO buffer to DOS memory as follows:

 dosmemput(&(ncbms.ncb), sizeof((ncbms.ncb)), (ncbms.NCB_ladr));
 dosmemput(&(ncbms.IO_buff), sizeof((ncbms.IO_buff)), (ncbms.IO_ladr));

 memset(&r, 0, sizeof(r));

 r.x.es = (ncbms.NCB_seg);
 r.x.bx = (ncbms.NCB_off);
 r.x.ax = 0x100;

 _go32_dpmi_simulate_int(0x5C, &r);

 ret_code = r.h.al;

I just started learning C, and I haven't programmed since I was writing 
silly games in Z-80 assembly 10 years ago. So, I really don't know if 
this an extremely stupid way of doing things (keeping two copies of the 
NCB and the IO buffer (which is between 2 to 8K). I would appreciate any 
feedback on this.

Another question I have is this. Ultimately, the program I am writing may 
end up maintaining multiple NCBs and IO buffers in DOS memory. I was 
wondering if it would be possible to allocate a large enough chunk of 
DOS memory initially and then manage allocate NCBs and IO buffers from 
that pool instead of doing it piecemeal and thereby possibly causing 
fragmentation. Any opinions?
 
TIA,

Sinan.

-- 
*******************************************************************
 A. Sinan Unur                                WWWWWW
                                              |--O+O
 mailto:asu1 AT cornell DOT edu                      C   ^ 
 mailto:sinan AT econ DOT cit DOT cornell DOT edu             \  ~/ 
*******************************************************************

- Raw text -


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