pascal + assembler 
Author Message
 pascal + assembler

Hello!

 I want to do some things:

 1. Write OBJ external procedure

 2. Send (FAST) some bytes (often i must check all bytes while sending)

 How to do that?

 Pascal program:

 type
       ekr = array[0..63999] of byte;
 var
       scr,bgr,sprt :^ekr;

  procedure Sending; external; far; {$L SEND.OBJ}

 begin
  New(scr); New(bgr);
  Sending bytes...
  Dispose(scr); Dispose(bgr);
 end.

 and i got SEND.ASM (compiled to OBJ of course)

  something like that:

   lds si , bgr
   les di , scr
   mov cx , 16000
   movsd
   lds si , sprt
   les di , scr

   lodsb
   cmp al , 0

   stosb

 why it doesn't work?

 i need your help especially with calculating ds,es,si,di - many times all i got
was error (with sending, not declaring, so i think lds and les not working well
;-)). what am i doing wrong? maybe one of you got some working model?

 please help.

PS: i don't want to use Move because i must check all bytes in some causes.

--
greetings

 ukasz Nowicki

 Queen, Taekwondo, Pascal, Lyrics, FreeDOS PL mirror
  http://www.*-*-*.com/
 want to see some action? www.jagoda.kki.pl/luke.mpg



Tue, 15 Apr 2003 22:50:07 GMT  
 pascal + assembler


Quote:
> Hello!

>  I want to do some things:

>  1. Write OBJ external procedure

>  2. Send (FAST) some bytes (often i must check all bytes while
>  sending)

>  How to do that?

> Pascal program:

> type
>   ekr = array[0..63999] of byte;
> var
>   scr,bgr,sprt :^ekr;

> procedure Sending; external; far; {$L SEND.OBJ}

>  begin
>   New(scr); New(bgr);
>   Sending bytes...
>   Dispose(scr); Dispose(bgr);
> end.

> and i got SEND.ASM (compiled to OBJ of course)

> something like that:

push ds

Quote:
>   lds si , bgr
>   les di , scr
>   mov cx , 16000
>   movsd

pop ds
push ds

Quote:
>   lds si , sprt
>   les di , scr
>   mov cx , 64000

>   lodsb
>   cmp al , 0

>   stosb


pop ds

Quote:

> why it doesn't work?

> i need your help especially with calculating ds,es,si,di - many
> times all i got was error (with sending, not declaring, so i think
> lds and les not working well ;-)). what am i doing wrong? maybe one
> of you got some working model?

>  please help.

> PS: i don't want to use Move because i must check all bytes in some
> causes.

Need, as added above, to save and restore DS! BTW, you don't need
external .OBJ to use MOVSD! Use "db $66; movsw"

Robert
--
Robert AH Prins

Sent via Deja.com http://www.deja.com/
Before you buy.



Wed, 16 Apr 2003 18:41:03 GMT  
 pascal + assembler

Quote:
> Need, as added above, to save and restore DS! BTW, you don't need
> external .OBJ to use MOVSD! Use "db $66; movsw"

i used pop and push ds - but i forgot to write it here. my shame. thanks for
help anyway and please send me some more!

--
greetings

 ukasz Nowicki

 Queen, Taekwondo, Pascal, Lyrics, FreeDOS PL mirror
 http://www.jagoda.kki.pl/
 want to see some action? www.jagoda.kki.pl/luke.mpg



Wed, 16 Apr 2003 21:03:40 GMT  
 pascal + assembler
you are leaving out too much, either on purpose or by mistake. so, it
looks like your code needs more work than someone may want to do for
you.



Quote:
>Hello!
> I want to do some things:
> 1. Write OBJ external procedure
> 2. Send (FAST) some bytes (often i must check all bytes while sending)



Wed, 16 Apr 2003 23:51:25 GMT  
 pascal + assembler

Quote:
> you are leaving out too much, either on purpose or by mistake. so, it
> looks like your code needs more work than someone may want to do for
> you.

I think you din't understand me. I did it all - but it doesn't work! I wrote
Pascal program and asm file... I am able to link but there must be some mistake
in my code.
I just want to know how to write asm procedure (or as assembly inside with help
from Robert AH Prins (thanx man!)).

--
pozdrawiam

 Lukasz Nowicki

 Queen, Taekwondo, Pascal, Wiersze, Opowiadania, FreeDOS PL mirror
 http://www.jagoda.kki.pl/
 want to see some action? www.jagoda.kki.pl/luke.mpg



Thu, 17 Apr 2003 01:47:48 GMT  
 pascal + assembler
actually, i do understand what i see.

i saw Robert's advice about PUSH/POP DS, but then you said you did
that already! so, that is something you left out of the code posted
here. personally, i don't want to guess what you might already have
done, but haven't posted, just for you to tell me that you did it. my
only other option is to write the whole thing from scratch for you!

based on what you've bothered to post, your assembly code is nowhere
near complete. for example, the entry / exit code and assembler
declarations are missing. (IMO, the Sending procedure should
explicitly pass the pointers as parameters, rather than use global
variables.)

to keep things simple, implement the Sending procedure using 16-bit
inline assembly code, then tweak it to 32-bit after it's working.

p.s. don't forget the use of REP with movs!

http://spacegroove.com/telic/bn/embedded.htm



Quote:
>> you are leaving out too much, either on purpose or by mistake. so, it
>> looks like your code needs more work than someone may want to do for
>> you.

>I think you din't understand me. I did it all - but it doesn't work! I wrote
>Pascal program and asm file... I am able to link but there must be some mistake
>in my code.
>I just want to know how to write asm procedure (or as assembly inside with help
>from Robert AH Prins (thanx man!)).



Thu, 17 Apr 2003 17:17:50 GMT  
 pascal + assembler

Quote:
> based on what you've bothered to post, your assembly code is nowhere
> near complete. for example, the entry / exit code and assembler
> declarations are missing. (IMO, the Sending procedure should
> explicitly pass the pointers as parameters, rather than use global
> variables.)

that because i wasn't post  my procedure - i rewrote it from my memory.

{****************************************}
{$L SEND.OBJ}
type
              ekr = array[0..63999] of byte;
var
              scr,tlo :^ekr;
 {$F+}
 procedure SEND; EXTERNAL;
 {$F-}
begin
 New(scr); New(tlo);
 Send;
 Dispose(scr); Dispose(tlo);
end.
{****************************************}
.386
.MODEL TPASCAL
.CODE
 EXTRN SCR
 EXTRN TLO
 SEND PROC FAR
 PUBLIC SEND
   push ds
   cld
   mov cx , 16000
   les si , tlo
   lds di , scr
   rep movsd
   pop ds
   ret
 SEND ENDP
   mov ax , 04C01h
   int 21h
 CODE ENDS
 END
{****************************************}

Of course I can send variables as arguments, but that is not all - there will be
much more variables. And I can write it inside program - but  the asm program
will be longer :-)

TIA for help
--
greetings

 Lukasz Nowicki

 Queen, Taekwondo, Pascal, Lyrics, FreeDOS PL mirror
 http://www.jagoda.kki.pl/
 want to see some action? www.jagoda.kki.pl/luke.mpg



Thu, 17 Apr 2003 18:50:44 GMT  
 pascal + assembler


Quote:
>.386
>.MODEL TPASCAL

tlo and scr are declared in the pascal data segment, so declare them
external in the asm .DATA segment

.DATA

Quote:
> EXTRN SCR
> EXTRN TLO

.CODE

Quote:
> SEND PROC FAR
> PUBLIC SEND
>   push ds
>   cld
>   mov cx , 16000
>   les si , tlo
>   lds di , scr

If you want to SEND from scr^ to tlo^ then use
    les di, [tlo]
    lds si, [scr]
else
    les di, [scr]
    lds si, [tlo]

Remember: source is in ds/si and dest in es/di.

Quote:
>   rep movsd
>   pop ds
>   ret
> SEND ENDP

These two lines are dead code

Quote:
>   mov ax , 04C01h
>   int 21h
> CODE ENDS
> END

Wolfgang
--
In order to e-mail me a reply to this message, you will have
to remove PLEASE.REMOVE from the address shown in the header.


Fri, 18 Apr 2003 05:46:23 GMT  
 pascal + assembler

Quote:
> >.386
> >.MODEL TPASCAL

> tlo and scr are declared in the pascal data segment, so declare them
> external in the asm .DATA segment

THANK YOU VERY MUCH :-))))

Quote:
> If you want to SEND from scr^ to tlo^ then use
>     les di, [tlo]
>     lds si, [scr]
> else
>     les di, [scr]
>     lds si, [tlo]

> Remember: source is in ds/si and dest in es/di.

:-)

Quote:
> Wolfgang

Thank You once again :-)

--
greetings

 ukasz Nowicki

 Queen, Taekwondo, Pascal, Lyrics, FreeDOS PL mirror
 http://www.jagoda.kki.pl/
 want to see some action? www.jagoda.kki.pl/luke.mpg



Fri, 18 Apr 2003 14:56:44 GMT  
 pascal + assembler
And I got one for question (last I hope :-)

I want to send fastest as it possible bytes with checking values. I tried this
code:

lds si , ruch
les di , scr

mov al , byte ptr ds:[si]
cmp al , 0


 inc si
 inc di

How to accelerate this?

TIA

--
greetings

 ukasz Nowicki

 Queen, Taekwondo, Pascal, Lyrics, FreeDOS PL mirror
 http://www.jagoda.kki.pl/
 Want to see hot action?
 www.jagoda.kki.pl/luke1.mpg
 www.jagoda.kki.pl/luke2.mpg
 www.jagoda.kki.pl/luke3.mpg



Fri, 18 Apr 2003 19:01:24 GMT  
 pascal + assembler
On Mon, 30 Oct 2000 12:01:24 +0100, =?iso-8859-2?Q?=A3ukasz_Nowicki?=

Quote:

>And I got one for question (last I hope :-)

>I want to send fastest as it possible bytes with checking values. I tried this
>code:

>lds si , ruch
>les di , scr
>mov cx , 64000

>mov al , byte ptr ds:[si]
>cmp al , 0

>mov byte ptr es:[di] , al

> inc si
> inc di

>How to accelerate this?

Back in the old days when cycle counting was reliable and not
black magic I would have said use

doit: lodsb
      or al,al
      jz skip
      stosb
skip: loop doit

as a starting point, but today there are many CPU/memory aspects to be
considered.

Dependig on the distribution of zeros in your data, it may be faster
to load a word, do a word compare against zero (with or ax,ax!?) and
perform two subsequent compares on al and ah.

And there are other optimisations if one of your src/dest is in video
memory (video memory is slow).

Another point to consider is the aligment (byte, word, dword ...) of
your data blocks.

To summarize: there is no single optimisation trick for your problem.
--
In order to e-mail me a reply to this message, you will have
to remove PLEASE.REMOVE from the address shown in the header.



Sat, 19 Apr 2003 05:29:55 GMT  
 pascal + assembler

Quote:
> And there are other optimisations if one of your src/dest is in video
> memory (video memory is slow).

So I'm gonna put all data (background, sprites, text etc. in SCR (variable in
RAM) and then put only "SCR" to video memory :-)

Quote:
> To summarize: there is no single optimisation trick for your problem.

Anyway, thank You very much for Your help :-)

--
pozdrawiam

 ukasz Nowicki

 Queen, Taekwondo, Pascal, Wiersze, Opowiadania, FreeDOS PL mirror
 http://www.jagoda.kki.pl/
 Want to see hot action?
 www.jagoda.kki.pl/luke1.mpg
 www.jagoda.kki.pl/luke2.mpg
 www.jagoda.kki.pl/luke3.mpg



Sat, 19 Apr 2003 17:33:47 GMT  
 pascal + assembler

Quote:

>I want to send fastest as it possible bytes with checking values. I tried this
>code:

>lds si , ruch
>les di , scr
>mov cx , 64000

>mov al , byte ptr ds:[si]
>cmp al , 0

>mov byte ptr es:[di] , al

> inc si
> inc di

>How to accelerate this?

First, get rid of loop. dec cx; jnz is much faster, at least on
Pentium.

Second, you can get rid of the middle jump:

lds si , ruch
les di , scr

mov al , byte ptr ds:[si]
inc si
inc di
dec cx

or al,al

mov byte ptr es:[di-1] , al

mov b
cmp al , 0

Of course there are ways that are faster. The fastest method depends on
the data. You could read a word or dword at a time. This makes the code
more complicated though.

Osmo



Mon, 21 Apr 2003 02:37:13 GMT  
 pascal + assembler

Thank You for help :-)

--
greetings

 ?ukasz Nowicki

 Queen, Taekwondo, Pascal, Lyrics, FreeDOS PL mirror
 http://www.jagoda.kki.pl/
 Want to see hot action?
 www.jagoda.kki.pl/luke1.mpg
 www.jagoda.kki.pl/luke2.mpg
 www.jagoda.kki.pl/luke3.mpg



Mon, 21 Apr 2003 04:58:39 GMT  
 
 [ 14 post ] 

 Relevant Pages 

1. Pascal-Assembler

2. Turbo Pascal (assembler)

3. 3D engine/vesa/pascal assembler

4. pascal/assembler

5. Mouse Drivers in Pascal (possibly some assembler) ?

6. Turbo Pascal 7.0 inline assembler and 386 and newer instructions

7. translate assembler code into turbo pascal code

8. 386 assembler in Turbo Pascal

9. Translate Assembler to Pascal

10. Pascal to assembler converter

11. can I get the real time running...with assembler coding or in pascal

12. 386/486 assembler instructions with Turbo Pascal 7.

 

 
Powered by phpBB® Forum Software