flat assembler
Message board for the users of flat assembler.
Index
> IDE Development > A problems for those want to help for developement of Fresh. Goto page 1, 2 Next |
Author |
|
Tomasz Grysztar 15 Sep 2003, 08:45
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. |
|||
15 Sep 2003, 08:45 |
|
JohnFound 15 Sep 2003, 09:01
Thanks Privalov.
Maybe we should make some wrapper function... BTW: What you think about [Problem 3]? Well, I know we talked about this before, but the problem is really complex for me. |
|||
15 Sep 2003, 09:01 |
|
Tomasz Grysztar 15 Sep 2003, 09:09
JohnFound wrote: BTW: What you think about [Problem 3]? Well, I know we talked about this before, but the problem is really complex for me. Probably because it is really complex. 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 |
|||
15 Sep 2003, 09:09 |
|
JohnFound 15 Sep 2003, 09:14
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? |
|||
15 Sep 2003, 09:14 |
|
Tomasz Grysztar 15 Sep 2003, 09:16
You have asked while I was editing my post to add the last sentence.
|
|||
15 Sep 2003, 09:16 |
|
JohnFound 15 Sep 2003, 09:24
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... |
|||
15 Sep 2003, 09:24 |
|
Tomasz Grysztar 15 Sep 2003, 09:36
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.
|
|||
15 Sep 2003, 09:36 |
|
decard 15 Sep 2003, 19:34
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 ). 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 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 |
|||
15 Sep 2003, 19:34 |
|
JohnFound 15 Sep 2003, 19:45
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. |
|||
15 Sep 2003, 19:45 |
|
decard 16 Sep 2003, 06:39
I have rewritten the proc to give the names with numbers but without leading zeros. Fortunatelly now it doesn't use any constants
btw: I should have look at all functions from the StrLib.asm 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 |
|||
16 Sep 2003, 06:39 |
|
JohnFound 16 Sep 2003, 06:53
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 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. I like good commented programs. Welcome in the team! BTW: Please, don't use this emoticon: "" I don't like it. Your can't evaluate whole project for one day. Just keep good work. You can continue with [Problem 2], if you like the string processing. regards. |
|||
16 Sep 2003, 06:53 |
|
decard 16 Sep 2003, 07:50
I'm glad to hear that
I started to work with functions that you mentioned in [Problem 2], and soon I will post here new version of StrLib. regards, decard |
|||
16 Sep 2003, 07:50 |
|
Betov 16 Sep 2003, 07:59
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. |
|||
16 Sep 2003, 07:59 |
|
Tomasz Grysztar 16 Sep 2003, 08:04
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).
|
|||
16 Sep 2003, 08:04 |
|
Betov 16 Sep 2003, 08:29
Nice. I will have to do the same...
Betov. |
|||
16 Sep 2003, 08:29 |
|
decard 16 Sep 2003, 15:55
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). |
|||
16 Sep 2003, 15:55 |
|
JohnFound 16 Sep 2003, 16:36
Hi, decard.
It's fixed. Thanks. |
|||
16 Sep 2003, 16:36 |
|
Blag 16 Sep 2003, 21:04
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. 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 Anyway......explain me what's the last route the FRESH team is going to take. Thanx |
|||
16 Sep 2003, 21:04 |
|
JohnFound 16 Sep 2003, 21:36
Hi, Blag.
At first, Feel free to post in whatever thread you wand 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. 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. Do you think I am too greedy? 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. regards. |
|||
16 Sep 2003, 21:36 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.