turbo c help

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
jgmorford
Posts: 6
Joined: Mon Jun 06, 2005 11:00 pm

turbo c help

Post by jgmorford »

I'm to a point in my real-mode OS where I'm trying to load my command shell. In bochs, it works exactly as it should. But when I give it control on real hardware, I get the message 'Abnormal Program Termination', and the program returns to the kernel with a return code of 3. The shell is compiled to a tiny model com file using turbo c.

Anybody have any idea what could be the cause of this?

When I pass execution cs, es, ds, ss = PSP, sp = 0xFFFE, ip = 0x0100. Memory block is 64K. The only thing in the PSP that I haven't initialized is the environment block.
User avatar
carbonBased
Member
Member
Posts: 382
Joined: Sat Nov 20, 2004 12:00 am
Location: Wellesley, Ontario, Canada
Contact:

Post by carbonBased »

That would really depend on what this shell does, and what your OS has deemed an abnormal program termination, and what the return code of 3 means.

Any more detail on these would be handy.

--Jeff
jgmorford
Posts: 6
Joined: Mon Jun 06, 2005 11:00 pm

Post by jgmorford »

As far as what I've written, all it should do is read in a command from stdin, and then try to execute the command through an EXEC call identical to DOS.

The problem seems to be in some initialization code added by the compiler. When the program starts in Bochs, it gets the system version (which returns the equivalent of DOS 2.0), gets the interrupt values of 0x22, 0x23, and 0x24, then sets int 0x00. After that, it resizes the memory block and executes my command prompt, like so:

Code: Select all

fdd: INFO - FDD Command Byte 5: 2
fdd: INFO - FDD Command Byte 6: 0
fdd: INFO - FDD Command Byte 7: 0
fdd: INFO - FDD Command Byte 8: 255
dev: INFO - IOCTL call completed.
sys: INFO - Setting interrupt 0.
Regress Operating System 0.1
Copyright(C) 2004-2006 John G. Morford
A:\>fdd: INFO - Stopping floppy drive motors

dev: INFO - Making IOCTL call 4 to device 0.
dev: WARN - IOCTL call 4 to device 0 failed.
Command invalid.

A:\>exit
sys: INFO - Setting interrupt 0.
sys: INFO - Setting interrupt 4.
sys: INFO - Setting interrupt 5.
sys: INFO - Setting interrupt 6.
sys: INFO - Setting interrupt 34.
sys: INFO - Setting interrupt 35.
sys: INFO - Setting interrupt 36.
Program exit code: 0
Press ctl-alt-del to reboot.
When it executes on real hardware, it craps out at the point that it should be resizing the memory block, writes 'Abnormal Program Termination' to stdout, then exits with al=3. My command line code never executes. So something is happening in the stub the compiler added that's causing the program to bomb. I can't find any information on what the return code of 3 is supposed to indicate, nor can I find anything on what turbo c adds to initialize the program.

So, I guess I'm really asking the same thing you are Jeff. Does anyone know what turbo c does to initialize a DOS program, and what does a return code of 3 mean?
jgmorford
Posts: 6
Joined: Mon Jun 06, 2005 11:00 pm

Post by jgmorford »

Never mind. Found my problem. I was overwriting the next memory block's header when setting up the stack in the EXEC routine. Works fine now.
Post Reply