Board index » delphi » Assembly language in Turbo Pascal

Assembly language in Turbo Pascal

Hello everybody,
can you tell me if it is possible to use inside assembly code in Turbo
Pascal 3.0? If it is not possible, is it possible in Turbo Pascal 5.5? And
if something of that is possible, how can it be done?
Thank you!
--------------------------------
Moritz Raguschat
 

Re:Assembly language in Turbo Pascal


Quote
"Moritz Raguschat" <Moritz.Ragusc...@gmx.de> wrote in message

news:8o3tlh$9udrn$1@ID-35495.news.cis.dfn.de...

Quote
> Hello everybody,
> can you tell me if it is possible to use inside assembly code in
Turbo
> Pascal 3.0? If it is not possible, is it possible in Turbo Pascal
5.5? And
> if something of that is possible, how can it be done?
> Thank you!

You have to use Inline in TP versions up to, I think, 6. Basically, an
Inline statement is like

inline(code element/ code element/ ... code element);

"code element" is one or more "data elements" separated by + or -,
"data element" is an integer constant, a variable, procedure or
function identifier, or * meaning the current offset. By default the
code element is 8-bit if it's made up only of integer constants and
has a value in the range 0..255, and is 16-bit (low end first, of
course) otherwise. If you want to change this, prefixing it with '<'
gives an 8-bit value by discarding the high byte, '>' gives a 16-bit
value, if necessary by using 0 for the high byte.

You probably have to use this by coding in another assembler and
pasting in bits of its listing. It's crude. If you want to be _really_
crude, you can use DOS' DEBUG program as your assembler. It will take
STDIN redirection so you could have a text file x.dbg containing

a100
mov dx, 200
mov ah, 9
int 21

u100 110

q

and squirt that through Debug by

DEBUG < X.DBG > x.out

and then edit the listing in x.out
1E81:0100 BA0002        MOV     DX,0200
1E81:0103 B409          MOV     AH,09
1E81:0105 CD21          INT     21
into
  inline( $BA/x/     {    MOV     DX,offset of x }
          $B4/$09/   {    MOV     AH,09          }
          $CD/$21);  {    INT     21             }

Don't laugh! People actually used to do this sort of thing. I didn't
make this up.

Or you could see if you could buy a more up-to-date compiler with a
built-in assembler. If you can use either TP3 or TP5.5 you can't be
working on nonportable TP3 legacy code.

FP

Re:Assembly language in Turbo Pascal


Moritz Raguschat a crit :

Quote
> can you tell me if it is possible to use inside assembly code in Turbo
> Pascal 3.0? If it is not possible, is it possible in Turbo Pascal 5.5?

in TP3 :

procedure test;
begin
  ...
  inline($00/$00/$00);
  ...
end;

not easy: search INLIN219.ZIP to convert asm to hex

starting from TP6:

procedure test;
begin
  ...
  asm
    mov ax,0
    ...
  end;
  ...
end;

--
http://www.pascaland.org The Land of Pascal Language

Re:Assembly language in Turbo Pascal


Quote
Frank Peelo wrote:

> You have to use Inline in TP versions up to, I think, 6.

In fact, up to 8 also known as Delphi 1.0

Quote
> Basically, an Inline statement is like

> inline(code element/ code element/ ... code element);

> You probably have to use this by coding in another assembler and
> pasting in bits of its listing. It's crude.

As Franck noted INLIN219.ZIP is *the* package to use if you want
to do assembly via Inline.

But Inline also have a flaw: it inlines, i.e. the same code
is pasted as much times as the Inline function/procedure is
used. Very different from normal subroutines.

For TP 2-3, the way to go was to program position-indepent code
with no reference to any variable, to package it in a simple
chunk usually with a .BIN extension, and using the external
directive. Difficult way, IMO.

For TP 4, 5, 5.5, the way was to use an external assembler to build
regular .OBJ (with a few exceptions), and then link them using the
{$L } directive with the Pascal code.

Beginning with TP6, integrated assembler is available inside the source.
Nice thing.

Antoine

Re:Assembly language in Turbo Pascal


Quote
"Antoine Leca" <Antoine.L...@renault.fr> wrote in message

news:39ABA4F8.ACF4ACD3@renault.fr...

Quote
> Frank Peelo wrote:

> > You have to use Inline in TP versions up to, I think, 6.

> In fact, up to 8 also known as Delphi 1.0

No - from v6 you do not have to use inline because asm is available.
We may be interpreting the phrase "have to use" differently.

You're right, though, external or $L code was also a possibility and
for anything more than a couple of dozen bytes it would be the way to
go.

Frank

Re:Assembly language in Turbo Pascal


Quote
>"Antoine Leca" <Antoine.L...@renault.fr> wrote in message
>news:39ABA4F8.ACF4ACD3@renault.fr...
>> Frank Peelo wrote:

>> > You have to use Inline in TP versions up to, I think, 6.

>> In fact, up to 8 also known as Delphi 1.0

>No - from v6 you do not have to use inline because asm is available.
>We may be interpreting the phrase "have to use" differently.

>You're right, though, external or $L code was also a possibility and
>for anything more than a couple of dozen bytes it would be the way to
>go.

I would do that to. Before I moved on to FPC, I did that for a while.

Re:Assembly language in Turbo Pascal


Quote
Frank Peelo wrote:

> "Antoine Leca" <Antoine.L...@renault.fr> wrote in message
> news:39ABA4F8.ACF4ACD3@renault.fr...
> > Frank Peelo wrote:

> > > You have to use Inline in TP versions up to, I think, 6.

> > In fact, up to 8 also known as Delphi 1.0

> No - from v6 you do not have to use inline because asm is available.
> We may be interpreting the phrase "have to use" differently.

I stand corrected: yes you're right both times. I misread your sentence.
I am sure we all agree on the grounds.

Antoine

Other Threads