Page 3 sur 26

Publié : jeu. 11/déc./2008 22:10
par Progi1984
Ma fonction :

Code : Tout sélectionner

ProcedureDLL S08_GetVarL(MyArrayL.l(1), Num.l) ; Commebt
	Protected sContent.s, lInc.l
	For lInc = 1 To  10
	  sContent + "ID : " + Str(lInc)+ " - Element : "+Str(MyArrayL(lInc))
	Next
	MessageRequester("S07_GetVarL", sContent)
	ProcedureReturn #True
EndProcedure
Le code ASM :

Code : Tout sélectionner

; 
; PureBasic 4.20 (Windows - x86) generated code
; 
; (c) 2008 Fantaisie Software
; 
; The header must remain intact for Re-Assembly
; 
; String
; StringExtension
; Requester
; FileSystem
; Date
; Object
; SimpleList
; :System
; KERNEL32
; :Import
; 
format MS COFF
; 
extrn _ExitProcess@4
extrn _GetModuleHandleA@4
extrn _HeapCreate@12
extrn _HeapDestroy@4
; 
extrn _PB_FreeSimpleLists@0
extrn _PB_InitRequester@0
extrn _PB_InitSimpleList@0
extrn _PB_MessageRequester@8
extrn _PB_Str@8
extrn _SYS_CopyString@0
extrn _memset
extrn SYS_AllocateString
extrn _SYS_FreeString@4
extrn _PB_StringBase
extrn PB_StringBase
extrn _SYS_InitString@0
; 
extrn _PB_StringBasePosition
public _PB_Instance
public _PB_ExecutableType
public _PB_MemoryBase
public PB_Instance
public PB_MemoryBase
public _PB_EndFunctions
public _PB_DEBUGGER_LineNumber
public _PB_DEBUGGER_IncludedFiles

macro pb_public symbol
{
  public  _#symbol
  public symbol
_#symbol:
symbol:
}

macro    pb_align value { rb (value-1) - ($-_PB_DataSection + value-1) mod value }
macro pb_bssalign value { rb (value-1) - ($-_PB_BSSSection  + value-1) mod value }
public PureBasicStart
; 
section '.code' code readable executable
; 
; 
PureBasicStart:
; 
  PUSH   dword I_BSSEnd-I_BSSStart
  PUSH   dword 0
  PUSH   dword I_BSSStart
  CALL  _memset
  ADD    esp,12
  PUSH   dword 0
  CALL  _GetModuleHandleA@4
  MOV    [_PB_Instance],eax
  PUSH   dword 0
  PUSH   dword 4096
  PUSH   dword 0
  CALL  _HeapCreate@12
  MOV    [PB_MemoryBase],eax
  CALL  _SYS_InitString@0
  CALL  _PB_InitSimpleList@0
  CALL  _PB_InitRequester@0
; :
; ProcedureDLL S08_GetVarL(MyArrayL.l(1), Num.l) ; Commebt
macro MP0{
_Procedure0:
  PUSH   ebp
  PUSH   ebx
  PS0=24
  XOR    eax,eax
  PUSH   eax
  PUSH   eax
  PUSH   eax                                                                                                                                                                                    
  MOV    eax,dword [esp+PS0+0]
  MOV    dword [esp+0],eax
; Protected sContent.s, lInc.l
; For lInc = 1 To  10
  MOV    dword [esp+8],1
_For1:
  MOV    eax,10
  CMP    eax,dword [esp+8]
  JL    _Next2
; sContent + "ID : " + Str(lInc)+ " - Element : "+Str(MyArrayL(lInc))
  MOV    edx,dword [esp+4]
  PUSH   dword [_PB_StringBasePosition]
  CALL  _SYS_CopyString@0
  MOV    edx,_S1
  CALL  _SYS_CopyString@0
  MOV    eax,[_PB_StringBasePosition]
  PUSH   eax
  PUSH   eax
  PUSH   dword [esp+20]
  CALL  _PB_Str@8
  POP    eax
  MOV    edx,_S2
  CALL  _SYS_CopyString@0
  MOV    eax,[_PB_StringBasePosition]
  PUSH   eax
  PUSH   eax
  MOV    ebx,dword [esp+20]
  MOV    edx,[esp+12]
  MOV    ebp,dword [edx]
  SAL    ebx,2
  PUSH   dword [ebp+ebx]
  CALL  _PB_Str@8
  POP    eax
  LEA    ecx,[esp+8]
  POP    edx
  CALL   SYS_AllocateString
; Next
_NextContinue2:
  INC    dword [esp+8]
  JMP   _For1
_Next2:
; MessageRequester("S07_GetVarL", sContent)
  PUSH   dword [esp+4]
  PUSH   dword _S3
  CALL  _PB_MessageRequester@8
; ProcedureReturn #True
  MOV    eax,1
  JMP   _EndProcedure1
; EndProcedure
  XOR    eax,eax
_EndProcedure1:
  PUSH   dword [esp+4]
  CALL  _SYS_FreeString@4
  ADD    esp,12
  POP    ebx
  POP    ebp
  RET    8
}
_PB_EOP_NoValue:
  PUSH   dword 0
_PB_EOP:
  CALL  _PB_EndFunctions
  PUSH   dword [PB_MemoryBase]
  CALL  _HeapDestroy@4
  CALL  _ExitProcess@4
_PB_EndFunctions:
  CALL  _PB_FreeSimpleLists@0
  RET
; 
MP0
; 
section '.data' data readable writeable
; 
_PB_DataSection:
_PB_DEBUGGER_LineNumber: dd -1
_PB_DEBUGGER_IncludedFiles: dd 0
_PB_ExecutableType: dd 0
public _SYS_StaticStringStart
_SYS_StaticStringStart:
_S1: db "ID : ",0
_S3: db "S07_GetVarL",0
_S2: db " - Element : ",0
pb_public PB_NullString
  db     0
public _SYS_StaticStringEnd
_SYS_StaticStringEnd:
align 4
align 4
s_s:
  dd     0
  dd     -1
align 4
; 
section '.bss' readable writeable
_PB_BSSSection:
align 4
; 
I_BSSStart:
_PB_MemoryBase:
PB_MemoryBase: rd 1
_PB_Instance:
PB_Instance: rd 1
; 
align 4
PB_DataPointer rd 1
align 4
align 4
align 4
align 4
I_BSSEnd:
section '.data' data readable writeable
SYS_EndDataSection:
ASM :
----- Shared

Code : Tout sélectionner

format MS COFF

public _S1
public _S3
public _S2
public _PB_BSSSection
public PB_DataPointer

section '.data' data readable writeable

_SYS_StaticStringStart:
_S1: db "ID : ",0
_S3: db "S07_GetVarL",0
_S2: db " - Element : ",0
db     0
_SYS_StaticStringEnd:
section '.bss' readable writeable

_PB_BSSSection:
align 4
PB_DataPointer rd 1
align 4
align 4
align 4
align 4
section '.data' data readable writeable


----- Init

Code : Tout sélectionner

format MS COFF

extrn _SYS_InitString@0

Public PB_Samples08Windows_Init

PB_Samples08Windows_Init:
CALL _SYS_InitString@0
RET 

----- S08_GetVarL

Code : Tout sélectionner

format MS COFF

public PB_S08_GetVarL

extrn _PB_StringBasePosition
extrn _SYS_CopyString@0
extrn _S1
extrn _PB_Str@8
extrn _S2
extrn SYS_AllocateString
extrn _S3
extrn _PB_MessageRequester@8
extrn _SYS_FreeString@4

_Procedure0:
PB_S08_GetVarL:

PUSH   ebp
PUSH   ebx
PS0=24
XOR    eax,eax
PUSH   eax
PUSH   eax
PUSH   eax
MOV    eax,dword [esp+PS0+0]
MOV    dword [esp+0],eax
MOV    dword [esp+8],1
_For1:
MOV    eax,10
CMP    eax,dword [esp+8]
JL    _Next2
MOV    edx,dword [esp+4]
PUSH   dword [_PB_StringBasePosition]
CALL  _SYS_CopyString@0
MOV    edx,_S1
CALL  _SYS_CopyString@0
MOV    eax,[_PB_StringBasePosition]
PUSH   eax
PUSH   eax
PUSH   dword [esp+20]
CALL  _PB_Str@8
POP    eax
MOV    edx,_S2
CALL  _SYS_CopyString@0
MOV    eax,[_PB_StringBasePosition]
PUSH   eax
PUSH   eax
MOV    ebx,dword [esp+20]
MOV    edx,[esp+12]
MOV    ebp,dword [edx]
SAL    ebx,2
PUSH   dword [ebp+ebx]
CALL  _PB_Str@8
POP    eax
LEA    ecx,[esp+8]
POP    edx
CALL   SYS_AllocateString
_NextContinue2:
INC    dword [esp+8]
JMP   _For1
_Next2:
PUSH   dword [esp+4]
PUSH   dword _S3
CALL  _PB_MessageRequester@8
MOV    eax,1
JMP   _EndProcedure1
XOR    eax,eax
_EndProcedure1:
PUSH   dword [esp+4]
CALL  _SYS_FreeString@4
ADD    esp,12
POP    ebx
POP    ebp
RET    8

Donc comme tu peux le voir par de labels "a_"

Publié : ven. 12/déc./2008 7:04
par Anonyme2
Oui pas de label a_ car tu as bien passé un tableau mais tu n'a pas déclaré de tableau (DIm) ce qui ne crée pas de variable globale en datasection (cas du tableau global).


Il y a le cas d'un tableau global et celui d'un tableau local, il faut faire des codes PB et regarder le code asm obtenu pour voir comment ça se déroule.

Je regarderais cet après-midi.

Donnes -moi un lien pour télécharger Moebius avec un code PB d'exemple de procedure à transformer et un code d'utilisation.

A+

Publié : ven. 12/déc./2008 7:32
par Progi1984
Télécharge le zip !

File:1->cf plus bas

Oublie pas de modifier les fichiers Prefs\Moebius_Windows.ini et les Lib_Source\Project_Sample0x.ini.
Pour lancer la userlibation d' un fichier Lib_Source\Sample0x.pb, change la toute première variable dans Moebius_Main.pb.

Tite question, quand on utilise les newlists (exemple07), on a pas besoin de les déclarer comme tu le dis.

Les tableaux (exemple08).

Publié : sam. 13/déc./2008 19:28
par Progi1984
As tu trouvé une piste ?

Publié : dim. 14/déc./2008 7:29
par Anonyme2
Je n'ai pas regardé, j'étais absent ces deux jours

A+

Publié : dim. 14/déc./2008 17:22
par Progi1984
Pas de problème, c'était pour information. J'étais aussi absent. Je m'y réattaque aussi aujourd'hui :)

[UPDATE 17:20] Ajouté dans le SVN : gestion des paramètres facultatifs.

Publié : lun. 15/déc./2008 14:06
par Progi1984
Je me posais la question : est ce que je n'aurais pas oublié d'initialiser les listes via la func "_PB_InitSimpleList@0" qui est appellé dans le PureBasicStart ?

PS : A quoi sert le PureBasicStart ?

Publié : lun. 15/déc./2008 14:57
par Anonyme2
Progi1984 a écrit :Je me posais la question : est ce que je n'aurais pas oublié d'initialiser les listes via la func "_PB_InitSimpleList@0" qui est appellé dans le PureBasicStart ?

PS : A quoi sert le PureBasicStart ?
Je ne sais pas mais je pense que cela initialise les variables utilisées par PB comme PB_StringBase etc.

Comme bien souvent en asm, je fais des essais, tu peux ajouter cette initialisation et recompiler mais je ne sais pas si tu crées un fichier bat sous windows permettant de recompiler la librairie (ce que Tailbite fait).

Pour la déclaration des listes chainées ou tableaux, oui on ne doit pas les déclarer sauf si une procedure en utilise une globale (procedure ou shared) mais là il faudra faire des essai pour les différents cas.

Publié : lun. 15/déc./2008 15:17
par Anonyme2
J'essaye de compiler le fichier Moebius_Main.pb mais ça plante dans la procedure ProcedureDLL Log_Add(Content.s, NumTab.l = 0), avec l'erreur " le fichier n'est pas initialisé


La ligne

WriteStringN(hFileLog, Space(NumTab) + Content)


Je fais quoi maintenant ?

Tu dois tester avant d'écrire sinon ...

Publié : lun. 15/déc./2008 19:14
par Progi1984
Désolé, je fais de mon mieux mais j'ai quelques oublis.

Code amélioré et réparé.
File:1->Proj_Moebius_2008_12_15.zip
Image

Pour le batch, il est prévu pour la prochaine version. par contre, pour l'instant, tu as le Debug.

Publié : jeu. 18/déc./2008 8:39
par Progi1984
Je vais migrer le code en Purebasic 4.3 ce we.

Peut-être le code ASM aura t il changé avec les nouvelles règles pour les tableaux & listes en paramètre ?!

Publié : jeu. 18/déc./2008 9:34
par Anonyme2
Bon,

je vais essayer de regarder un peu plus tout ça car pour l'instant je travaille mon projet perso et je galère (mais je finirais par y arriver).

Publié : ven. 19/déc./2008 16:09
par Progi1984
Bon, j'ai passé le code en 4.30 (en 10 minutes). Faut que je remette à jour le package pour Denis.

Mais j'ai pas avancé sur ce point !

Publié : dim. 21/déc./2008 16:12
par Anonyme2
Tu as mis en ligne ?

Publié : lun. 22/déc./2008 12:00
par Progi1984
Et voilà :
File:1->Proj_Moebius.zip
Image

Pour informations, j'ai aussi inclus trois petits trucs de la v0.6 :
* IMPROVED : Getting Error Message for FASM in Log
* IMPROVED : In desc file, adds some comments
* ADDED : Creation of Batch for building the userlib

Le plus important étant la création de batchs :)