flat assembler
Message board for the users of flat assembler.

flat assembler > IDE Development > A problems for those want to help for developement of Fresh.

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
JohnFound



Joined: 16 Jun 2003
Posts: 3494
Location: Bulgaria
[Problem 1]

It looks easy, but I have no time to write it. If someone want to help, I will be thankful. Smile
We need subroutine that must give unique name in the folowing patern: SomeNameNNN. It will use structure like folowing:

Code:
  struc TName {
    .Prefix    dd    ?    ; pointer (??? handle ) Prefix of the name.
    .Num      dd    ?    ; Current number.
}


proc MakeName, ptrTName
....
    


The procedure must return handle to string (look StrLib library in Fresh package) and increment the .Num member of the structure.
This will be used to generate unique names for forms and controls in Form editor.


[Problem 2]
This is harder.
I am talking about StrLib.asm library. Very soon we will need more functions from standard string library, but there is no free developer to make it. Search functions, string concatenation, maybe some
size and speed optimizations. StrToNum procedure (working with all FASM number formats).

It is very important, so every help is highly appreciated. Smile

[Problem 3]
Very hard problem IMHO.

For code completition function of source editor, we will need some function parsing source files and returning
list with all labels found in the source, that begings with given string. This function must be very fast and it must be compatible with the FASM syntax for labels, for example to find labels defined via "label" directive and to find labels defined in the macroses and structures. If it is possible the procedure may/must use some subroutines from FASM compiler (without modifying the compiler). But actually I don't know is it possible.

Thanks in advance.
John Found
Post 15 Sep 2003, 08:08
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7178
Location: Kraków, Poland
JohnFound wrote:
StrToNum procedure (working with all FASM number formats).

For this purpose you can use "get_number" routine from the fasm's source (EXPRESSI.INC file). It may be a bit complicated in use, but will give you full compatibility with fasm. It needs ESI to be the pointer to source string in the parser's internal format - it should be the byte 1Ah followed by the byte containing length of string and the string data then (first byte can also be 22h - that indicates the quoted string and in such case the double word containing length of string and the string data should follow). The functions sets CF when the given string is not a valid as number at all, if CF=0 and EBP is something but zero, the number is valid, but is out of 64-bit range, on which fasm operates. When CF=0 and EBP=0, quad word in EDX:EAX contains the value of number.
Post 15 Sep 2003, 08:45
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3494
Location: Bulgaria
Thanks Privalov.
Maybe we should make some wrapper function...

BTW: What you think about [Problem 3]? Smile Well, I know we talked about this before, but the problem is really complex for me. Sad
Post 15 Sep 2003, 09:01
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7178
Location: Kraków, Poland
JohnFound wrote:
BTW: What you think about [Problem 3]? Smile Well, I know we talked about this before, but the problem is really complex for me. Sad

Probably because it is really complex. Wink
There is no function in fasm that would help you with it without running the whole preprocessor and parser, so it seems you'll have to write a whole separate routine for this purpose. Symbol in fasm can be defined with "label", "segment", "load" or "extrn" directive (the "extrn" case is more complicated, as the "extrn 'name' as alias" syntax is allowed), or by being followed by ":" or "=" character or any of data directives (all are in "data_directives" table in X86.INC).
You could also run the whole preprocessor and then scan the result lines for labels - that would be much easier and more compatible, but probably not as fast as you need.


Last edited by Tomasz Grysztar on 15 Sep 2003, 09:15; edited 3 times in total
Post 15 Sep 2003, 09:09
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3494
Location: Bulgaria
Privalov wrote:
There is no function in fasm that would help you with it without running the whole preprocessor and parser, so it seems you'll have to write a whole separate routine for this purpose.


Hm, but what if we write separate procedure like: "flat_assembler" one but running only preprocessor and parser?
Post 15 Sep 2003, 09:14
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7178
Location: Kraków, Poland
You have asked while I was editing my post to add the last sentence. Smile
Post 15 Sep 2003, 09:16
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3494
Location: Bulgaria
Yea, I see it now. Why you think it will be slow? AFAIK, the preprocessor is very fast. One second for search I think is good enough, when you press '.' or Ctrl+Space in the source editor. How big sourse file can be preprocessed for one second on some Pentium 300MHz?
Besides this we may think about some caches for symbols and process only current changed files...
Post 15 Sep 2003, 09:24
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7178
Location: Kraków, Poland
All right, in such case it'll be enough. I thought you mean something that will be called very often, but if you can wait even one second on P300 for it, then it's OK. Wink
Post 15 Sep 2003, 09:36
View user's profile Send private message Visit poster's website Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1095
Location: Poland
Hi John,

First of all, you didn't specify if the names should be generated names like Name1, Name2, Name666, or like Name001, Name002, Name666. This proc generates Name001, Name002, etc. If you don't like it, I will rewrite this routine.

It uses one constant: MAKENAME_DIGITNO (heh, I didn't know how to name it Very Happy). It is used to determine number of digits to append to the string, ie. MAKENAME_DIGITNO=3 will generate Name001, while =6 will give Name000001.

The proc has one limitation: it doesn't care if the TName.Num fits in specified number of digits, so for prefix "FORM" and number 1000 it will give "FOR1000" (assuming that MAKENAME_DIGITNO=3). I don't think that this checking is necessary (proably there will never be Form789 in any project), but of course I can fix it SmileSmileSmile

Code:
MAKENAME_DIGITNO = 3

proc MakeName, ptrTName
.new_str dd ?
        enter
        push    ebx ecx edx esi edi

        mov     ebx,[ptrTName]
        inc     dword[ebx+4]            ; increase number in TName struc
        mov     eax,[ebx]
        call    StrLen
        push    ecx
        add     ecx,MAKENAME_DIGITNO
        xor     edi,edi
        call    NewStr
        mov     eax,edi
        mov     [.new_str],eax
        call    StrSetLength
        mov     esi,[ebx]
        call    CopyStr                 ; copy ptrTName->Prefix to newly created str

        mov     eax,edi                 ; compute offset of a number in new str
        call    StrPtr                  ; and store it in edi
        pop     ecx
        add     eax,ecx
        mov     edi,eax

        mov     ecx,MAKENAME_DIGITNO    ; fill a space for number with zeros
        mov     al,'0'
        rep     stosb

        dec     edi                     ; finally put the number in a string
        std
        mov     esi,10
        mov     eax,[ebx+4]             ; get ptrTName->Num
      .divide:
        xor     edx,edx
        div     esi
        add     dl,'0'
        xchg    al,dl
        stosb
        xchg    al,dl
        or      eax,eax
        jnz     .divide
        cld
        pop     edi esi edx ecx ebx
        mov     eax,[.new_str]
        return 
    


I didn't put it in as anttachment, because I think that you will proably copy that code and put it in one existing source file. Hope this proc is OK, but if not I can change it.

regards,
decard
Post 15 Sep 2003, 19:34
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3494
Location: Bulgaria
Hi decard.

Actually I think that the first type of names: Form1, Form2, ... Form78, ... Form999 etc. is more appropriate.

Take a look at the StrLib.asm / NumToStr procedure. It converts the numbers to string with diferent length. You can use temporary string defined as local variable to convert number and then to concatenate it with the prefix.
Post 15 Sep 2003, 19:45
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1095
Location: Poland
I have rewritten the proc to give the names with numbers but without leading zeros. Fortunatelly now it doesn't use any constants Very Happy

btw: I should have look at all functions from the StrLib.asm Embarassed

Code:
proc MakeName, ptrTName
.new_str dd ?
.buf rb 12   ; the number can have max. 11 digits, it is more 
                 ; than enough for any 32-bit decimal number
        enter
        push    ebx ecx edx esi edi

        xor     eax,eax                        ;   need to clear the buffer because
        mov     dword[.buf],eax           ;   NumToStr doesn't put NULL
        mov     dword[.buf+4],eax       ;   after the converted number,
        mov     dword[.buf+8],eax       ;
        mov     ebx,[ptrTName]
        inc     dword[ebx+4]            ; increase number in TName struc
        mov     eax,[ebx+4]
        mov     ecx,10
        lea     edi,[.buf]
        call    NumToStr                ; convert the number into a string
        lea     eax,[.buf]
        call    StrLen
        push    ecx                     ; push length of a converted num

        xor     edi,edi                 ; create new string
        call    NewStr
        mov     [.new_str],edi
        mov     esi,[ebx]               ; put ptrTName->Prefix into esi
        call    CopyStr
        mov     eax,edi                 ; calculate how many bytes our new string will need
        call    StrLen
        mov     edx,[esp]
        add     ecx,edx
        call    StrSetLength            ; set new length of our string
        add     eax,ecx
        pop     ecx             ; pop length of a converted num
        sub     eax,ecx
        mov     edi,eax
        lea     esi,[.buf]
        inc     ecx             ; needed to copy a NULL character      <-------!!!!!
        rep     movsb                   ; append a number to the name
        mov     eax,[.new_str]
        pop     edi esi edx ecx ebx
        return
    


Last edited by decard on 16 Sep 2003, 15:59; edited 1 time in total
Post 16 Sep 2003, 06:39
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3494
Location: Bulgaria
Hi, decard.

decard wrote:
I have rewritten the proc to give the names with numbers but without leading zeros. Fortunatelly now it doesn't use any constants Very Happy


It looks much better now. I will include it in the next realease. Just now I have no time to test, but it simply looks right. Smile
I like good commented programs.

Welcome in the team! Smile

BTW: Please, don't use this emoticon: "Embarassed" I don't like it. Very Happy
Your can't evaluate whole project for one day. Just keep good work. Smile

You can continue with [Problem 2], if you like the string processing.

regards.
Post 16 Sep 2003, 06:53
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1095
Location: Poland
I'm glad to hear that Very HappyVery Happy

I started to work with functions that you mentioned in [Problem 2], and soon I will post here new version of StrLib.

regards,
decard
Post 16 Sep 2003, 07:50
View user's profile Send private message Visit poster's website Reply with quote
Betov



Joined: 17 Jun 2003
Posts: 98
John, i am not quite sure about what you are talking about, with the "Name" problem, but, if this is for automatic generation of Symbols, NameXXX ("XXX" being a number) is not the good way.

I would bet that this would slow down a lot the Name parsing of FASM.

Much better is having the Names under the form fo "AAAAAAAA'. The, the second Name is 'BAAAAAAA', and so on.

(Unless the FASM Symbol search Algo, would have been modified since...).


Betov.
Post 16 Sep 2003, 07:59
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7178
Location: Kraków, Poland
No, with the current hashing algorithm fasm uses there is no much difference between those two naming systems (at least not as if I was using simple checksum, what I was doing in earlier versions).
Post 16 Sep 2003, 08:04
View user's profile Send private message Visit poster's website Reply with quote
Betov



Joined: 17 Jun 2003
Posts: 98
Nice. Wink I will have to do the same... Wink


Betov.
Post 16 Sep 2003, 08:29
View user's profile Send private message Visit poster's website Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1095
Location: Poland
heh, when working with string concentration routine I realised that MakeName has a little bug (one instruction is missing). It was working ok in my small testing program, but proably it could make some problems in a more complex app.
I have edited my post and corected this bug (added "inc ecx" in the end of the proc).
Post 16 Sep 2003, 15:55
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3494
Location: Bulgaria
Hi, decard.
It's fixed. Thanks.
Post 16 Sep 2003, 16:36
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Blag



Joined: 04 Jul 2003
Posts: 90
Location: Perú
Hi John Found:

I read the Fresh Team Conference post.....but as long as i not part of the team, i prefer to write my question here. Cool

Let me see if got your idea....coz if you english is poor....mine is worst......As long i can understand, you want to make something like Visual Basic, right??? Building the interface with FRESH, without the chance to modified it inside FRESH.....right??????
So you can build the interface visually but got to write code for the behavior......

Well......i think it's ok.....too much work to make it fully customizable.....and as you zed, you will need a decompiler in order to refresh the visual interface.........IMHO keep those things separate......

I would be great to use FRESH to build app's visually, but had the change to do it by code.....not modified the interface, but can build it from source code........i hope it's clear......after reading it again...i'm not sure Confused

Anyway......explain me what's the last route the FRESH team is going to take. Thanx Wink

_________________
Alvaro Tejada Galindo
SinglePath games design
http://www.iespana.es/singlepath
Post 16 Sep 2003, 21:04
View user's profile Send private message MSN Messenger Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3494
Location: Bulgaria
Hi, Blag.
At first, Feel free to post in whatever thread you wand Smile The conference is not some "secret meeting", everyone can write his question or to post some opinion or sugestion.

So, at the topic:
Quote:
As long i can understand, you want to make something like Visual Basic, right???

You are right, only not like VB but Delphi IMO. Smile

Quote:
Building the interface with FRESH, without the chance to modified it inside FRESH.....right?????? So you can build the interface visually but got to write code for the behavior......


Yes, the main idea to create standard things visualy and the user must write only the behaviour manualy. But the user must can write whole application manualy if he want this. Besides that, the user must have the ability to create DLL's, drivers, DOS programs, plain binary files, in general, all work that FASM can do. Visual tools are only for Win32 applications.

More, in the whole project there will be source level debugger too. Smile Do you think I am too greedy? Very Happy

Quote:
Anyway......explain me what's the last route the FRESH team is going to take.


I don't know just now. The conference is not finished yet. Smile

regards.
Post 16 Sep 2003, 21:36
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2019, Tomasz Grysztar.

Powered by rwasa.