comp.lang.ada
 help / color / mirror / Atom feed
* What's wrong with this simple Ada w/ assembly code?
@ 1999-03-03  0:00 Josh Highley
  1999-03-04  0:00 ` robert_dewar
                   ` (3 more replies)
  0 siblings, 4 replies; 27+ messages in thread
From: Josh Highley @ 1999-03-03  0:00 UTC (permalink / raw)


  I'm trying to link some really simple assembly code with Ada.  I 
haven't been able to find any good examples or explanations on how to do 
this.  I didn't want to do it, but I guess this is the quickest way to 
get a solution that I can then work/experiment with.  I think I'm close 
to getting this but I'm not sure what I need to do.  I want to use 
assembly to position the cursor on the screen.  At this point, I've 
hard-coded the location into the code, but after I get this working, 
I'll pass a row and column from the Ada program.  Here's the code I've 
been experimenting with:

; I have A86 on my PC so my assembly code is a .com   I have access to 
; MASM, though, if needed.  "moveto.asm":

page 60, 132
title moveto
codesg segment para 'code'
   assume cs:codesg, ds:codesg, ss:codesg, es:codesg
   org 100h
   jmp moveto
;-------------------
 row db 15
 col db 20
;-------------------
moveto proc near
   mov ah, 02h
   mov bh, 00
   mov dh, row
   mov dl, col
   int 10h

   mov ax, 4C00h
   int 21h
moveto endp
codesg ends
end
-------------------------------------------------------------------
Here's the Ada code.  I'm using GNAT 3.11, AdaGIDE 6.21, and Win95.
-----------------
with ada.text_io;
use ada.text_io;

procedure assembly_test is
    pragma Linker_Options("c:/gnat311/programs/moveto.obj");
        procedure moveto;
        pragma import (Assembler, moveto, "moveto");
begin  -- assembly_test
    moveto;
    put("Here it is.");
end assembly_test;
-------------------------

Everything I have so far is from a response to a less specific assembly 
with Ada question I posed earlier, and from looking at a few packages 
that link C code. I assembled the code using A86 to a .com file which 
also yielded an .obj file and .sym file.  The Ada compiles fine, but 
when I build it, I get the message "c:/gnat311/programs/moveto.obj: file 
not recognized: File format not recognized    gnatmake: *** link failed"
  
What do I need to do to make this code work? Also, are there any books 
or Internet sources that have good explanations and/or examples on 
using assembly from Ada? I hate to keep bothering this newsgroup with 
questions that are no doubt basic to people who know how to do this.

Thanks,

Josh Highley
joshhighley@hotmail.com





^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: What's wrong with this simple Ada w/ assembly code?
  1999-03-04  0:00   ` Mike Silva
  1999-03-04  0:00     ` Josh Highley
@ 1999-03-04  0:00     ` Samuel Mize
  1999-03-04  0:00       ` Tom Moran
  1999-03-04  0:00     ` robert_dewar
  1999-03-08  0:00     ` Matthew Heaney
  3 siblings, 1 reply; 27+ messages in thread
From: Samuel Mize @ 1999-03-04  0:00 UTC (permalink / raw)


Mike Silva <mjsilva@jps.net> wrote:
> 
> robert_dewar@my-dejanews.com wrote in message
> <7bm0kb$8uj$1@nnrp1.dejanews.com>...
>>
>>GNAT simply follows the standard ABI, so if you follow
>>this you should have no trouble. If you don't know the
>>ABI, you are indeed wandering in the dark.
> 
> 
> What exactly is ABI?  I've haven't found the term in the ARM or Rationale or
> any of my books.

Application Binary Interface, if I recall correctly.  It's a standard
that defines how systems utilities are called, at the assembler level.

All the system routines will follow a consistent set of rules about how
they are to be called.  These define, for instance, what order parameters
should be on the stack, whether the caller has shifted the stack pointer
before making the call, and so on.

You *have* to follow these rules to make system calls from assembler (and
your compiler has to follow them to make those system calls for you).

You can make up your own rules for your own assembler subroutines, but
you'd be stupid to do so (in most cases).  The smartest thing is to find
out how your operating system expects subroutine calls to be coded, and
code your assembly that way.

If you do so, you're also coding it the way the compiler expects things
to be done.  So, an assembly routine that's coded in accordance with
the ABI can be called by other assembly routines, or by routines coded
in any language, if you have a half-decent compiler (or better).

Best,
Sam Mize

-- 
Samuel Mize -- smize@imagin.net (home email) -- Team Ada
Fight Spam: see http://www.cauce.org/ \\\ Smert Spamonam




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: What's wrong with this simple Ada w/ assembly code?
  1999-03-04  0:00     ` Samuel Mize
@ 1999-03-04  0:00       ` Tom Moran
  1999-03-05  0:00         ` robert_dewar
  0 siblings, 1 reply; 27+ messages in thread
From: Tom Moran @ 1999-03-04  0:00 UTC (permalink / raw)


>Application Binary Interface, if I recall correctly.  It's a standard
>that defines how systems utilities are called, at the assembler level.
The original poster's code did not call any system utilities via any
ABI (unless you call a DOS int 10 call part of the ABI) and did not
pass any parameters, so there's no question of order, who pops the
stack, etc.   
  I thought that sort of thing was what Convention was about.  In any
case, I think the original question, so far unanswered, is how to link
something generated in the standard ways, with Gnat.  If it won't even
link, it's irrelevant whether it will run.




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: What's wrong with this simple Ada w/ assembly code?
  1999-03-04  0:00   ` Mike Silva
  1999-03-04  0:00     ` Josh Highley
  1999-03-04  0:00     ` Samuel Mize
@ 1999-03-04  0:00     ` robert_dewar
  1999-03-05  0:00       ` Mike Silva
  1999-03-08  0:00     ` Matthew Heaney
  3 siblings, 1 reply; 27+ messages in thread
From: robert_dewar @ 1999-03-04  0:00 UTC (permalink / raw)


In article <7bmb69$1bh$1@its.hooked.net>,
  "Mike Silva" <mjsilva@jps.net> wrote:
> What exactly is ABI?

Application Binary Interface.

Don't leave home without it if you are writing in assembly
language!

It is the contract that expresses how data is stored, and
passed between procedures, amongst many other things

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: What's wrong with this simple Ada w/ assembly code?
  1999-03-03  0:00 What's wrong with this simple Ada w/ assembly code? Josh Highley
  1999-03-04  0:00 ` robert_dewar
@ 1999-03-04  0:00 ` Tom Moran
  1999-03-04  0:00   ` robert_dewar
  1999-03-06  0:00 ` Nick Roberts
  1999-03-07  0:00 ` Jerry van Dijk
  3 siblings, 1 reply; 27+ messages in thread
From: Tom Moran @ 1999-03-04  0:00 UTC (permalink / raw)


>using assembly from Ada? I hate to keep bothering this newsgroup with 
>questions that are no doubt basic to people who know how to do this.
Of whom there are few ;)  Unfortunately, this is compiler-specific.
I'd hazard a guess that Gnat would be happy with the GNU assembler.




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: What's wrong with this simple Ada w/ assembly code?
  1999-03-03  0:00 What's wrong with this simple Ada w/ assembly code? Josh Highley
@ 1999-03-04  0:00 ` robert_dewar
  1999-03-04  0:00   ` Mike Silva
  1999-03-04  0:00 ` Tom Moran
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 27+ messages in thread
From: robert_dewar @ 1999-03-04  0:00 UTC (permalink / raw)


In article <36ddb9aa.0@silver.truman.edu>,
  joshhighley@hotmail.com (Josh Highley) wrote:
>   I'm trying to link some really simple assembly code
> with Ada.  I haven't been able to find any good examples
> or explanations on how to do this.

GNAT simply follows the standard ABI, so if you follow
this you should have no trouble. If you don't know the
ABI, you are indeed wandering in the dark.

For some illumination, look at the assembly code generated
by GNAT, the easiest way to do this is with

objdump --source file.o


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: What's wrong with this simple Ada w/ assembly code?
  1999-03-04  0:00 ` Tom Moran
@ 1999-03-04  0:00   ` robert_dewar
  0 siblings, 0 replies; 27+ messages in thread
From: robert_dewar @ 1999-03-04  0:00 UTC (permalink / raw)


In article <36de1e0e.43769384@news.pacbell.net>,
  tmoran@bix.com (Tom Moran) wrote:
> Unfortunately, this is compiler-specific. I'd hazard a
> guess that Gnat would be happy with the GNU assembler.

The guess is true but irrelevant,
GNAT could not care less what
compiler or assembler is used provided that the standard
system ABI is properly followed. It is hard to believe that
this is not pretty standard *across* compilers!

If you are writing an assembler module, as opposed to
trying to use System.Machine_Code, then your solution, if
done properly should in fact be pretty portable across
compilers.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: What's wrong with this simple Ada w/ assembly code?
  1999-03-04  0:00 ` robert_dewar
@ 1999-03-04  0:00   ` Mike Silva
  1999-03-04  0:00     ` Josh Highley
                       ` (3 more replies)
  0 siblings, 4 replies; 27+ messages in thread
From: Mike Silva @ 1999-03-04  0:00 UTC (permalink / raw)



robert_dewar@my-dejanews.com wrote in message
<7bm0kb$8uj$1@nnrp1.dejanews.com>...
>
>GNAT simply follows the standard ABI, so if you follow
>this you should have no trouble. If you don't know the
>ABI, you are indeed wandering in the dark.


What exactly is ABI?  I've haven't found the term in the ARM or Rationale or
any of my books.  This sounds related to something I've wondered about,
which is how do the Ada language interface packages know how to communicate
with functions written in other languages.  Does ABI relate to how
parameters and return values are passed between functions?

Mike







^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: What's wrong with this simple Ada w/ assembly code?
  1999-03-04  0:00   ` Mike Silva
@ 1999-03-04  0:00     ` Josh Highley
  1999-03-04  0:00     ` Samuel Mize
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 27+ messages in thread
From: Josh Highley @ 1999-03-04  0:00 UTC (permalink / raw)


  So, is my Ada code ok? I'm not sure about the pragmas since I'm 
teaching myself as I go about linking assembly with ada.  Or should I 
try using object code produced from MASM?  I have no idea what ABI is, 
where can I find some info on it?

Thanks 

Josh Highley
joshhighley@hotmail.com





^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: What's wrong with this simple Ada w/ assembly code?
  1999-03-05  0:00       ` Mike Silva
@ 1999-03-05  0:00         ` Ed Falis
  0 siblings, 0 replies; 27+ messages in thread
From: Ed Falis @ 1999-03-05  0:00 UTC (permalink / raw)


On Fri, 5 Mar 1999 08:41:46 -0800, "Mike Silva" <mjsilva@jps.net> wrote:
> Is there, then, exactly one ABI per architecture, as would seem to be
> necessary?  How and where are these standardised?
> 
> Again my thanks to the helpful folks on this group -- maybe someday *I'll*
> be able to answer questions here!
> 
> Mike
> 
> 
> 

Nope.  Let's take windows as an example.  MS defines a number of calling conventions that affect how parameters are passed.  The most important / common ones 
are cdecl (for most calls) and stdcall (for winapi calls).  They differ in their parameter passing conventions.  Then we get into niceties around how link names are 
mangled.  DLL's are mangled differently than other names for the same convention.  C++ member names are further mangled.  And if you use a non-MS compiler, you 
often get yet another name mangling scheme.

For our window products, we just took a "most commonly used" approach of providing language names cdecl, stdcall, dll_cdecl and dll_stdcall, with the option of 
overriding either the name to be mangled or the actual linker symbol generated.  We also provided the synonyms C and DLL corresponding to the two cdecl variants.

So, at least in this case there isn't a single convention.  But windows is worse in this regard than most.

- Ed




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: What's wrong with this simple Ada w/ assembly code?
  1999-03-04  0:00       ` Tom Moran
@ 1999-03-05  0:00         ` robert_dewar
  1999-03-05  0:00           ` Tom Moran
  0 siblings, 1 reply; 27+ messages in thread
From: robert_dewar @ 1999-03-05  0:00 UTC (permalink / raw)


In article <36def294.13811899@news.pacbell.net>,
  tmoran@bix.com (Tom Moran) wrote:
> The original poster's code did not call any system
> utilities via any ABI

SO what, it got called, a callee has to know the rules
just as much as a caller!

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: What's wrong with this simple Ada w/ assembly code?
  1999-03-05  0:00         ` robert_dewar
@ 1999-03-05  0:00           ` Tom Moran
  0 siblings, 0 replies; 27+ messages in thread
From: Tom Moran @ 1999-03-05  0:00 UTC (permalink / raw)


>> The original poster's code did not call any system
>> utilities via any ABI

>SO what, it got called, a callee has to know the rules
>just as much as a caller!
Since his code was called with zero parameters, and he did not return,
but rather called DOS's Terminate call (with correct calling
convention), his program did not violate any apparent rules.  

>I get the message "c:/gnat311/programs/moveto.obj: file 
>not recognized: File format not recognized    gnatmake: *** link failed"
That sounds to me like he wants to know how to link, not how to
call/be called.  Will anyone help him out?   Should he ask instead on
the Gnat mailing list (the DOS one perhaps?).  Or must he switch to
one of the Ada compilers that does accept obj files? 




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: What's wrong with this simple Ada w/ assembly code?
  1999-03-04  0:00     ` robert_dewar
@ 1999-03-05  0:00       ` Mike Silva
  1999-03-05  0:00         ` Ed Falis
  0 siblings, 1 reply; 27+ messages in thread
From: Mike Silva @ 1999-03-05  0:00 UTC (permalink / raw)



robert_dewar@my-dejanews.com wrote in message
<7bn1fd$7pq$1@nnrp1.dejanews.com>...
>In article <7bmb69$1bh$1@its.hooked.net>,
>  "Mike Silva" <mjsilva@jps.net> wrote:
>> What exactly is ABI?
>
>Application Binary Interface.
>
>Don't leave home without it if you are writing in assembly
>language!
>
>It is the contract that expresses how data is stored, and
>passed between procedures, amongst many other things


Thanks for the answer -- now, for a followup question:  do the Ada interface
packages to other languages all assume that the other languages follow ABI
as well?  I've wondered how Ada compiler X can know how to call a function
created by C compiler Y, but if ABI is assumed on both ends it would make
sense.

Is there, then, exactly one ABI per architecture, as would seem to be
necessary?  How and where are these standardised?

Again my thanks to the helpful folks on this group -- maybe someday *I'll*
be able to answer questions here!

Mike







^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: What's wrong with this simple Ada w/ assembly code?
  1999-03-03  0:00 What's wrong with this simple Ada w/ assembly code? Josh Highley
  1999-03-04  0:00 ` robert_dewar
  1999-03-04  0:00 ` Tom Moran
@ 1999-03-06  0:00 ` Nick Roberts
  1999-03-06  0:00   ` David Botton
  1999-03-07  0:00   ` Tom Moran
  1999-03-07  0:00 ` Jerry van Dijk
  3 siblings, 2 replies; 27+ messages in thread
From: Nick Roberts @ 1999-03-06  0:00 UTC (permalink / raw)


I think, possibly, the answer to your (immediate) problem is that GCC
expects a ".o" extension for object files, and doesn't recognise ".obj".

May I ask why you are programming in Assembly?

-------------------------------------
Nick Roberts
-------------------------------------








^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: What's wrong with this simple Ada w/ assembly code?
  1999-03-06  0:00 ` Nick Roberts
@ 1999-03-06  0:00   ` David Botton
  1999-03-07  0:00   ` Tom Moran
  1 sibling, 0 replies; 27+ messages in thread
From: David Botton @ 1999-03-06  0:00 UTC (permalink / raw)


If the .obj files is in the same format as Microsoft's obj format, then
it should work with GNAT 3.11p along with .lib files. I have an example
that links in Microsoft libs on my site.

David Botton


Nick Roberts wrote:
> 
> I think, possibly, the answer to your (immediate) problem is that GCC
> expects a ".o" extension for object files, and doesn't recognise ".obj".
> 
> May I ask why you are programming in Assembly?
> 
> -------------------------------------
> Nick Roberts
> -------------------------------------




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: What's wrong with this simple Ada w/ assembly code?
  1999-03-06  0:00 ` Nick Roberts
  1999-03-06  0:00   ` David Botton
@ 1999-03-07  0:00   ` Tom Moran
  1 sibling, 0 replies; 27+ messages in thread
From: Tom Moran @ 1999-03-07  0:00 UTC (permalink / raw)


>expects a ".o" extension for object files, and doesn't recognise ".obj".
If there are any standards at all in the DOS/Wintel world, surely the
extension ".obj" is one of them - unless of course a .o file is a
different format from .obj (which is another "standards" question, but
a different one).




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: What's wrong with this simple Ada w/ assembly code?
  1999-03-03  0:00 What's wrong with this simple Ada w/ assembly code? Josh Highley
                   ` (2 preceding siblings ...)
  1999-03-06  0:00 ` Nick Roberts
@ 1999-03-07  0:00 ` Jerry van Dijk
  1999-03-07  0:00   ` Tom Moran
  1999-03-14  0:00   ` Josh Highley
  3 siblings, 2 replies; 27+ messages in thread
From: Jerry van Dijk @ 1999-03-07  0:00 UTC (permalink / raw)


Josh Highley (joshhighley@hotmail.com) wrote:

:   I'm trying to link some really simple assembly code with Ada.  I 
: haven't been able to find any good examples or explanations on how to do 
: this.

One example is the ports_io packages that you can find on my homepage,
follow the old link.

: to getting this but I'm not sure what I need to do.  I want to use 
: assembly to position the cursor on the screen.

Why would you want to use ASM for this ? If you are using DOS (which I
suspect), use the conio package that comes with the EZ2LOAD distribution.
If you are using the windows compiler, use the NT_Console package on
my homepage.

: ; I have A86 on my PC so my assembly code is a .com   I have access to 
: ; MASM, though, if needed.  "moveto.asm":

Aha, I'm a long standing A86 user myself. 
Remember that:

a) A86 is a 16-bit realmode assembler (unless you are using the protmode
   features?) while all Ada95 compilers I know are 32-bit (minimum) compilers.

b) A86 uses its own modified Intel ASM syntax, if you are using GNAT, it uses
   the AT&T syntax. See the gcc manual for more information.

:    int 10h
: Here's the Ada code.  I'm using GNAT 3.11, AdaGIDE 6.21, and Win95.

There is no such thing as an interrupt in a Win32 environment. This will
never work.

: not recognized: File format not recognized    gnatmake: *** link failed"

That is correct. GNAT is expecting a 32-bit Win32 PE format .obj file, and 
A86 is generating a tiny model 16-bit realmode DOS .obj file.

--
-- Jerry van Dijk | Leiden, Holland
-- Team Ada       | jdijk@acm.org
-- see http://stad.dsl.nl/~jvandyk




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: What's wrong with this simple Ada w/ assembly code?
  1999-03-07  0:00 ` Jerry van Dijk
@ 1999-03-07  0:00   ` Tom Moran
  1999-03-08  0:00     ` Jerry van Dijk
  1999-03-14  0:00   ` Josh Highley
  1 sibling, 1 reply; 27+ messages in thread
From: Tom Moran @ 1999-03-07  0:00 UTC (permalink / raw)


>GNAT is expecting a 32-bit Win32 PE format .obj file
So a Gnat .o file is in fact the same as a Win32 .obj file, but with a
different file name extension?




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: What's wrong with this simple Ada w/ assembly code?
  1999-03-07  0:00   ` Tom Moran
@ 1999-03-08  0:00     ` Jerry van Dijk
  0 siblings, 0 replies; 27+ messages in thread
From: Jerry van Dijk @ 1999-03-08  0:00 UTC (permalink / raw)


Tom Moran (tmoran@bix.com) wrote:

: >GNAT is expecting a 32-bit Win32 PE format .obj file

: So a Gnat .o file is in fact the same as a Win32 .obj file, but with a
: different file name extension?

Whoops...

No, win32 uses a modified coff format that is called the PE (portable
executable) format for .obj, .exe and .dll files. GNAT's .o format is
really a coff file.

Simply put: close, but no sigar :-)

--
-- Jerry van Dijk | Leiden, Holland
-- Team Ada       | jdijk@acm.org
-- see http://stad.dsl.nl/~jvandyk




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: What's wrong with this simple Ada w/ assembly code?
  1999-03-04  0:00   ` Mike Silva
                       ` (2 preceding siblings ...)
  1999-03-04  0:00     ` robert_dewar
@ 1999-03-08  0:00     ` Matthew Heaney
  3 siblings, 0 replies; 27+ messages in thread
From: Matthew Heaney @ 1999-03-08  0:00 UTC (permalink / raw)


"Mike Silva" <mjsilva@jps.net> writes:

> What exactly is ABI?

"application binary interface"





^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: What's wrong with this simple Ada w/ assembly code?
  1999-03-07  0:00 ` Jerry van Dijk
  1999-03-07  0:00   ` Tom Moran
@ 1999-03-14  0:00   ` Josh Highley
  1999-03-14  0:00     ` David C. Hoos, Sr.
                       ` (2 more replies)
  1 sibling, 3 replies; 27+ messages in thread
From: Josh Highley @ 1999-03-14  0:00 UTC (permalink / raw)


In article <F88Cs4.4u@jvdsys.stuyts.nl>, jerry@jvdsys.stuyts.nl says...

>:    int 10h
>: Here's the Ada code.  I'm using GNAT 3.11, AdaGIDE 6.21, and Win95.
>
>There is no such thing as an interrupt in a Win32 environment. This 
will
>never work.
>
The program I'm writing is a simple text based program intended to run 
in a DOS window. I don't know about you other people, but I'm only a 
sophomore CS major who hasn't had the classes or the time to try writing 
Ada programs for Windows, although I'd like to :)  Having said this, can 
I use interrupts?
  I'm using ASM to position the cursor because the other Ada packages 
I've tried aren't very fast at moving the cursor to several different 
areas of the screen quickly.  There's also some other things I'd like to 
try with ASM and Ada, if nothing else, just for fun and to see if I 
myself can make it work.
  Would MASM produce the correct 32 bit object code?

Thanks,

Josh Highley
joshhighley@hotmail.com





^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: What's wrong with this simple Ada w/ assembly code?
  1999-03-14  0:00   ` Josh Highley
@ 1999-03-14  0:00     ` David C. Hoos, Sr.
  1999-03-15  0:00       ` Josh Highley
  1999-03-15  0:00     ` Jerry van Dijk
  1999-03-16  0:00     ` Dale Stanbrough
  2 siblings, 1 reply; 27+ messages in thread
From: David C. Hoos, Sr. @ 1999-03-14  0:00 UTC (permalink / raw)



Josh Highley wrote in message <36ec237f.0@silver.truman.edu>...
>In article <F88Cs4.4u@jvdsys.stuyts.nl>, jerry@jvdsys.stuyts.nl says...
>
>>:    int 10h
>>: Here's the Ada code.  I'm using GNAT 3.11, AdaGIDE 6.21, and Win95.
>>
>>There is no such thing as an interrupt in a Win32 environment. This 
>will
>>never work.
>>
>The program I'm writing is a simple text based program intended to run 
>in a DOS window. I don't know about you other people, but I'm only a 
>sophomore CS major who hasn't had the classes or the time to try writing 
>Ada programs for Windows, although I'd like to :)  Having said this, can 
>I use interrupts?
>  I'm using ASM to position the cursor because the other Ada packages 
>I've tried aren't very fast at moving the cursor to several different 
>areas of the screen quickly.  There's also some other things I'd like to 
>try with ASM and Ada, if nothing else, just for fun and to see if I 
>myself can make it work.
>  Would MASM produce the correct 32 bit object code?
>
Have you looked at the code for the diners example that came with GNAT?

Although that examples primary purpose is demonstrating multitasking,
it also illustrates the use of cursor-position-addressable screen
management.  This is done by means of ANSI terminal escape sequences,
using the ANSI.SYS device driver in the DOS/Win95 environment.

This is a preferable method, because it leaves the matter of
cursor positioning to an OS-provided device driver, instead of
requiring your program to have implementation- or platform-
dependent code.

 





^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: What's wrong with this simple Ada w/ assembly code?
  1999-03-14  0:00     ` David C. Hoos, Sr.
@ 1999-03-15  0:00       ` Josh Highley
  0 siblings, 0 replies; 27+ messages in thread
From: Josh Highley @ 1999-03-15  0:00 UTC (permalink / raw)


>This is done by means of ANSI terminal escape sequences,
>using the ANSI.SYS device driver in the DOS/Win95 environment.
>
>This is a preferable method, because it leaves the matter of
>cursor positioning to an OS-provided device driver, instead of
>requiring your program to have implementation- or platform-
>dependent code.
>
 
  I have used the ANSI escape sequences. However, I want to get away 
from using them to position the cursor because  1) the user has to load 
the ANSI.SYS file in the CONFIG.SYS and I know too many computer 
illiterate people who have never even heard of either of those files 
and would be unsure about working with them even with step-by-step 
directions.  2) I use "get_immediate" and ANSI.SYS causes the input for 
this statement to echo to the screen, which is something I don't want to 
happen.  3) I believe that the ASM code would be much faster and I 
notice that the escape sequence to move the cursor, display ('put') a 
character, and then move the cursor again, is slow.

Finally, I'd just like to know how to link ASM with Ada, not necessarily 
to just position the cursor.

Thanks,

Josh Highley
joshhighley@hotmail.com





^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: What's wrong with this simple Ada w/ assembly code?
  1999-03-14  0:00   ` Josh Highley
  1999-03-14  0:00     ` David C. Hoos, Sr.
@ 1999-03-15  0:00     ` Jerry van Dijk
       [not found]       ` <36ef2175.4732984@news.pacbell.net>
  1999-03-16  0:00     ` Dale Stanbrough
  2 siblings, 1 reply; 27+ messages in thread
From: Jerry van Dijk @ 1999-03-15  0:00 UTC (permalink / raw)


Josh Highley (joshhighley@hotmail.com) wrote:

: The program I'm writing is a simple text based program intended to run 
: in a DOS window.

If you are using the NT version of GNAT, it does produce console based 
programs by default, but this is _not_ DOS code. To write a DOS program
you need to use a DOS version of GNAT.

:  I don't know about you other people, but I'm only a 
: sophomore CS major who hasn't had the classes or the time to try writing 
: Ada programs for Windows, although I'd like to :)  Having said this, can 
: I use interrupts?

No, there are _no_ interrupts in Windows.

:   I'm using ASM to position the cursor because the other Ada packages 
: I've tried aren't very fast at moving the cursor to several different 
: areas of the screen quickly.

Well, my NT_Console package is about as fast as the console will go, using
ASM doesn't help since you would still be calling the same slow Win32 API
functions.

:    There's also some other things I'd like to 
: try with ASM and Ada, if nothing else, just for fun and to see if I 
: myself can make it work.
:   Would MASM produce the correct 32 bit object code?

No, MASM produces microsoft type object (.obj) files, while GNAT expects a
coff (.o) file. Either use the Ada facilities for inline assembly (see gnat
documentation for info) or write directly for the 'as' assembler.
Be warned though that this assembler uses a completely diffent syntax than
MASM does.

--
-- Jerry van Dijk | Leiden, Holland
-- Team Ada       | jdijk@acm.org
-- see http://stad.dsl.nl/~jvandyk




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: What's wrong with this simple Ada w/ assembly code?
  1999-03-14  0:00   ` Josh Highley
  1999-03-14  0:00     ` David C. Hoos, Sr.
  1999-03-15  0:00     ` Jerry van Dijk
@ 1999-03-16  0:00     ` Dale Stanbrough
  1999-03-16  0:00       ` Jerry van Dijk
  2 siblings, 1 reply; 27+ messages in thread
From: Dale Stanbrough @ 1999-03-16  0:00 UTC (permalink / raw)


Josh Highley wrote:

"The program I'm writing is a simple text based program intended to run 
 in a DOS window. I don't know about you other people, but I'm only a 
 sophomore CS major who hasn't had the classes or the time to try writing 
 Ada programs for Windows, although I'd like to :)  Having said this, can 
 I use interrupts?
   I'm using ASM to position the cursor because the other Ada packages 
 I've tried aren't very fast at moving the cursor to several different 
 areas of the screen quickly.  There's also some other things I'd like to 
 try with ASM and Ada, if nothing else, just for fun and to see if I 
 myself can make it work.
 Would MASM produce the correct 32 bit object code?"


If you want to devote your program to DOS (or at least learn how to
layer your programs so that you end up with platform specific code)
the best way to handle this is to declare a 2d array that matches the
video memory, and then simply map it to the real video memory via an
address clause.

If you want the code email me, and i'll hunt around and find it.


Dale




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: What's wrong with this simple Ada w/ assembly code?
  1999-03-16  0:00     ` Dale Stanbrough
@ 1999-03-16  0:00       ` Jerry van Dijk
  0 siblings, 0 replies; 27+ messages in thread
From: Jerry van Dijk @ 1999-03-16  0:00 UTC (permalink / raw)


Dale Stanbrough (dale@cs.rmit.edu.au) wrote:

: If you want to devote your program to DOS (or at least learn how to
: layer your programs so that you end up with platform specific code)
: the best way to handle this is to declare a 2d array that matches the
: video memory, and then simply map it to the real video memory via an
: address clause.

Or use the conio package that comes with EZ2LOAD :-)

--
-- Jerry van Dijk | Leiden, Holland
-- Team Ada       | jdijk@acm.org
-- see http://stad.dsl.nl/~jvandyk




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: What's wrong with this simple Ada w/ assembly code?
       [not found]       ` <36ef2175.4732984@news.pacbell.net>
@ 1999-03-17  0:00         ` Jerry van Dijk
  0 siblings, 0 replies; 27+ messages in thread
From: Jerry van Dijk @ 1999-03-17  0:00 UTC (permalink / raw)


Tom Moran (tmoran@bix.com) wrote:

: >No, there are _no_ interrupts in Windows.

: 16 bit DOS apps that use Int 10, for instance, run just fine in a
: Windows 95 DOS window, at least on my machine.  It's been a while
: since I wrote, or used, a 32 bit "Extended DOS" program, but don't
: they also do what's necessary to handle such interrupts, IO, etc,
: while running under Windows?

Yes, on Win9X (and to a lesser extend NT) you can run DOS programs
that use interrupts. 

What I tried to point out was:

-> If you want to write DOS programs, use a DOS compiler. GNAT/NT generates
   code for Win32, not DOS.

   [The confusion here is that, contrary to for example OS/2, there is only
    one type of console window in Win9x, which is called the MS-DOS window.
    In reality it is a Win32 console with the ability to recognize DOS
    excutables and running them in a emulated DOS environment]

--
-- Jerry van Dijk | Leiden, Holland
-- Team Ada       | jdijk@acm.org
-- see http://stad.dsl.nl/~jvandyk




^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~1999-03-17  0:00 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-03-03  0:00 What's wrong with this simple Ada w/ assembly code? Josh Highley
1999-03-04  0:00 ` robert_dewar
1999-03-04  0:00   ` Mike Silva
1999-03-04  0:00     ` Josh Highley
1999-03-04  0:00     ` Samuel Mize
1999-03-04  0:00       ` Tom Moran
1999-03-05  0:00         ` robert_dewar
1999-03-05  0:00           ` Tom Moran
1999-03-04  0:00     ` robert_dewar
1999-03-05  0:00       ` Mike Silva
1999-03-05  0:00         ` Ed Falis
1999-03-08  0:00     ` Matthew Heaney
1999-03-04  0:00 ` Tom Moran
1999-03-04  0:00   ` robert_dewar
1999-03-06  0:00 ` Nick Roberts
1999-03-06  0:00   ` David Botton
1999-03-07  0:00   ` Tom Moran
1999-03-07  0:00 ` Jerry van Dijk
1999-03-07  0:00   ` Tom Moran
1999-03-08  0:00     ` Jerry van Dijk
1999-03-14  0:00   ` Josh Highley
1999-03-14  0:00     ` David C. Hoos, Sr.
1999-03-15  0:00       ` Josh Highley
1999-03-15  0:00     ` Jerry van Dijk
     [not found]       ` <36ef2175.4732984@news.pacbell.net>
1999-03-17  0:00         ` Jerry van Dijk
1999-03-16  0:00     ` Dale Stanbrough
1999-03-16  0:00       ` Jerry van Dijk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox