• C

Newbie question about memory models



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
LVL 2
DaveMonAsked:
Who is Participating?
 
jhanceConnect With a Mentor Commented:
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
 
DaveMonAuthor Commented:
That   was  informative
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.