NTDVM CPU has encountered an illegal instruction - please help.

Hello all,

Using Borland C++ 4.52 on a Windows Virtual PC in XP Mode.

I am writing what I thought to be a pretty simple DOS program.  It is basically opening files, filling up structures, printing structure information to a file and that's it.  The files are binary and are less than 32 Kbytes, most are 1K or less.   I am 75% of the way done, it has been running fine up to now.  I just added some code to finish it off, and now I am getting this error at runtime:

"The NTDVM CPU has encountered an illegal instruction.
CS:00cc IP:0106 OP:ff ff 00 00 00 Choose 'Close' to terminate the application."

The thing is, the code I added is just a repeat of the same code that was at the beginning but to different structures.  Seems to have something to do with the code size?  I don't know.  I am not that familiar with memory management.  However, when I removed the stuff I had added, it works again.  

I am attaching both the main code and the extra code I am trying to add.

I would appreciate any guidance.
Elena QuinnAsked:
Who is Participating?
sarabandeConnect With a Mentor Commented:
Borland C++ 4.52 is from 1995 and the first Borland c++ compiler that supported win95. but windows 95 has a preemptive multi-tasking and not all instructions still are supported by newer windows version including windows xp. windows xp was based on winnt and they replaced nearly all kernel DOS functions by new kernel functions.

there is no advantage to using such an old compiler beside you really would need to develop a dos program. if that is really your goal, you should create a VM with win95 or win98 and use Visual C++ 1.52 (IDE + compiler) which was the last visual c++ compiler that could create dos applications by using a DOS extender.

if you only want to create a console program that runs in a windows console (dos box), you could use the newest c++ compilers. for example you could download visual studio 2017 community which is free and create a new project for a win32 console application.

Elena QuinnConnect With a Mentor Author Commented:
Some additional information - I put in some printfs to figure out where the failure is happening.  Its happening in printalltst, which is called prior to the additional lines I added.  This is why I think it has something to do with the size.
David Johnson, CD, MVPConnect With a Mentor OwnerCommented:
from what I can remember as I haven't used Borland products in a LOOONG time..
What size are you compiling it to?  tiny, small, large ??
Elena QuinnConnect With a Mentor Author Commented:
Elena QuinnAuthor Commented:
Actually never figured this out, but don't need it anymore.
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.