Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2001-01

asm

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author

I try to port some bp7 software to freepascal
I have some lib written in asm
when i try to run the example it bugs !
perhaps i to tired to see the error or i miss something in the 32 bit information...

A chercher = 0:151084
Tableau = 0:151080
An unhandled exception occurred at 0x00021759 :
Access violation
0x00021759 CHERCHE_PLUS_ZONE, line 71 of g:/pp/adeli/test32.pas 0x00021827 main, line 121 of g:/pp/adeli/test32.pas 0x0000206D

I try to check the value in register with both ide in dos and win33 mode and gdb in win32 mode wiht the same result the value of ds,es,esi,edi are the same as printed....

{$ASMMODE INTEL}
{ debut poinbte sur le numÚro de l'ÚlÚment...
Var_tableau contient  }
function cherche_plus_zone(debut:longint;
                      var var_a_chercher;
                      taille:longint;
                      var var_tableau;
                      taille_element:longint; { taille de base d'un ÚlÚment du
tableau ou du record}
                      nombre_element:longint  { nombre d'element dans le
tableau}
                      ) :longint;
var sseg:word;
    oofs:longint;
    sseg_tab:word;
    oofs_tab:longint;
    pt:p_stock;
    a:longint;
begin
writeln('A chercher = ',seg(var_a_chercher),':',ofs(var_a_chercher));
sseg:=seg(var_a_chercher);
oofs:=ofs(var_a_chercher);
pt:=p_stock(var_a_chercher);
writeln('Tableau = ',seg(var_tableau),':',ofs(var_tableau));
sseg_tab:=seg(var_tableau);
oofs_tab:=ofs(var_tableau);
a:=pt^.texte;
asm
     push ds
     push es
     cld
     mov eax, debut
     mov edi, taille_element
     mul edi
     xor edi,edi     {on calcul l'offset de dÚplacement..}

{ les edi, var_a_chercher}
mov edi, oofs
mov es,sseg
add edi,eax

mov ebx, debut
{ lds esi, var_tableau}
mov ds, sseg_tab
mov esi, oofs_tab
mov edx,esi

@boucle_plus_zone:
mov ecx, taille_element
{line just for test the adresse es:[edi]}

mov eax, dword ptr es:[edi] { here is a bug }

{line just for test the adresse in ds:[esi]}
mov al, byte ptr ds:[esi] { here is the other bug }

repe
cmpsb {HERE is the bug}
je @egal_plus_zone
clc

inc ebx

mov ecx,eax
mov eax,ebx
mov esi,edx
mov edi, taille_element
mul edi
xor edi,edi
mov edi,eax
mov eax,ecx

mov edx,esi
cmp ebx,nombre_element
jb @boucle_plus_zone
mov ebx,0FFFFFFFFH

@egal_plus_zone:
mov eax,ebx
pop es
pop ds

  end ['EAX','EBX','ECX','EDX','ESI','EDI'];

end;

Lionel Drevon
Adeli http://www.adeli.fr
618 Av. Gal de Gaulle Tel 04 78 66 11 85
69760 Limonest Fax 04 78 66 04 33

Reply by email

Marco van de Voort
to Unknown author

[Charset ISO-8859-1 unsupported, filtering to ASCII...]

Show quoted text 17 lines
I try to port some bp7 software to freepascal I have some lib written in asm when i try to run the example it bugs ! perhaps i to tired to see the error or i miss something in the 32 bit information... A chercher = 0:151084 Tableau = 0:151080 An unhandled exception occurred at 0x00021759 : Access violation 0x00021759 CHERCHE_PLUS_ZONE, line 71 of g:/pp/adeli/test32.pas 0x00021827 main, line 121 of g:/pp/adeli/test32.pas 0x0000206D I try to check the value in register with both ide in dos and win33 mode and gdb in win32 mode wiht the same result the value of ds,es,esi,edi are the same as printed....

You shouldn't use seg or ofs, and leave the segment registers alone. Ordinary variables are in your own segment, and the descriptors ds and es already point to it.

I marked the lines to be removed by putting '-' to the beginning of the line and the not commented lines are new.

Show quoted text 19 lines
{$ASMMODE INTEL} { debut poinbte sur le num_ro de l'_l_ment... Var_tableau contient } function cherche_plus_zone(debut:longint; var var_a_chercher; taille:longint; var var_tableau; taille_element:longint; { taille de base d'un _l_ment du tableau ou du record} nombre_element:longint { nombre d'element dans le tableau} ) :longint; var sseg:word; oofs:longint; sseg_tab:word; oofs_tab:longint; pt:p_stock; a:longint; begin
- writeln('A chercher = ',seg(var_a_chercher),':',ofs(var_a_chercher));
- sseg:=seg(var_a_chercher);
- oofs:=ofs(var_a_chercher);
pt:=p_stock(var_a_chercher);
- writeln('Tableau = ',seg(var_tableau),':',ofs(var_tableau));
- sseg_tab:=seg(var_tableau);
- oofs_tab:=ofs(var_tableau);
a:=pt^.texte; asm

- push ds
- push es

cld mov eax, debut mov edi, taille_element mul edi

mov edi,var_a_chercher

xor edi,edi {on calcul l'offset de d_placement..} { les edi, var_a_chercher}

- mov edi, oofs
- mov es,sseg

add edi,eax mov ebx, debut

mov esi,var_tableau
- { lds esi, var_tableau}
- mov ds, sseg_tab
- mov esi, oofs_tab

Show quoted text 7 lines
mov edx,esi @boucle_plus_zone: mov ecx, taille_element {line just for test the adresse es:[edi]}

- mov eax, dword ptr es:[edi] { here is a bug } mov eax, dword ptr [edi]

{line just for test the adresse in ds:[esi]}

- mov al, byte ptr ds:[esi] { here is the other bug } mov al, byte ptr [esi]

Show quoted text 25 lines
repe cmpsb {HERE is the bug} je @egal_plus_zone clc inc ebx mov ecx,eax mov eax,ebx mov esi,edx mov edi, taille_element mul edi xor edi,edi mov edi,eax mov eax,ecx mov edx,esi cmp ebx,nombre_element jb @boucle_plus_zone mov ebx,0FFFFFFFFH @egal_plus_zone: mov eax,ebx

- pop es
- pop ds

end ['EAX','EBX','ECX','EDX','ESI','EDI']; end;

Reply by email

Unknown author
to Unknown author: I try to port some bp7 software to freepascal I have some lib written in asm when i try…

From: ""
To:
Date sent: Fri, 12 Jan 2001 00:06:10 +0100
Priority: normal
Subject: [fpc-pascal]asm
Send reply to:

I try to port some bp7 software to freepascal

ok when i use asm
2 thinks
Don' t toiuch the ds,es,fs,gs segment they are ready with the good value... when you use seg(pt^) the segment is not the same value as in the asm value of ds,e,s,gs,fs !

Lionel Drevon
Adeli http://www.adeli.fr
618 Av. Gal de Gaulle Tel 04 78 66 11 85
69760 Limonest Fax 04 78 66 04 33

Reply by email