Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Newbie question about memory models

Posted on 2000-04-04
2
Medium Priority
?
179 Views
Last Modified: 2010-04-15


I am using a third party product  to create apps  for mobile computers, ( Penright) ,  anyway  in getting  peripherals to work under DOS   I have  had to ask the manufacturers to send me the proper libraries and header files to make the barcode scanners   work on their particular unit ( each one is different )  enclosed with the email from the company is this  "There is a bar code example under the barscan directory. It links
with libraries touch_s and periphs for small memory model. You would
probably only need to link with periphl for large model to integrate it into
your Penright application."  As  I said  I am a complete newbie  at this,  can someone explain  what these  memory  model  terms  mean?  In laymans  terms  also  if  possible.  

Thanks

DaveMon
0
Comment
Question by:DaveMon
2 Comments
 
LVL 32

Accepted Solution

by:
jhance earned 200 total points
ID: 2685552
MSDOS runs on Intel 8086 family based computers only.  The 8086 was designed using a screwy register setup where each of it's 16-bit registers could access it's 20-bit (1MB) memory space by adding the 16-bit base register value to the 16-bit segment register with the segment register shifted left by 4 bits.  There were 4 of these segment registers, CS, DS, SS, and ES for CODE segment, DATA segment, STACK segment, and EXTRA segment.  With each value in a segment register the base registers could access 64KB of memory.

Since messing with these segment registers is not only a hassle but also a performance hog, programming libraries developed around memory "models" of how these segments were managed.  The most common of these are:

TINY : CS = DS = SS.  All code, data, stack, and other stuff must fit in 1 64KB memory block.  In DOS, this is a COM program.

SMALL : CS = DS != SS.  Here the stack is in it's own 64K segment but CODE and DATA still must fit in 64K.

LARGE : CS != DS != SS.  Code, Data, and stack are all in their own segments and generally the library causes all jumps and calls to be FAR.  This means that the CODE size can be > 64K but there is additional overhead in loading the CS for each jump or call.  Same with data references, all data references load the DS.

There are other variations in this but this gives the general idea.

Under the 32-bit model in 80386 and higher, there is still a segment scheme but the segments are now 32-bits long.  Hence the "32-bit flat" memory model used by Win32, linux, and other 32-bit x86 operating systems.


Bottom line for your application is that you must use a library that is compatible with the memory model you are using.
0
 
LVL 2

Author Comment

by:DaveMon
ID: 2691314
That   was  informative
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question