[comp.lang.asm370] Interfacing from Ada to C to Assembler

tfrancis@wpi.wpi.edu (Krishan M Nainani) (09/16/89)

(Posted to comp.lang.ada and comp.lang.asm370 in the hopes that I'll get
a reply that will help my question.)

Hi Folks,


	I have been working on a project involving context switching of Ada
procedures. Essentially, my project consists of Ada procedures communicating
via messages (a uni-processor environment) so when procedure A performs some
calculations it sends the result(s) to procedure B. As a result, procedure B
should then be scheduled thereby leaving procedure A unfinished. Then, 
procedure B could perform some calculations and then send it's result(s) to
procedure C. Here comes the tricky part. Now, procedure C could use the 
message from B and then send it's result to procedure A which would then 
RESUME from where it left off earlier. Obviously, this is not single-thread
execution, instead this is a real-time system which allows the most important
procedure to execute next. 

	Since this system allows any procedure to call any other procedure
and then RESUME ANY other procedure (or start the procedure if it hasn't begun
yet), then this is going to be system dependant and this is acceptable.
However, this system involves using Assembler which does the context switch.
An added complication was required by the so-called "management" which 
demanded an interface from Ada to C to Assembler. So now, C routines
call the Assembler (context switch) routines. As a whole, Ada procedures
call the C routines which call the Assembler routines.

	There are actually two Assembler routines : initstk and swap.
INITSTK creates a procedure stack whereas swap performs a context switch
between procedure stacks. I have tried interfacing between Ada and Assmbler
and the results are perfect whereas the results obtained by interfacing
between Ada -> C -> Assembler are very dissapointing. The system crashes
repeatedly in the swap (assembler) routine.
---------------------------------------------

Can anyone provide me with (much needed) help or advice regarding the reason
for this crash before I spend a long time trying to debug this with the
MS-DOS debug tool since I cannot use CodeView (5.0) because CodeView does
not handle Ada code ?? Also, does anyone see any problems with this method?


BTW, I am using Alsys Ada (ver 4.2), an IBM-AT, with DOS 3.3 (MicroSoft)
and the 80286 chip (using the extended mode - NOT the Protected mode).

Krishan Nainani		(tfrancis@wpi.wpi.edu or tfrancis@wpi.bitnet)

tfrancis@WPI.WPI.EDU (Krishan M Nainani) (09/16/89)

(Posted to comp.lang.ada and comp.lang.asm370 in the hopes that I'll get
a reply that will help my question.)

Hi Folks,


        I have been working on a project involving context switching of Ada
procedures. Essentially, my project consists of Ada procedures communicating
via messages (a uni-processor environment) so when procedure A performs some
calculations it sends the result(s) to procedure B. As a result, procedure B
should then be scheduled thereby leaving procedure A unfinished. Then,
procedure B could perform some calculations and then send it's result(s) to
procedure C. Here comes the tricky part. Now, procedure C could use the
message from B and then send it's result to procedure A which would then
RESUME from where it left off earlier. Obviously, this is not single-thread
execution, instead this is a real-time system which allows the most important
procedure to execute next.

        Since this system allows any procedure to call any other procedure
and then RESUME ANY other procedure (or start the procedure if it hasn't begun
yet), then this is going to be system dependant and this is acceptable.
However, this system involves using Assembler which does the context switch.
An added complication was required by the so-called "management" which
demanded an interface from Ada to C to Assembler. So now, C routines
call the Assembler (context switch) routines. As a whole, Ada procedures
call the C routines which call the Assembler routines.

        There are actually two Assembler routines : initstk and swap.
INITSTK creates a procedure stack whereas swap performs a context switch
between procedure stacks. I have tried interfacing between Ada and Assmbler
and the results are perfect whereas the results obtained by interfacing
between Ada -> C -> Assembler are very dissapointing. The system crashes
repeatedly in the swap (assembler) routine.
---------------------------------------------

Can anyone provide me with (much needed) help or advice regarding the reason
for this crash before I spend a long time trying to debug this with the
MS-DOS debug tool since I cannot use CodeView (5.0) because CodeView does
not handle Ada code ?? Also, does anyone see any problems with this method?


BTW, I am using Alsys Ada (ver 4.2), an IBM-AT, with DOS 3.3 (MicroSoft)
and the 80286 chip (using the extended mode - NOT the Protected mode).

Krishan Nainani         (tfrancis@wpi.wpi.edu or tfrancis@wpi.bitnet)