Board index » delphi » Calling Procedures within Inline Assembly?

Calling Procedures within Inline Assembly?

Hello, Does anyone here know if my question above is possible in Inline
Assembly & if so does anyone have an example on how to demonstrate this or
where I could find one?

I have seen this been done in Assembly in later versions of TP, but I really
need a Inline Assembly example if this is possible.

Thanks.
Ross.
. .
 |
\_/

 

Re:Calling Procedures within Inline Assembly?


Quote
> Hello, Does anyone here know if my question above is possible in Inline
> Assembly & if so does anyone have an example on how to demonstrate this or
> where I could find one?

> I have seen this been done in Assembly in later versions of TP, but I
really
> need a Inline Assembly example if this is possible.

asm
     push  arg_1
     push  arg_2
     ...
     push  arg_n
     call    my_proc
end;

note that you can't call a standard procedure or function like writeln
within tp inline assembler.

Re:Calling Procedures within Inline Assembly?


Quote
Ross Simpson wrote:

> Hello, Does anyone here know if my question above is possible in Inline
> Assembly & if so does anyone have an example on how to demonstrate this or
> where I could find one?

> I have seen this been done in Assembly in later versions of TP, but I really
> need a Inline Assembly example if this is possible.

> Thanks.
> Ross.
> . .
>  |
> \_/

If I remember correctly, it is impossible to do it directly as the
linker wouldn't know how to change the code to call the procedures (the
x86 uses relative calls instead of absolute calls).
The only way I can think of, is to create your own relocator and use
indirect calls via a vector table OR define an interrupt vector (like
INT $21) to handle your own service procedures.

/klaus

Re:Calling Procedures within Inline Assembly?


Quote
"Klaus" <p102882...@mail.uni2.dk> wrote in message

news:3BF226AD.77D415DC@mail.uni2.dk...

Quote
> Ross Simpson wrote:

> > Hello, Does anyone here know if my question above is possible in Inline
> > Assembly & if so does anyone have an example on how to demonstrate this
or
> > where I could find one?

> > I have seen this been done in Assembly in later versions of TP, but I
really
> > need a Inline Assembly example if this is possible.

> > Thanks.
> > Ross.
> > . .
> >  |
> > \_/

> If I remember correctly, it is impossible to do it directly as the
> linker wouldn't know how to change the code to call the procedures (the
> x86 uses relative calls instead of absolute calls).
> The only way I can think of, is to create your own relocator and use
> indirect calls via a vector table OR define an interrupt vector (like
> INT $21) to handle your own service procedures.

> /klaus

Yeah! I've have a bit more thought about this problem since & thought that
there is a better way of tackling this. The problem within my example is
that the Assembly is calling another lot of assembly within a different
procedure. I've thought that becuase this is only calling from one spot to
another it's easier to include the other assembly around the other or to
have the other code after the other bit of code which calls it (all in one
inline statement). There is no issue of other code calling it from
elsewhere.

Ross.
. .
 |
\_/

Re:Calling Procedures within Inline Assembly?


Quote
"Crash Khatastrov" <rashmat...@hotmail.com> wrote in message <news:9ss4lp$hmo$1@dinkel.civ.utwente.nl>...
> > Hello, Does anyone here know if my question above is possible in Inline
> > Assembly & if so does anyone have an example on how to demonstrate this or
> > where I could find one?

> > I have seen this been done in Assembly in later versions of TP, but I
>  really
> > need a Inline Assembly example if this is possible.

> asm
>      push  arg_1
>      push  arg_2
>      ...
>      push  arg_n
>      call    my_proc
> end;

> note that you can't call a standard procedure or function like writeln
> within tp inline assembler.

Also one must remember that TP does not preserve any registers besides
CS, IP, DS, SS, SP and BP. All other registers are undefined after
the call.

Osmo

Re:Calling Procedures within Inline Assembly?


I have a question about Inline Assembly. What is the advantage of InLine
Assembly?  I have used the command .ASM and just written the needed code in
assembly.  The reason for doing so was that I was just more knowledgeable
with assembly in doing what I needed to do..
Thanks Joe

Quote
"Osmo Ronkanen" <ok...@hotmail.com> wrote in message

news:d0d3e7d9.0111190122.5a3d8266@posting.google.com...
Quote
> "Crash Khatastrov" <rashmat...@hotmail.com> wrote in message

<news:9ss4lp$hmo$1@dinkel.civ.utwente.nl>...
Quote
> > > Hello, Does anyone here know if my question above is possible in
Inline
> > > Assembly & if so does anyone have an example on how to demonstrate
this or
> > > where I could find one?

> > > I have seen this been done in Assembly in later versions of TP, but I
> >  really
> > > need a Inline Assembly example if this is possible.

> > asm
> >      push  arg_1
> >      push  arg_2
> >      ...
> >      push  arg_n
> >      call    my_proc
> > end;

> > note that you can't call a standard procedure or function like writeln
> > within tp inline assembler.

> Also one must remember that TP does not preserve any registers besides
> CS, IP, DS, SS, SP and BP. All other registers are undefined after
> the call.

> Osmo

Re:Calling Procedures within Inline Assembly?


Quote
In article <HoaK7.4302$py4.3624...@news2.nash1.tn.home.com>, Joe wrote:
> I have a question about Inline Assembly. What is the advantage of InLine
> Assembly?  I have used the command .ASM and just written the needed code in
> assembly.  The reason for doing so was that I was just more knowledgeable
> with assembly in doing what I needed to do..

The assembly is truely inlined in the place where it is used. It isn't
merely called from that place.

Re:Calling Procedures within Inline Assembly?


Quote
"Joe" <j...@home.com> wrote in message...
> I have a question about Inline Assembly. What is the advantage of InLine
> Assembly?

Well the only advantage of Inline assembly I can think of (since I've used
it a bit) is that it brings more compatability within your programs. If you
use the ASM statements your limiting your program to work only in Turbo
Pascal 6 & 7. I use TP 5.5 & 3 from the Borland web sites & in the case of
TP 5.5 & 3 it does not support the ASM statement so Inline is the next
closest thing which they both support.

Quote
> I have used the command .ASM and just written the needed code in
> assembly.  The reason for doing so was that I was just more knowledgeable
> with assembly in doing what I needed to do..

Of course there are programs I use which help convert assembly statements
into Inline codes (e.g. Inlin219.zip at the garbo web site). I simply don't
have the knowledge to put all those codes in the inline statement. The only
grudge I have towards those programs (there's a few of them) is they are
older than TP 6 & 7 so modifing them is sometimes the case & I have even had
cases where it can't be done & that is one of the disadvantages of inline.
It's not as flexable as the Assembly used in TP 6 & 7.

Quote
> Thanks Joe

No worries.

Ross.

 <snip!>

Re:Calling Procedures within Inline Assembly?


Quote
"Joe" <j...@home.com> wrote in message

news:HoaK7.4302$py4.3624799@news2.nash1.tn.home.com...

Quote
> I have a question about Inline Assembly. What is the advantage of
InLine
> Assembly?  I have used the command .ASM and just written the needed
code in
> assembly.  The reason for doing so was that I was just more
knowledgeable
> with assembly in doing what I needed to do..
> Thanks Joe

What's inline assembly? The built-in assembler, BASM, is assembly but
that would be using the command asm and just writing the needed code
in assembly - so I don't think that's what you mean. Before BASM was
developed, we had to put up with Inline statements, but they don't do
any assembly. You have to do that yourself first, elsewhere. And the
only advantage they have is in inline procedures, where you can give
names to short bits of machine code that you want to insert into
Pascal in more than one place, without a procedure call. Sort of
Macros for {*word*37}s.

FP

Re:Calling Procedures within Inline Assembly?


Quote
"Joe" <j...@home.com> wrote in message <news:HoaK7.4302$py4.3624799@news2.nash1.tn.home.com>...
> I have a question about Inline Assembly. What is the advantage of InLine
> Assembly?  I have used the command .ASM and just written the needed code in
> assembly.  The reason for doing so was that I was just more knowledgeable
> with assembly in doing what I needed to do..

Inline assembly is much neater way to do things if there is not that
much assembler code. One can just write the code in same source and
one can debug it with the internal de{*word*81}. One can use inline
assembly inside normal procedures, for example to disable interrupts
one can just write:

asm
cli
end;

inside a Pascal procedure.

Osmo

Re:Calling Procedures within Inline Assembly?


Quote
"Ross Simpson" <rosssimp...@optusnet.com.au> wrote in message <news:3bf991a1$0$21711$afc38c87@news.optusnet.com.au>...
> "Joe" <j...@home.com> wrote in message...

> > I have a question about Inline Assembly. What is the advantage of InLine
> > Assembly?

> Well the only advantage of Inline assembly I can think of (since I've used
> it a bit) is that it brings more compatability within your programs. If you
> use the ASM statements your limiting your program to work only in Turbo
> Pascal 6 & 7. I use TP 5.5 & 3 from the Borland web sites & in the case of
> TP 5.5 & 3 it does not support the ASM statement so Inline is the next
> closest thing which they both support.

Asm statements are inline assembly. Inline statements have nothing
whatsoever to do with assembler (assembler uses mnemonics and
symbolic labels).

As for the inline statements, the only real benefit they can bring
are inline functions and procedures. Those are truly inluned instead
of called. This makes them faster.

Osmo

Re:Calling Procedures within Inline Assembly?


Quote
"Osmo Ronkanen" <ok...@hotmail.com> wrote in message

news:d0d3e7d9.0111210302.71de6014@posting.google.com...
Quote
> "Ross Simpson" <rosssimp...@optusnet.com.au> wrote in message

<news:3bf991a1$0$21711$afc38c87@news.optusnet.com.au>...

Quote
> > "Joe" <j...@home.com> wrote in message...

> > > I have a question about Inline Assembly. What is the advantage
of InLine
> > > Assembly?

> > Well the only advantage of Inline assembly I can think of (since
I've used
> > it a bit) is that it brings more compatability within your
programs. If you
> > use the ASM statements your limiting your program to work only in
Turbo
> > Pascal 6 & 7. I use TP 5.5 & 3 from the Borland web sites & in the
case of
> > TP 5.5 & 3 it does not support the ASM statement so Inline is the
next
> > closest thing which they both support.

> Asm statements are inline assembly. Inline statements have nothing
> whatsoever to do with assembler (assembler uses mnemonics and
> symbolic labels).

I was going to say that, because I called it inline assembly too, but
then I checked my manual. It refers to it as the built-in assembler,
rather than the inline assembler. Probably to avoid confusion with the
inline statements. Does the term "inline assembly" come from another
language?

FP

Re:Calling Procedures within Inline Assembly?


Quote
"Frank Peelo" <fpe...@eircom.net> wrote in message...

> "Osmo Ronkanen" <ok...@hotmail.com> wrote in message
> news:d0d3e7d9.0111210302.71de6014@posting.google.com...
> > "Ross Simpson" <rosssimp...@optusnet.com.au> wrote in message
> <news:3bf991a1$0$21711$afc38c87@news.optusnet.com.au>...
> > > "Joe" <j...@home.com> wrote in message...

> > > > I have a question about Inline Assembly. What is the advantage
> of InLine
> > > > Assembly?

> > > Well the only advantage of Inline assembly I can think of (since
> I've used
> > > it a bit) is that it brings more compatability within your
> programs. If you
> > > use the ASM statements your limiting your program to work only in
> Turbo
> > > Pascal 6 & 7. I use TP 5.5 & 3 from the Borland web sites & in the
> case of
> > > TP 5.5 & 3 it does not support the ASM statement so Inline is the
> next
> > > closest thing which they both support.

> > Asm statements are inline assembly. Inline statements have nothing
> > whatsoever to do with assembler (assembler uses mnemonics and
> > symbolic labels).

> I was going to say that, because I called it inline assembly too, but
> then I checked my manual. It refers to it as the built-in assembler,
> rather than the inline assembler. Probably to avoid confusion with the
> inline statements. Does the term "inline assembly" come from another
> language?

Actually Frank I think you might be right. I sure I heard people who program
in C language refer to it more as inline assembly. However, in a matter of
speaking the program I use to convert assembly back into inline statements
(for turbo pascal) is simply called "inline assembler" which is where I got
the term from.

Actually after thinking about it Osmo is correct by saying Inline statements
have nothing to do with assembler since that is the language used to get the
mnemonics which is what inline is. The only thing assembly has with this is
the program which converts the assembly back into inline.

Ross.

Other Threads