Board index » delphi » More noob help needed please: 'asm'

More noob help needed please: 'asm'

Ok, Valentine helped me with a routine (below).  

But it keeps whining about "asm" with an "unknown identifier" error
when I try to compile/build it.  

Is there a unit I need to add to support it?  I have DOS in my uses.

I'm using TP 5.5

{******************************************************}
{ Copy Screen from one page to another.                }
{                                                      }
{ Arguments can be 0 to 7                              }
{                                                      }
{ Routine by Valentine Mehling (va...@earthlink.net)   }
{ from the comp.lang.pascal.borland news group.        }
{******************************************************}
Procedure CopyScreen(from, too : word) ;
begin
  from := (from * $1000) ;   { * page size in bytes    }
  too  := (too  * $1000) ;

  asm      mov   cx,$B800       { set new segment address }
           mov   es,cx          { - and transfer to es    }
           mov   bx,$800        { page size in words      }
           mov   si,from        { store source index      }
           mov   di,too         { store destination index }
    @loop: mov   ax,es:[si]     { fetch                   }
           mov   es:[di],ax     { store                   }
           inc   si                     { increment indexes twice }
           inc   si          
           inc   di          
           inc   di          
           dec   bx             { decrement counter       }
           cmp   bx,$00         { compare counter to 0    }
           jne   @loop          { loop if not 0           }
  end ;                                 { asm                     }
end ;    

Thanks guys.

 

Re:More noob help needed please: 'asm'


Brett Lathrope <br...@lathrope.com> said the following:

Quote

>Ok, Valentine helped me with a routine (below).

>But it keeps whining about "asm" with an "unknown identifier" error
>when I try to compile/build it.

>Is there a unit I need to add to support it?  I have DOS in my uses.

>I'm using TP 5.5

The ability to use inline assembler (BASM), ie the asm......end pairs
only came about with the introduction of TP6, I'm afraid that V5.5 does
not support the use of assembler statements within the program.
Quote

>{******************************************************}
>{ Copy Screen from one page to another.                }
>{                                                      }
>{ Arguments can be 0 to 7                              }
>{                                                      }
>{ Routine by Valentine Mehling (va...@earthlink.net)   }
>{ from the comp.lang.pascal.borland news group.        }
>{******************************************************}
>Procedure CopyScreen(from, too : word) ;
>begin
>  from := (from * $1000) ;   { * page size in bytes    }
>  too  := (too  * $1000) ;

>  asm      mov   cx,$B800      { set new segment address }
>           mov   es,cx         { - and transfer to es    }
>           mov   bx,$800       { page size in words      }
>           mov   si,from       { store source index      }
>           mov   di,too                { store destination index }
>    @loop: mov   ax,es:[si]    { fetch                   }
>           mov   es:[di],ax    { store                   }
>           inc   si                    { increment indexes twice }
>           inc   si
>           inc   di
>           inc   di
>           dec   bx            { decrement counter       }
>           cmp   bx,$00        { compare counter to 0    }
>           jne   @loop         { loop if not 0           }
>  end ;                                { asm                     }
>end ;

As long as you remember to move bytes (so $1000 bytes not $800 words),
you can do it in TP5.5 with the Move procedure in the system unit:

procedure CopyScreen(from, too : word);
begin
      move(ptr($B800,from*$1000)^,ptr($B800,too*$1000)^,$1000);
end;

For mono screens, BTW, you'll need to replace $B800 with $B000.

The other options would be to use inline() statements or to make the
procedure an external assembler file, compile it with TASM and link in
the .obj file. The above is your easiest option with TP5.5

Note that there is no error checking either in mine or Valentine's, you
do need to make sure that you only pass 0..7 for both the 'from' and
'too' or you'll overwrite memory you shouldn't.

See also John Stockton's earlier reply, it should be quicker to switch
to the new page 0..7 than copy the data back and forth.
--
Pedt
From: heavily spam-trapped; Reply-To: works

Re:More noob help needed please: 'asm'


ALL PROBLEMS SOLVED!  Got my hands on TP70 ...  it fixed everything of
course.  

Thanks guys!  Seriously!

Brett

On Fri, 13 Sep 2002 16:49:13 GMT, br...@lathrope.com (Brett Lathrope)
wrote:

Quote

>Ok, Valentine helped me with a routine (below).  

>But it keeps whining about "asm" with an "unknown identifier" error
>when I try to compile/build it.  

>Is there a unit I need to add to support it?  I have DOS in my uses.

>I'm using TP 5.5

>{******************************************************}
>{ Copy Screen from one page to another.                }
>{                                                      }
>{ Arguments can be 0 to 7                              }
>{                                                      }
>{ Routine by Valentine Mehling (va...@earthlink.net)   }
>{ from the comp.lang.pascal.borland news group.        }
>{******************************************************}
>Procedure CopyScreen(from, too : word) ;
>begin
>  from := (from * $1000) ;   { * page size in bytes    }
>  too  := (too  * $1000) ;

>  asm      mov   cx,$B800   { set new segment address }
>           mov   es,cx              { - and transfer to es    }
>           mov   bx,$800    { page size in words      }
>           mov   si,from    { store source index      }
>           mov   di,too             { store destination index }
>    @loop: mov   ax,es:[si] { fetch                   }
>           mov   es:[di],ax { store                   }
>           inc   si                 { increment indexes twice }
>           inc   si          
>           inc   di          
>           inc   di          
>           dec   bx                 { decrement counter       }
>           cmp   bx,$00     { compare counter to 0    }
>           jne   @loop              { loop if not 0           }
>  end ;                             { asm                     }
>end ;    

>Thanks guys.

Re:More noob help needed please: 'asm'


Quote
"Brett Lathrope" <br...@lathrope.com> wrote in message...

> Ok, Valentine helped me with a routine (below).

> But it keeps whining about "asm" with an "unknown identifier" error
> when I try to compile/build it.

> Is there a unit I need to add to support it?  I have DOS in my uses.

> I'm using TP 5.5

> {******************************************************}
> { Copy Screen from one page to another.                }
> {                                                      }
> { Arguments can be 0 to 7                              }
> {                                                      }
> { Routine by Valentine Mehling (va...@earthlink.net)   }
> { from the comp.lang.pascal.borland news group.        }
> {******************************************************}
> Procedure CopyScreen(from, too : word) ;
> begin
>   from := (from * $1000) ;   { * page size in bytes    }
>   too  := (too  * $1000) ;

>   asm      mov   cx,$B800 { set new segment address }
>            mov   es,cx { - and transfer to es    }
>            mov   bx,$800 { page size in words      }
>            mov   si,from { store source index      }
>            mov   di,too { store destination index }
>     @loop: mov   ax,es:[si] { fetch                   }
>            mov   es:[di],ax { store                   }
>            inc   si { increment indexes twice }
>            inc   si
>            inc   di
>            inc   di
>            dec   bx   { decrement counter       }
>            cmp   bx,$00 { compare counter to 0    }
>            jne   @loop { loop if not 0           }
>   end ;                   { asm                     }
> end ;

Just out of interest would anyone here know a Pascal equivalant to
this statement: 'mov ax,es:[si]'. I 'am using TP 5.5 & have no
intention to change to 7. For example in TP 5.5 you could do this for
a statement like 'mov cx,$b800' in the form of this:

uses dos; {this is required for setting up the registers}

var regs : registers; {just defining the regs statement}
begin
 regs.cx:=$b800; {pascal equivalant to 'mov cx,$b800'}
end.

If anyone could let me know what 'mov ax,es:[si]' means in pascal I
should be able to interpret this for TP 5.5.

Thanks,
Ross.

Re:More noob help needed please: 'asm'


"Ross Simpson" <rosssimpson@my_spammers_address(optusnet).com.au> schreef
in bericht news:3d82d993$0$18873$afc38c87@news.optusnet.com.au...

Quote

> "Brett Lathrope" <br...@lathrope.com> wrote in message...

> > Ok, Valentine helped me with a routine (below).

> > But it keeps whining about "asm" with an "unknown identifier" error
> > when I try to compile/build it.

> > Is there a unit I need to add to support it?  I have DOS in my uses.

> > I'm using TP 5.5

> > {******************************************************}
> > { Copy Screen from one page to another.                }
> > {                                                      }
> > { Arguments can be 0 to 7                              }
> > {                                                      }
> > { Routine by Valentine Mehling (va...@earthlink.net)   }
> > { from the comp.lang.pascal.borland news group.        }
> > {******************************************************}
> > Procedure CopyScreen(from, too : word) ;
> > begin
> >   from := (from * $1000) ;   { * page size in bytes    }
> >   too  := (too  * $1000) ;

> >   asm      mov   cx,$B800 { set new segment address }
> >            mov   es,cx { - and transfer to es    }
> >            mov   bx,$800 { page size in words      }
> >            mov   si,from { store source index      }
> >            mov   di,too { store destination index }
> >     @loop: mov   ax,es:[si] { fetch                   }
> >            mov   es:[di],ax { store                   }
> >            inc   si { increment indexes twice }
> >            inc   si
> >            inc   di
> >            inc   di
> >            dec   bx   { decrement counter       }
> >            cmp   bx,$00 { compare counter to 0    }
> >            jne   @loop { loop if not 0           }
> >   end ;                   { asm                     }
> > end ;

> Just out of interest would anyone here know a Pascal equivalant to
> this statement: 'mov ax,es:[si]'. I 'am using TP 5.5 & have no
> intention to change to 7. For example in TP 5.5 you could do this for
> a statement like 'mov cx,$b800' in the form of this:

> uses dos; {this is required for setting up the registers}

> var regs : registers; {just defining the regs statement}
> begin
>  regs.cx:=$b800; {pascal equivalant to 'mov cx,$b800'}
> end.

> If anyone could let me know what 'mov ax,es:[si]' means in pascal I
> should be able to interpret this for TP 5.5.

Unless you are familiar with inline statements (which I am not), I don't
think you can.
The registers type of parameter is just a normal type of parameter which
holds an image of what you want to do with the processor registers

type
    (Registers record used by Intr and MsDos)
  Registers = record
    case Integer of
    0: (AX, BX, CX, DX, BP, SI, DI, DS, ES, Flags: Word);
    1: (AL, AH, BL, BH, CL, CH, DL, DH: Byte);
  end;

So the assignment
  regs.cx:=$b800;
is not the pascal equivalent to 'mov cx,$b800' but it is an assignment of
$B800 to the cx field in the regs parameter, which is more than one
assembler instruction.
When you call
INTR(...,regs)   or
MSDOS(regs)        which is effectively  Intr($21,regs)

the first thing that will happen inside the procedures is probably that
all the fields of the regs parameter are copied to the corresponding
processor registers. Next the interrupt is called. After that the
resulting processor registers are copied back to the parameter for
readout in your program.

Femme

Re:More noob help needed please: 'asm'


On Sat, 14 Sep 2002 16:35:08 +1000, "Ross Simpson"

Quote
<rosssimpson@my_spammers_address(optusnet).com.au> wrote:
>Just out of interest would anyone here know a Pascal equivalant to
>this statement: 'mov ax,es:[si]'. I 'am using TP 5.5 & have no
>intention to change to 7. For example in TP 5.5 you could do this for
>a statement like 'mov cx,$b800' in the form of this:

There is no "equivalent", as this is a specific assembler instruction
which does not have a corresponding Pascal instruction....

Quote
>uses dos; {this is required for setting up the registers}

>var regs : registers; {just defining the regs statement}
>begin
> regs.cx:=$b800; {pascal equivalant to 'mov cx,$b800'}

The Regs record in TP is just used for loading register values as a
setup for an interrupt call with either Intr or MsDOS, and has nothing
to do with "assembler programming" in Pascal.

Quote
>If anyone could let me know what 'mov ax,es:[si]' means in pascal I
>should be able to interpret this for TP 5.5.

Pascal is a high-level language, you simply can't translate
instructions to/from assembler 1:1.
One (simple) Pascal instruction can consists of up to hundereds of
assembler instructions and the majority of assembler instructions
can't be translated into a matching Pascal statement.

Ralf

Re:More noob help needed please: 'asm'


JRS:  In article <3d821552.317953...@news.mminternet.com>, seen in
news:comp.lang.pascal.borland, Brett Lathrope <br...@lathrope.com>
posted at Fri, 13 Sep 2002 16:49:13 :-

Quote

>Ok, Valentine helped me with a routine (below).  

>But it keeps whining about "asm" with an "unknown identifier" error
>when I try to compile/build it.  

>Is there a unit I need to add to support it?  I have DOS in my uses.

>I'm using TP 5.5

Needs later TP.

But you can use the standard
        procedure Move(var Source, Dest; Count: Word);
which will not be much slower.

Swapping screen pages, if available, should be still quicker.

--
? John Stockton, Surrey, UK.  j...@merlyn.demon.co.uk   Turnpike v4.00   MIME. ?
  <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
  <URL:http://www.merlyn.demon.co.uk/clpb-faq.txt> Pedt Scragg: c.l.p.b. mFAQ;
  <URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ.

Re:More noob help needed please: 'asm'


Quote
"Femme Verbeek"  wrote in message...
> > Just out of interest would anyone here know a Pascal equivalant to
> > this statement: 'mov ax,es:[si]'. I 'am using TP 5.5 & have no
> > intention to change to 7. For example in TP 5.5 you could do this
for
> > a statement like 'mov cx,$b800' in the form of this:

> > uses dos; {this is required for setting up the registers}

> > var regs : registers; {just defining the regs statement}
> > begin
> >  regs.cx:=$b800; {pascal equivalant to 'mov cx,$b800'}
> > end.

> > If anyone could let me know what 'mov ax,es:[si]' means in pascal
I
> > should be able to interpret this for TP 5.5.

> Unless you are familiar with inline statements (which I am not), I
don't
> think you can.
> The registers type of parameter is just a normal type of parameter
which
> holds an image of what you want to do with the processor registers

> type
>     (Registers record used by Intr and MsDos)
>   Registers = record
>     case Integer of
>     0: (AX, BX, CX, DX, BP, SI, DI, DS, ES, Flags: Word);
>     1: (AL, AH, BL, BH, CL, CH, DL, DH: Byte);
>   end;

> So the assignment
>   regs.cx:=$b800;
> is not the pascal equivalent to 'mov cx,$b800' but it is an
assignment of
> $B800 to the cx field in the regs parameter, which is more than one
> assembler instruction.

Ah, but as Ralf said Pascal is a high level language! But with 'mov
cx,$b800' your assigning the value of b800h to cx. It's the same as
'regs.cx:=$b800'! :-)

Quote
> When you call
> INTR(...,regs)   or
> MSDOS(regs)        which is effectively  Intr($21,regs)

True this is possibly the problem. It could well be the Pascal
solution would be to use the mem(); or memw(); maybe the equivalant
here. I'll have to look into this.

Okay, so maybe pascal isn't the solution. Maybe the 'from := (from *
$1000) ;',  'too  := (too  * $1000);' need to be translated into
assembler. The biggest problem with inline statements here is you
cannot assign a value to a variable then expect it to be part of the
'from' & 'too' in the inline bit (it doesn't work like that).

I'll do some checking up on stuff which had a Pascal equivalant
statement as well as an assembly bit I maybe able to get an idea from
that.

Regards,
Ross.

Re:More noob help needed please: 'asm'


"Ralf A. Quint" <ralf_qu...@hottmail.com> wrote in message...

Quote

> The Regs record in TP is just used for loading register values as a
> setup for an interrupt call with either Intr or MsDOS, and has
nothing
> to do with "assembler programming" in Pascal.

Sure I think you can use the mem(); & memw(); in conjunction with it.
That maybe the solution.

Quote
> Pascal is a high-level language, you simply can't translate
> instructions to/from assembler 1:1.
> One (simple) Pascal instruction can consists of up to hundereds of
> assembler instructions and the majority of assembler instructions
> can't be translated into a matching Pascal statement.

I've seen some stuff the size of routines like this been translated
into Pascal & no I'm not referning to the:
 mov ax,0003h
 int 10h
to:
 regs.ax:=$0003;
 intr($10,regs);
stuff.

As I've mentioned to Femme I'll look further into this.

Regards,
Ross.

Re:More noob help needed please: 'asm'


Quote
In article <3d83e93f$0$22175$afc38...@news.optusnet.com.au>, Ross Simpson wrote:
> "Femme Verbeek"  wrote in message...
>> type
>>     (Registers record used by Intr and MsDos)
>>   Registers = record
>>     case Integer of
>>     0: (AX, BX, CX, DX, BP, SI, DI, DS, ES, Flags: Word);
>>     1: (AL, AH, BL, BH, CL, CH, DL, DH: Byte);
>>   end;

>> So the assignment
>>   regs.cx:=$b800;
>> is not the pascal equivalent to 'mov cx,$b800' but it is an
> assignment of
>> $B800 to the cx field in the regs parameter, which is more than one
>> assembler instruction.

> Ah, but as Ralf said Pascal is a high level language! But with 'mov
> cx,$b800' your assigning the value of b800h to cx. It's the same as
> 'regs.cx:=$b800'! :-)

No. You assign it to memory, as Femme said.

Quote
>> When you call
>> INTR(...,regs)   or
>> MSDOS(regs)        which is effectively  Intr($21,regs)

> True this is possibly the problem. It could well be the Pascal
> solution would be to use the mem(); or memw(); maybe the equivalant
> here. I'll have to look into this.

There is no Pascal equivalent. The registers are not directly accessable.
It could be possible to mimic the functionality of a larger set if assembler
instructions, but not just this single one.

Re:More noob help needed please: 'asm'


"Marco van de Voort" <mar...@toad.stack.nl> wrote in message...

Quote
> > True this is possibly the problem. It could well be the Pascal
> > solution would be to use the mem(); or memw(); maybe the
equivalant
> > here. I'll have to look into this.

> There is no Pascal equivalent. The registers are not directly
accessable.
> It could be possible to mimic the functionality of a larger set if
assembler
> instructions, but not just this single one.

Okay, however for you information basically what I'm looking for is a
Pascal equivalant to the CopyScreen procedure which I've included
below. Surely there must be a way to do that, wouldn't there?

If not then it's no hassle. I'll just use conventional interrupt
routines.

Regards,
Ross.

Procedure CopyScreen(from, too : word) ;
begin
  from := (from * $1000) ;   { * page size in bytes    }
  too  := (too  * $1000) ;

  asm      mov   cx,$B800 { set new segment address }
           mov   es,cx { - and transfer to es    }
           mov   bx,$800 { page size in words      }
           mov   si,from { store source index      }
           mov   di,too { store destination index }
    @loop: mov   ax,es:[si] { fetch                   }
           mov   es:[di],ax { store                   }
           inc   si { increment indexes twice }
           inc   si
           inc   di
           inc   di
           dec   bx   { decrement counter       }
           cmp   bx,$00 { compare counter to 0    }
           jne   @loop { loop if not 0           }
  end ;                   { asm                     }
end ;

Re:More noob help needed please: 'asm'


Quote
In article <3d845b3b$0$16693$afc38...@news.optusnet.com.au>, Ross Simpson wrote:
> "Marco van de Voort" <mar...@toad.stack.nl> wrote in message...

>> > True this is possibly the problem. It could well be the Pascal
>> > solution would be to use the mem(); or memw(); maybe the
> equivalant
>> > here. I'll have to look into this.

>> There is no Pascal equivalent. The registers are not directly
> accessable.
>> It could be possible to mimic the functionality of a larger set if
> assembler
>> instructions, but not just this single one.

> Okay, however for you information basically what I'm looking for is a
> Pascal equivalant to the CopyScreen procedure which I've included
> below. Surely there must be a way to do that, wouldn't there?

For 16-bit TP/BP's, try:

For I:=0 to $7FF DO
 memw[$B800:to+i]:=memw[$B800:from+i];

Or maybe (I can't test here)

Move ([$B800:from],[$B800:to],$1000);

(the $1000 <> $800 difference is 16-bit words vs bytes)

Re:More noob help needed please: 'asm'


Ross Simpson <rosssimpson@my_spammers_address.com.au> said the
following:
Quote
>"Marco van de Voort" <mar...@toad.stack.nl> wrote in message...

>> > True this is possibly the problem. It could well be the Pascal
>> > solution would be to use the mem(); or memw(); maybe the
>equivalant
>> > here. I'll have to look into this.

>> There is no Pascal equivalent. The registers are not directly
>accessable.
>> It could be possible to mimic the functionality of a larger set if
>assembler
>> instructions, but not just this single one.

>Okay, however for you information basically what I'm looking for is a
>Pascal equivalant to the CopyScreen procedure which I've included
>below. Surely there must be a way to do that, wouldn't there?

Already answered in this thread:

Message-ID: <avl5nqDVAig9Ews8@creaky.hole>
From: Pedt <"\"@ @\""@dontspame.com>
Date: Fri, 13 Sep 2002 18:27:49 +0100

--
Pedt

Re:More noob help needed please: 'asm'


On Sun, 15 Sep 2002 12:00:41 +1000, "Ross Simpson"

Quote
<rosssimpson@my_spammers_address(optusnet).com.au> wrote:
>"Ralf A. Quint" <ralf_qu...@hottmail.com> wrote in message...

>> The Regs record in TP is just used for loading register values as a
>> setup for an interrupt call with either Intr or MsDOS, and has
>nothing
>> to do with "assembler programming" in Pascal.

>Sure I think you can use the mem(); & memw(); in conjunction with it.
>That maybe the solution.

for the problem of the OP, a simple move() call would already do it,
just as John already mentioned...

Quote

>> Pascal is a high-level language, you simply can't translate
>> instructions to/from assembler 1:1.
>> One (simple) Pascal instruction can consists of up to hundereds of
>> assembler instructions and the majority of assembler instructions
>> can't be translated into a matching Pascal statement.

>I've seen some stuff the size of routines like this been translated
>into Pascal & no I'm not referning to the:
> mov ax,0003h
> int 10h
>to:
> regs.ax:=$0003;
> intr($10,regs);
>stuff.

>As I've mentioned to Femme I'll look further into this.

No offense, but there is not much you will find. There is nothing else
to replace asm code of TP/BP 7 with Pascal code for TP5.5.

Beside support for interrupt calls, you have some memory access arrays
(mem []) as well as some I/O port access "pseudo" arrays (port []),
but that is as far as it gets.....

Otherwise, you have only the choice of using inline () statements or
external .OBJ files linked in.

Ralf

Re:More noob help needed please: 'asm'


"Ross Simpson" <rosssimpson@my_spammers_address(optusnet).com.au> wrote in
message news:3d83e93f$0$22175$afc38c87@news.optusnet.com.au...

Quote
> "Femme Verbeek"  wrote in message...
> > > Just out of interest would anyone here know a Pascal equivalant to
> > > this statement: 'mov ax,es:[si]'. I 'am using TP 5.5 & have no
> > > intention to change to 7. For example in TP 5.5 you could do this
> for
> > > a statement like 'mov cx,$b800' in the form of this:

> > > uses dos; {this is required for setting up the registers}

> > > var regs : registers; {just defining the regs statement}
> > > begin
> > >  regs.cx:=$b800; {pascal equivalant to 'mov cx,$b800'}
> > > end.

> > > If anyone could let me know what 'mov ax,es:[si]' means in pascal
> I
> > > should be able to interpret this for TP 5.5.
...
> > So the assignment
> >   regs.cx:=$b800;
> > is not the pascal equivalent to 'mov cx,$b800' but it is an
> assignment of
> > $B800 to the cx field in the regs parameter, which is more than one
> > assembler instruction.

> Ah, but as Ralf said Pascal is a high level language! But with 'mov
> cx,$b800' your assigning the value of b800h to cx. It's the same as
> 'regs.cx:=$b800'! :-)

regs.cx is not the cx register! They have similar names and one gets copied
to the other but they are separate entities!

But to answer your question, mov ax,es:[si] means: take what's in the es
register, use that as a segment value; take what's in the si register, use
that as an offset value, take the word in the memory address specified by
that segment and offset and copy that to the ax register. In Pascal it would
be something like
  ax := MemW[es:si];
except, of course, that you don't have direct access to the ax, es or si
registers.

And by now you probably know why you don't need to know that!

FP

Go to page: [1] [2]

Other Threads