Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using C functions in a TSR program

41 views
Skip to first unread message

nomed...@gmail.com

unread,
Nov 14, 2007, 9:41:16 AM11/14/07
to
Hi. I'm coding a TSR program using turbo C++ version 3.0. I'm using
getvect(), setvect() and keep() functions to do it... i hooked the
timer interupt (8h)...
in my function i have some C function calls, but they don't work...
functions like fopen(), printf(), etc...
I already did a search here in the group by the answer but it isn't so
clear to me... i have to use fopen() in my program, but when i try to
use it, the system hangs... when i try to use printf() the system
reboots... and so on...
Does anyone can help telling how can i use C functions in this case??
I already read many things here in the group, but nothing is clear to
me... =(

Tanks a lot

Patrick Klos

unread,
Nov 14, 2007, 10:44:03 AM11/14/07
to
In article <1195051276.3...@k79g2000hse.googlegroups.com>,

You cannot necessarily make DOS (INT 21h) calls from your timer interrupt
hook. Creating a TSR that can use the timer and access DOS functions is
a little more complex than that. There is an "IN DOS" flag you'll need to
check and keep track of, or you can keep track yourself by hooking INT 21h
and keeping your own flag. Look for Ralf Brown's interrupt list or some
old DOS books for more details.

Patrick
========= For LAN/WAN Protocol Analysis, check out PacketView Pro! =========
Patrick Klos Email: pat...@klos.com
Klos Technologies, Inc. Web: http://www.klos.com/
============================================================================

nomed...@gmail.com

unread,
Nov 14, 2007, 11:21:28 AM11/14/07
to
On Nov 14, 1:44 pm, pk...@osmium.mv.net (Patrick Klos) wrote:
> In article <1195051276.318659.252...@k79g2000hse.googlegroups.com>,

>
> nomedeu...@gmail.com <nomedeu...@gmail.com> wrote:
> >Hi. I'm coding a TSR program using turbo C++ version 3.0. I'm using
> >getvect(), setvect() and keep() functions to do it... i hooked the
> >timer interupt (8h)...
> >in my function i have some C function calls, but they don't work...
> >functions like fopen(), printf(), etc...
> >I already did a search here in the group by the answer but it isn't so
> >clear to me... i have to use fopen() in my program, but when i try to
> >use it, the system hangs... when i try to use printf() the system
> >reboots... and so on...
> >Does anyone can help telling how can i use C functions in this case??
> >I already read many things here in the group, but nothing is clear to
> >me... =(
>
> >Tanks a lot
>
> You cannot necessarily make DOS (INT 21h) calls from your timer interrupt
> hook. Creating a TSR that can use the timer and access DOS functions is
> a little more complex than that. There is an "IN DOS" flag you'll need to
> check and keep track of, or you can keep track yourself by hooking INT 21h
> and keeping your own flag. Look for Ralf Brown's interrupt list or some
> old DOS books for more details.
>
> Patrick
> ========= For LAN/WAN Protocol Analysis, check out PacketView Pro! =========
> Patrick Klos Email: patr...@klos.com

> Klos Technologies, Inc. Web: http://www.klos.com/
> ============================================================================

Tanks to answer dude :)
Well.. so, i was trying to do something like this to check the InDOS
flag:

this before stay resident:
in.h.ah = 0x34;
intdosx(&in, &out, &out2);

and this after stay resident:
// is this check correct???? to check the InDOS flag...
if(*(char far *)(out2.es + out.x.bx) == 0)
printf("hello");


Well... i'm not sure if it is correct or not =(

All the code (it's very small) can be see at:

http://pastebin.com/m5a7c14d

Tanks again...

pe...@nospam.demon.co.uk

unread,
Nov 15, 2007, 12:52:25 AM11/15/07
to
In article <1195057288.9...@o3g2000hsb.googlegroups.com>
nomed...@gmail.com " "nomed...@gmail.com"" writes:

> On Nov 14, 1:44 pm, pk...@osmium.mv.net (Patrick Klos) wrote:
> > In article <1195051276.318659.252...@k79g2000hse.googlegroups.com>,

[..]


> > You cannot necessarily make DOS (INT 21h) calls from your timer interrupt
> > hook. Creating a TSR that can use the timer and access DOS functions is
> > a little more complex than that. There is an "IN DOS" flag you'll need to
> > check and keep track of, or you can keep track yourself by hooking INT 21h
> > and keeping your own flag. Look for Ralf Brown's interrupt list or some
> > old DOS books for more details.
> >
> > Patrick
>

> Tanks to answer dude :)
> Well.. so, i was trying to do something like this to check the InDOS
> flag:
>
> this before stay resident:
> in.h.ah = 0x34;
> intdosx(&in, &out, &out2);
>
> and this after stay resident:
> // is this check correct???? to check the InDOS flag...
> if(*(char far *)(out2.es + out.x.bx) == 0)
> printf("hello");
>
>
> Well... i'm not sure if it is correct or not =(

It is not :-( You will need to convert ES:BX into a long pointer
(32 bits) to access that address. Something like

(((unsigned long)(out2.es)<<16) | (unsigned)(out.x.bx))

Your compiler might even have a MK_FP() macro to do this for you.

> All the code (it's very small) can be see at:
>
> http://pastebin.com/m5a7c14d
>
> Tanks again...

Pete
--
"We have not inherited the earth from our ancestors,
we have borrowed it from our descendants."

nomed...@gmail.com

unread,
Nov 19, 2007, 10:54:19 PM11/19/07
to
On 15 nov, 03:52, p...@nospam.demon.co.uk wrote:
> In article <1195057288.928785.267...@o3g2000hsb.googlegroups.com>

Well... I used MK_FP(), etc, and now I can call printf() for example
and the system doesn't hangs... but now there's another problem...
The printf() isn't printing what I'm telling to print, it's printing
some strange characters, for example, if I execute:

printf("Hello");

It prints things like:

!@#$%*()

I can't understand what is happening...

Tanks guys =)

Oh, and so sorry by my so bad english, it isn't my native language...
=(

pe...@nospam.demon.co.uk

unread,
Nov 20, 2007, 12:35:46 AM11/20/07
to
In article <71fcb793-f939-42a8...@d50g2000hsf.googlegroups.com>
nomed...@gmail.com "nomed...@gmail.com" writes:
[..]

> Well... I used MK_FP(), etc, and now I can call printf() for example
> and the system doesn't hangs... but now there's another problem...
> The printf() isn't printing what I'm telling to print, it's printing
> some strange characters, for example, if I execute:
>
> printf("Hello");
>
> It prints things like:
>
> !@#$%*()
>
> I can't understand what is happening...

My first guess would be that DS is wrong; I'm not sure how BC++ 3.0
handles segment registers when compiling a COM file (tiny model)
but would assume it sets SS = ES = DS = CS. So before you can call
any library function you'll have to reset DS to be equal to your
local CS (and perhaps the other segregs too).

On entry to your TSR code, you'll need something like:

enter_tsr:
push ds ;use caller's stack...
push ax
mov ax, cs
mov ds, ax
...
rest of your TSR code
...
pop ax
pop ds
iret

Also, be aware that you will be using caller's stack in your TSR
(unless you change it) and that some C functions like printf can
consume a lot of stack space -- perhaps more than is available.
You might therefore need to switch to a local stack for your TSR
code, and restore the original [entry] SS:SP on exit.

nomed...@gmail.com

unread,
Nov 20, 2007, 12:33:06 PM11/20/07
to
On 20 nov, 03:35, p...@nospam.demon.co.uk wrote:
> In article <71fcb793-f939-42a8-90e0-5ad27abe0...@d50g2000hsf.googlegroups.com>

Hum... i'm creating a .EXE, not a .COM...
But, you're telling that, for example, the data segment is point to
the code segment for example, and so, it's getting other things and
not my data that i want to print? Well... if so... i don't know if
could be it... well... it's more probably be the stack segment (SS)
because i'm passing the argument in the stack, right? ... well, anyway
i have no idea what i have to do =( i'm lost... but i'll continue
searching...
any help is welcome >=)

Tanks so much

nomed...@gmail.com

unread,
Nov 21, 2007, 12:11:31 PM11/21/07
to
On Nov 20, 3:33 pm, "nomedeu...@gmail.com" <nomedeu...@gmail.com>
wrote:

Wow! I got it! Just was needing compile with:

tcc -mc code.c

Compact mode..........
Pete, I think what you said was right!

Well... Tank you a lot!!! =)

nomed...@gmail.com

unread,
Nov 26, 2007, 10:52:38 AM11/26/07
to
On Nov 21, 3:11 pm, "nomedeu...@gmail.com" <nomedeu...@gmail.com>

wrote:
> On Nov 20, 3:33 pm, "nomedeu...@gmail.com" <nomedeu...@gmail.com>
> wrote:
>
>
>
> > On 20 nov, 03:35, p...@nospam.demon.co.uk wrote:
>
> > > In article <71fcb793-f939-42a8-90e0-5ad27abe0...@d50g2000hsf.googlegroups.com>
> > > nomedeu...@gmail.com "nomedeu...@gmail.com" writes:
> > > [..]
>
> > > > Well... I used MK_FP(), etc, and now I can call printf() for example
> > > > and the system doesn't hangs... but now there's another problem...
> > > > The printf() isn't printing what I'm telling to print, it's printing
> > > > some strange characters, for example, if I execute:
>
> > > > printf("Hello");
>
> > > > It prints things like:
>
> > > > !@#$%*()
>
> > > > I can't understand what is happening...
>
> > > My first guess would be that DS is wrong; I'm not sure how BC++ 3.0
> > > handles segment registers when compiling a COM file (tiny model)
> > > but would assume it sets SS = ES = DS = CS. So before you can call
> > > any library function you'll have to reset DS to be equal to your
> > > local CS (and perhaps the other segregs too).
>
> > > On entry to yourTSRcode, you'll need something like:

>
> > > enter_tsr:
> > > push ds ;use caller's stack...
> > > push ax
> > > mov ax, cs
> > > mov ds, ax
> > > ...
> > > rest of yourTSRcode
> > > ...
> > > pop ax
> > > pop ds
> > > iret
>
> > > Also, be aware that you will be using caller's stack in yourTSR
> > > (unless you change it) and that someCfunctionslike printf can

> > > consume a lot of stack space -- perhaps more than is available.
> > > You might therefore need to switch to a local stack for yourTSR
> > > code, and restore the original [entry] SS:SP on exit.
>
> > > Pete
> > > --
> > > "We have not inherited the earth from our ancestors,
> > > we have borrowed it from our descendants."
>
> > Hum... i'm creating a .EXE, not a .COM...
> > But, you're telling that, for example, the data segment is point to
> > the code segment for example, and so, it's getting other things and
> > not my data that i want to print? Well... if so... i don't know if
> > could be it... well... it's more probably be the stack segment (SS)
> > because i'm passing the argument in the stack, right? ... well, anyway
> > i have no idea what i have to do =( i'm lost... but i'll continue
> > searching...
> > any help is welcome >=)
>
> > Tanks so much
>
> Wow! I got it! Just was needing compile with:
>
> tcc -mc code.c
>
> Compact mode..........
> Pete, I think what you said was right!
>
> Well... Tank you a lot!!! =)

Well... the program can now call C functions... but after some time
running, the program hangs all the system...
I think it could be the time which a timer interruption is actived...
55 miliseconds... so, i think if my program run more than 55
miliseconds i think it could hangs the system... i have no idea if my
program is runing more than this...
and i have no idea if could be it that is hangs the system after some
time...

well...

but i have no idea if could be it...
Does anyone have some idea what could be?

The code is this (it's small):

http://pastebin.com/f74abb032

pe...@nospam.demon.co.uk

unread,
Nov 26, 2007, 2:50:17 PM11/26/07
to
In article <ec8fdd06-40a2-40e9...@y5g2000hsf.googlegroups.com>
nomed...@gmail.com "nomed...@gmail.com" writes:

[snip]


> Well... the program can now call C functions... but after some time
> running, the program hangs all the system...
> I think it could be the time which a timer interruption is actived...
> 55 miliseconds... so, i think if my program run more than 55
> miliseconds i think it could hangs the system... i have no idea if my
> program is runing more than this...
> and i have no idea if could be it that is hangs the system after some
> time...
>
> well...
>
> but i have no idea if could be it...
> Does anyone have some idea what could be?
>
> The code is this (it's small):
>
> http://pastebin.com/f74abb032

Your program doesn't need the overhead of the stdio library; I've
replaced the fopen() etc. with the lower level io equivalents
which, if timimg is the problem, might help. In any case the
code should be smaller :-)

And if timing is still an issue, try relocating your "stat" file
on a ramdisk -- access will likely be much quicker.

nomed...@gmail.com

unread,
Nov 26, 2007, 7:34:12 PM11/26/07
to
On 26 nov, 17:50, p...@nospam.demon.co.uk wrote:
> In article <ec8fdd06-40a2-40e9-995b-8c2144176...@y5g2000hsf.googlegroups.com>

Well, tanks for response Pete :)
So... i have no sure if is it, the timming, but i think could be it,
just think... have you already used C functions like i used in this
code?

i cant see anything wrong in it... i have no idea what could be going
wrong... it's just a thing i thought could be...
after some time running the system hangs, but just some time after
running, some seconds, sometimes some minutes......


well... anyway, could you give some examples on how can i use low
level equivalents? some examples, etc, equivalents to the functions
i'm using... i'll be too too much grateful!

Oh... and about the file "stat", i think i couldn't do it, because i
have to access this file remotely to write in it...
or could I?

Tanks you so much mate!

pe...@nospam.demon.co.uk

unread,
Nov 27, 2007, 1:38:31 AM11/27/07
to
In article <7529bf7a-af0f-4b56...@v4g2000hsf.googlegroups.com>
nomed...@gmail.com "nomed...@gmail.com" writes:

> Well, tanks for response Pete :)
> So... i have no sure if is it, the timming, but i think could be it,
> just think... have you already used C functions like i used in this
> code?

Not is a TSR program; I find asm more suited to the task.

> i cant see anything wrong in it... i have no idea what could be going
> wrong... it's just a thing i thought could be...
> after some time running the system hangs, but just some time after
> running, some seconds, sometimes some minutes......

Could be timing, could be stack overflow, could be...?

> well... anyway, could you give some examples on how can i use low
> level equivalents? some examples, etc, equivalents to the functions
> i'm using... i'll be too too much grateful!

I made some changes on the pastebin site -- I guess you can see
them there? Just used open(), read(), write() etc. instead of
what you had written.

> Oh... and about the file "stat", i think i couldn't do it, because i
> have to access this file remotely to write in it...
> or could I?
>
> Tanks you so much mate!

If your interrupt routine is taking too long, you should remove
the time-consuming code (e.g. file access) and replace it with
setting a flag or two, which your main (non-interrupt) code can
poll and take the required action.

nomed...@gmail.com

unread,
Nov 27, 2007, 7:24:03 AM11/27/07
to
On Nov 27, 4:38 am, p...@nospam.demon.co.uk wrote:
> In article <7529bf7a-af0f-4b56-91f4-5311b5e5b...@v4g2000hsf.googlegroups.com>

> nomedeu...@gmail.com "nomedeu...@gmail.com" writes:
>
>
>
>
>
> > On 26 nov, 17:50, p...@nospam.demon.co.uk wrote:
> > > In article <ec8fdd06-40a2-40e9-995b-8c2144176..
> > ....@y5g2000hsf.googlegroups.com>
> we have borrowed it from our descendants."- Hide quoted text -
>
> - Show quoted text -

Pete, I couldn't see your changes at the pastebin.com code...
but i tried to use open(), but it has the same problem, didn't
solve...

Well... have you already coded a C program that called this functions?

If yes, so here has to works too and i'll continue trying...

If no, i'll try to use INTs (low level equivalents, was what you said,
right?) like 21, function 3Dh, etc in the place of open() etc...

Tanks again

pe...@nospam.demon.co.uk

unread,
Nov 27, 2007, 2:39:05 PM11/27/07
to
In article <dd40c6fa-cb21-4847...@b40g2000prf.googlegroups.com>
nomed...@gmail.com "nomed...@gmail.com" writes:
[..]

> Pete, I couldn't see your changes at the pastebin.com code...
> but i tried to use open(), but it has the same problem, didn't
> solve...

I've not come across pastebin.com before, but just returned there
and selected the link to view follow-ups from "anon" [me] and the
changes I made are showing there...

> Well... have you already coded a C program that called this functions?

I frequently use read(), write() etc. when the power/flexibility
of fread()/fwrite()/fprintf() are not needed. You should see
from the changes I made at pastebin that I replaced

printf("Download");
with
write(1, "Download", 8);

for example. printf() in the implementations I've looked at
requires a fair amount of stack space (which write() does not)
and it is things like this that *might* be breaking your TSR.

> If yes, so here has to works too and i'll continue trying...
>
> If no, i'll try to use INTs (low level equivalents, was what you said,
> right?) like 21, function 3Dh, etc in the place of open() etc...

That would of course be even smaller/faster, but decent
implementations of open(), read() etc. will do just that: set up
the regs and call the appropriate DOS service.

> Tanks again

My pleasure; I hope you can find what is causing the failure and
fix it!

nomed...@gmail.com

unread,
Nov 27, 2007, 5:28:01 PM11/27/07
to
On 27 nov, 17:39, p...@nospam.demon.co.uk wrote:
> In article <dd40c6fa-cb21-4847-a1cb-28ab53d59...@b40g2000prf.googlegroups.com>

Hi Pete! So... I wrote the code using INTs and it's running better
now, but not 100%...
For example, if do consecultives CTRL + C at the prompt, after some
time the system
hangs... the same happen if I insure the ENTER key... and I can't run
a application that I have
together with it, but comands like dir, cls, etc etc works well and
the system doesn't hang if
I don't do the things i said above...

The problem is that i have to run this program together with the
TSR...
Memory, I verified, isn't the problem... there's sufficient space to
the two...

And again, I have no idea what can be... :P
But I'll be searching for the problem...


Any idea mate?? Tanks a lot!

pe...@nospam.demon.co.uk

unread,
Nov 28, 2007, 1:11:19 AM11/28/07
to
In article <0511af26-8373-4a51...@w40g2000hsb.googlegroups.com>
nomed...@gmail.com "nomed...@gmail.com" writes:

[..]


> Hi Pete! So... I wrote the code using INTs and it's running better
> now, but not 100%...
> For example, if do consecultives CTRL + C at the prompt, after some
> time the system
> hangs... the same happen if I insure the ENTER key... and I can't run
> a application that I have
> together with it, but comands like dir, cls, etc etc works well and
> the system doesn't hang if
> I don't do the things i said above...
>
> The problem is that i have to run this program together with the
> TSR...
> Memory, I verified, isn't the problem... there's sufficient space to
> the two...
>
> And again, I have no idea what can be... :P
> But I'll be searching for the problem...

From your observations of pressing ^C, perhaps you should be
monitoring DOS's crtical error flag as well as InDos. I assume
you have a copy of Ralf Brown's Interrupt List (search for RBIL
if not) and take a look at the comments for Int 21h/AH=34h and
also the entry for Int 21h/AX=5d06h. Both flags should be clear
before requesting a DOS service.

nomed...@gmail.com

unread,
Nov 28, 2007, 6:11:38 AM11/28/07
to
On Nov 28, 4:11 am, p...@nospam.demon.co.uk wrote:
> In article <0511af26-8373-4a51-a308-d7a41243b...@w40g2000hsb.googlegroups.com>

> nomedeu...@gmail.com "nomedeu...@gmail.com" writes:
>
>
>
>
>
> > On 27 nov, 17:39, p...@nospam.demon.co.uk wrote:
> > > In article <dd40c6fa-cb21-4847-a1cb-28ab53d59..
> > ....@b40g2000prf.googlegroups.com>

Hi Pete, so... I tried to use 5D06h function to get the errorFlag, so,
i did this way:

regs.x.ax = 0x5D06;
int86x(0x21, &regs, &regs, &sregs);
errorFlag = (char far *)MK_FP(sregs.es, regs.x.bx);

But I'm getting the same address that InDOS flag... 321. I read some
places that errorFlag is ever 1 byte before the InDOS flag... so i
tried to decrement InDOS flag and i got 320, but in this place it
*ever* has 1.
I searched for some more information about the error flag and I
couldn't find more things about...

nomed...@gmail.com

unread,
Nov 28, 2007, 6:48:52 AM11/28/07
to
On Nov 28, 9:11 am, "nomedeu...@gmail.com" <nomedeu...@gmail.com>
wrote:

Let me tell just one more thing. I have a program that use all the
screen and stay running, like
EDIT for example.

Well... when I run the TSR and run the EDIT, the two run normally and
the system doesn't hang.
If i run the TSR together with this program I said, the system
hangs...

I realized that if I don't use INT function to open the file, the
system doesn't hang...
I can run printf() and the two, TSR and the application run normally,
but if I use the INT to open
the file, and run the TSR and the application, the system hangs.

nomed...@gmail.com

unread,
Nov 28, 2007, 7:06:15 AM11/28/07
to
On Nov 28, 9:48 am, "nomedeu...@gmail.com" <nomedeu...@gmail.com>

The actual code is this:

http://pastebin.com/f396d5ab5

nomed...@gmail.com

unread,
Nov 28, 2007, 10:57:05 AM11/28/07
to
On Nov 28, 10:06 am, "nomedeu...@gmail.com" <nomedeu...@gmail.com>

Sorry,

errorFlag = (char far *)MK_FP(sregs.es, regs.x.bx);

No, i used this:

errorFlag = (char far *)MK_FP(sregs.ds, regs.x.si);


DS and SI I used, but it didn't solve the problem =(

It's returning the correct address of the critical error flag (320,
the InDOS flag is 321)

But i checked the two before execute the code, but didn't solve =(

nomed...@gmail.com

unread,
Nov 29, 2007, 8:20:44 AM11/29/07
to
On Nov 28, 1:57 pm, "nomedeu...@gmail.com" <nomedeu...@gmail.com>

Any idea?? :(

nomed...@gmail.com

unread,
Dec 4, 2007, 5:48:43 AM12/4/07
to
On Nov 29, 11:20 am, "nomedeu...@gmail.com" <nomedeu...@gmail.com>

I tried to store and restore the SDA... but didnt work too...

Someone??

Rod Pemberton

unread,
Dec 4, 2007, 5:46:08 PM12/4/07
to

<nomed...@gmail.com> wrote in message
news:44587fe5-a5c9-41d5...@d4g2000prg.googlegroups.com...

> I tried to store and restore the SDA... but didnt work too...
>
> Someone??

Andrew Schulman's book on undocumented DOS is supposedly the primary source
for info on using these calls.

Ralf Brown's interrupt list has some info too (via DJ Delorie' DJGPP site):
http://www.delorie.com/djgpp/doc/rbinter/id/35/30.html
http://www.delorie.com/djgpp/doc/rbinter/id/40/30.html

I've not used these, but, from what I can tell, you check InDos and Critical
Error flags. If not in dos or critical error routines, then you get the
size of the swappable dos area (SDA), small or large, and then save it by
copying it somewhere. Then, you call your int 0x21 function. Restore the
original SDA and return from your routine to DOS. The dos version numbers
are used to decide whether to call 5d06 or 5d0b (4.0 only). I've seen
mentions of needing to switch stacks, setting the disk transfer address
(DTA), and setting the program segment prefix (PSP), but have no idea
whether these are required or not...

There' only a handful of programs I've found that use 5d0b or 5d06. But,
they use the call to locate other data structures relative to the start of
the DSA or for the critical error flag, not for swapping DOS in and out.

BOSSv2 uses 5d0b,5d06. The source is cpp. It appears to be source for a
GPL'd DOS task switcher circa 1995. Unfortunately, Section 19 of boss.cpp
is missing... The page is in Chinese. I'm not sure where the original
source is located.
http://post.baidu.com/f?kz=10822377

"Display Saver Version 4.52" by Alexey Kulentsov and Alexey Pavlov use 5d06.
The source is assembly. The documentation and code comments in Russian...
The files are dsa.zip (or dsa.rar) and dsa2.zip. I've found a few .ru sites
that list them, but I can't find any site that has them even though I
downloaded them about two years ago... Someone sent one as .uue through an
NG, but the uue portion was removed... Sometimes there is a tag line like:
"DOS Swappable Data Area Example (File work in TSR)."


Rod Pemberton

nomed...@gmail.com

unread,
Dec 4, 2007, 9:34:49 PM12/4/07
to
On Dec 4, 8:46 pm, "Rod Pemberton" <do_not_h...@nohavenot.cmm> wrote:
> <nomedeu...@gmail.com> wrote in message

>
> news:44587fe5-a5c9-41d5...@d4g2000prg.googlegroups.com...
>
> > I tried to store and restore the SDA... but didnt work too...
>
> > Someone??
>
> Andrew Schulman's book on undocumented DOS is supposedly the primary source
> for info on using these calls.
>
> Ralf Brown's interrupt list has some info too (via DJ Delorie' DJGPP site):http://www.delorie.com/djgpp/doc/rbinter/id/35/30.htmlhttp://www.delorie.com/djgpp/doc/rbinter/id/40/30.html

>
> I've not used these, but, from what I can tell, you check InDos and Critical
> Error flags. If not in dos or critical error routines, then you get the
> size of the swappable dos area (SDA), small or large, and then save it by
> copying it somewhere. Then, you call your int 0x21 function. Restore the
> original SDA and return from your routine to DOS. The dos version numbers
> are used to decide whether to call 5d06 or 5d0b (4.0 only). I've seen
> mentions of needing to switch stacks, setting the disk transfer address
> (DTA), and setting the program segment prefix (PSP), but have no idea
> whether these are required or not...
>
> There' only a handful of programs I've found that use 5d0b or 5d06. But,
> they use the call to locate other data structures relative to the start of
> the DSA or for the critical error flag, not for swapping DOS in and out.
>
> BOSSv2 uses 5d0b,5d06. The source is cpp. It appears to be source for a
> GPL'd DOS task switcher circa 1995. Unfortunately, Section 19 of boss.cpp
> is missing... The page is in Chinese. I'm not sure where the original
> source is located.http://post.baidu.com/f?kz=10822377

>
> "Display Saver Version 4.52" by Alexey Kulentsov and Alexey Pavlov use 5d06.
> The source is assembly. The documentation and code comments in Russian...
> The files are dsa.zip (or dsa.rar) and dsa2.zip. I've found a few .ru sites
> that list them, but I can't find any site that has them even though I
> downloaded them about two years ago... Someone sent one as .uue through an
> NG, but the uue portion was removed... Sometimes there is a tag line like:
> "DOS Swappable Data Area Example (File work in TSR)."
>
> Rod Pemberton

Tanks for reply!

Well... i already did it... i check InDos flag and ErrorFlag and if
they aren't true, so i save the current SDA, change the SDA to my
TSR's SDA (that i got in main() function...) and in the end of the TSR
i restore the original SDA...

But it didnt solve my problem =(

I have no more idea what could be the problem... i'll post the code
tomorrow... if someone could see it...

Tanks so much!

pe...@nospam.demon.co.uk

unread,
Dec 5, 2007, 1:18:51 AM12/5/07
to
In article <a59c08d5-b799-4698...@e67g2000hsc.googlegroups.com>
nomed...@gmail.com "nomed...@gmail.com" writes:

> On Dec 4, 8:46 pm, "Rod Pemberton" <do_not_h...@nohavenot.cmm> wrote:

[snip useful stuff on SDA]

> Tanks for reply!
>
> Well... i already did it... i check InDos flag and ErrorFlag and if
> they aren't true, so i save the current SDA, change the SDA to my
> TSR's SDA (that i got in main() function...) and in the end of the TSR
> i restore the original SDA...
>
> But it didnt solve my problem =(
>
> I have no more idea what could be the problem... i'll post the code
> tomorrow... if someone could see it...
>
> Tanks so much!

How are you compiling this code? I think you're using tcc (which
I don't have, but I do have bcc) and I believe this latter
includes by default stack checking -- I think you would not want
this in a TSR (and any other such like library code).

Using bcc one can suppress stack checking with -N- on the compile
command line, is it the same for tcc? Perhaps you should look
through all the options and enable/disable those as appropriate.
Maybe even do a search for "tcc tsr compile flags" or some such.

nomed...@gmail.com

unread,
Dec 6, 2007, 7:53:42 PM12/6/07
to
On Dec 5, 4:18 am, p...@nospam.demon.co.uk wrote:
> In article <a59c08d5-b799-4698-8d62-760e283b1...@e67g2000hsc.googlegroups.com>

> nomedeu...@gmail.com "nomedeu...@gmail.com" writes:
>
> > On Dec 4, 8:46 pm, "Rod Pemberton" <do_not_h...@nohavenot.cmm> wrote:
>
> [snip useful stuff on SDA]
>
> > Tanks for reply!
>
> > Well... i already did it... i check InDos flag and ErrorFlag and if
> > they aren't true, so i save the current SDA, change the SDA to my
> >TSR'sSDA (that i got in main() function...) and in the end of theTSR

> > i restore the original SDA...
>
> > But it didnt solve my problem =(
>
> > I have no more idea what could be the problem... i'll post the code
> > tomorrow... if someone could see it...
>
> > Tanks so much!
>
> How are you compiling this code? I think you're using tcc (which
> I don't have, but I do have bcc) and I believe this latter
> includes by default stack checking -- I think you would not want
> this in aTSR(and any other such like library code).

>
> Using bcc one can suppress stack checking with -N- on the compile
> command line, is it the same for tcc? Perhaps you should look
> through all the options and enable/disable those as appropriate.
> Maybe even do a search for "tcctsrcompile flags" or some such.

>
> Pete
> --
> "We have not inherited the earth from our ancestors,
> we have borrowed it from our descendants."


I think it isnt the problem, because i'm no using it more, i'm using
asm { ... } and calling the interruptions directelly... like this:


asm {
mov ah, 3Dh // to open a file
mov al, 0 // read
...
int 21h
}


If i use INT 21h to print something in the screen the system doesnt
hang when i run the TSR together with the other program...
It just hangs when i use the INT 21h to open a file and run together
with the other program...

Any idea? :(((

nomed...@gmail.com

unread,
Dec 6, 2007, 7:56:06 PM12/6/07
to
On Dec 6, 10:53 pm, "nomedeu...@gmail.com" <nomedeu...@gmail.com>
wrote:
> hang when i run theTSRtogether with the other program...

> It just hangs when i use the INT 21h to open a file and run together
> with the other program...
>
> Any idea? :(((

Oh! And yes, i'm using tcc... i'm compiling this way:

tcc -mc mycode.c

0 new messages