PDA

View Full Version : The weird world of C



Sunny
05-31-2002, 09:40 AM
Hi guys.
I was writing some code recently, and it's a set of around 10 modules-60000 Compiled
lines. Everything was fine until recently I added a simple module with some very simple void
functions. However, when I compile this time i get error messages telling
me "Segment Code _TEXT exceeds 64k". The compiler is the basic BC31. The Help
system is very dry, short and jargonic. So, I turn to you, my friends, as my last hope...
No, i don't want to change memory model from 'Compact' to Large or Huge.
:confused:

Thanks.



Discover the XBlue:
http://www.angelfire.com/my/bahairomania/freegui.html:confused:

Shiro
05-31-2002, 11:32 AM
Your program is too large. Split it up in submodules.

JoshG
05-31-2002, 12:30 PM
You said the compiler you use is BC31? If that means Turbo C++ 3.1, then just change the memory modual to huge.

Salem
05-31-2002, 12:42 PM
> No, i don't want to change memory model from 'Compact' to Large or Huge
I don't think you have a choice - compact is 64K max of code (ie TEXT segment) - whether its in 1 source file or 10

Scroll down to the end of
this (http://burks.brighton.ac.uk/burks/language/asm/asmtut/asm5.htm) to see what each memory model gives you.

Your other choice is to look through your code to see if there is any dead code which can be removed. But you are at the limit with this memory model, and without changing it, your options are few.

Sunny
05-31-2002, 08:25 PM
Split it up into smaller modules
could that really work?

I'll try changing to "Large", but changing to "huge" will just jam all the graphicsa routines.

Thanks a lot for talking to me about this.


Stef

Shiro
06-01-2002, 02:48 AM
>could that really work?

Yes, but ofcourse I'm not talking only about splitting the source code into different files, but mainly about splitting binaries. In large software projects, programmers usually create libraries with functions. Create one or more libraries and use these.

sean
06-03-2002, 04:02 PM
Doesn't your compiler have any other options? Mine has like 6! And they all would increase something, so I would think it would work on Medium or even small.

Sunny
06-09-2002, 01:31 AM
Yes, of course it has other options. But I wanted to
know from the right source. :D
Now, by making libraries, you mean those files with
the '.lib' extension? If so, I really didn't know they were so
eficient....

I was also wondering about DOS. And if anyone still
uses it nowadays... I know I do sometimes, but that's
until I get my Linux installed. Then It's bye bye, and i'm
off to the wonderfull world of DOS Emulators and WINE
if I ever need to use Ms Compatible software.

So, let's think about it. Should I still develop any software under DOS?

Of course, I did try to learn the Windows API but it
was too much of a headache. Really distressing. But
i'll keep trying if it's the case.


Thanks a lot guys for taking your time to reply.



Stef

My website:
www.angelfire.com/my/bahairomania/freegui.html

Shiro
06-09-2002, 03:03 AM
>So, let's think about it. Should I still develop any software under DOS?

You don't need to. Unless you want people who use DOS be able to use your software. So it depends on what kind of software you want to write.

sean
06-09-2002, 09:03 AM
I only do DOS because a lot of the programming I do is utilities and stuff. I originally learned how to program because my brother's mother in law had a virus on her computer, where the second you turned it on, it started creating directories. I made a batch file that would put itself as first priority (via something similar to that preprocessor directive where you can specify urgency of tasks), start deleting directories, and deletes the program. The program would install itself again somehow, but wouldn't start until you turned it on (Trojan Horse type thing). So the next time, it would continue deleteing the superfluous directories, and eventually everything was back to normal. When the directories were no longer there, I had a system where it would search out the program installer. Problem solved! I enjoyed doing it so much I started learning C. Anyway - I just do utilities in DOS because its very closely linked with the PC architecture itself. You don't have to keep programming in DOS. It's a personal choice really.

Sunny
06-09-2002, 09:08 PM
Mmm. .. I think I targeted my question at something else.
If there is however a large group of people who still
use DOS, for example?


C ya.

sean
06-09-2002, 09:39 PM
Oh yeah - a lot of people still use DOS. Most people think Windows is all there is (excluding Linux and all that - I'm talking Microsoft exclusive) because that's what most programmers learn about. But that's the reason itself why Assembly programmers are so highly paid - they're so rare nowadays.

VirtualAce
06-09-2002, 10:09 PM
Well I've been doing a lot of DirectX coding and let me tell you, assembly is still used. In fact my knowledge of assembly has helped me a lot in DirectX. Granted that the HEL probably performs what I want to do but just in case it does not I code my own.

For instance I coded my own bi-linear interpolation function for DirectX in assembly. Yes video cards do bi-linear interpolate but its always on textures which is no good for me. If you want to find the altitude of an object and you know the altitude of the four corners of the grid the object is in - and you know how far into the grid on x and y the object is, you can bi-linear interpolate to find the height of the object.




USHORT Bi_Linear(WORD v1,WORD v2,WORD v3,WORD v4,
double offset_x,double offset_y)
{
USHORT value1=0,value2=0,final_value=0;
__asm {

fild [v2]
fisub [v1]
fmul [offset_x]
fiadd [v1]
fistp [value1]

fild [v4]
fisub [v3]
fmul [offset_y]
fiadd [v3]
fistp [value2]

fild [value2]
fisub [value1]
fmul [offset_y]
fiadd [value1]
fistp [final_value]
}
return (final_value);
}



You could just as easily store final_value in the eax register to return it since this is where C looks for integral return values, but since I did this in inline assembly it looks more logical to use a return (and the compiler does not whine at me) instead of placing the correct value in the eax register (or st(0) for floating point values).

So assembly is not dead (might be used less in Direct3D, but I'm sure I'll still use some) - at least not for games where speed is the prime factor.

Zeeshan
06-09-2002, 11:08 PM
IMO, most people don't actually use DOS to run programs get their jobs done. They use DOS as a mezanine floor b/w nothing and windows. Infact, a majority of people using Windows don't even know a single DOS command.

It's just that they're stuck with DOS, whenever something wrong happens with their Macro.......... Winblows 98... :D

Hence, programming in DOS to learn programming in fine, as there is usually no overhead involved in writing DOS programs. You get what you write which is what you want. On the other hand, Windows programming involves much overhead.

However, writing software in DOS, other than for personal purposes is a BAD idea, b/c most people won't probably like it (ofcourse, b/c they're comparing it's features to all the basic charms that windows offers)...

sean
06-10-2002, 11:42 AM
Assembly and DOS will always be used a little as long as people use the current style of PC. They what everything else is built on. Right now, we have a really tall tower, and as long as people are going to use the tower and do maintenance on it, the foundations need maintenance as well.