flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
scientica 27 Sep 2003, 13:26
Code: Ok, here is my draft, and attempt to explain it. I've given the source doc extracter the work name "harsyra" (Oxalis Acetosella, an eatable herb), i've got some idea of a name for it but there is time for naming later. Examples: Code: ;<<****************************************************** ; Name: FASM dynamic string library. ; Description: ; (c)2003 John Found ; ; You can use and modify this library, as long as modifyed ; versions are clearly marked (author of the modification ; and what is changed), copyright notice is not ; removed and the library remains free. ; Copyright for the library concept and parts written by ; me, remains to me, John Found ; Copyright for the modifyed/new parts remains to their ; authors. ;>>****************************************************** ; Versions: ; dd.mm.yyyy version author of modification ; - description ;-------------------------------------------------------- ; 09.07.2003 v1.0 John Found ; - the first public version. ; 15.07.2003 v1.0.1 John Found ; - minor bug with string table expand. Look in NewStr ; ;******************************************************** ;--< How to use it >----------------------------------------------------------------- ; 1. Include "strutils.inc" somewhere in the begining of main file. ; 2. Define structure "StrTable" of type "TStrTable" somewhere in data section. ; 3. Before using of library functions, call "InitStrings" ; 4. After last use of the library (probably on close of application), ; call "FreeStrings" to free all used memory. ; 5. Some functions are with register parameter passing, other with "stdcall" ; parameter passing. Read the header descriptions of the functions. ;------------------------------------------------------------------------------------ ; < Library functions > ;<<********************************************************************************** ; Name: InitStrings ; Description: Allocates memory for string table and allocates memory for strings. ; Start it before any work with strings. ; Arguments: Nothing. ; Returns: 0 if failed to allocate needed memory. ;>>********************************************************************************** ;<<************************************************************************************ ; Name: StrPtr ; Descripton: Returns the pointer in memory of the str handle eax ; Arguments: ; eax: handle or pointer of the string. ; Returns: ; eax: pointer to the string buffer or NULL if error ;>>************************************************************************************ ;>>************************************************************************ ; Name: DelStr ; Description: Deletes the string if it is possible. ; Argumets: ; eax: handle or pointer of the string created using NewStr. ; Returns: ; Nothing. ;<<************************************************************************ ;<<***************************************************************************** ; Name: GetControlText ; Description: ; Get the text of the [Control] using WM_GETTEXT and put it to the string with ; handle (only) in [string]. ; ; if [string] = NULL creates new string and returns the handle. ; if [string] <> NULL just copyes the text. ; Arguments: ; Control - control to aquire text from ; string - se description field for more info. ; Returns: Nothing. ;>>***************************************************************************** Note: "Nothing." to show it's usage. ;<<********************************************************** ; Name: SetString ; Description: Creates string and assigns it to variable. If variable ; already contains string handle, the old string will be ; deleted. ; Arguments: ; ptrHString - pointer to variable containing string handle. ; ptrSource - pointer to the source for string. ;>>********************************************************** IMO it's better to write the [ptrHString] as above. ;<<******************************************************************************** ; Name: NumToStr ; Description: NumToStr converts the number in eax to the string in any radix approx. [2..26] ; There is no parameter check, so be careful. ; Arguments: ; edi: pointer to the string buffer ; ecx: radix ; eax: number to convert. ; Returns: ? ;>>******************************************************************************** Something like this is one possible output: (I haven't decied what ouput formats to support yet). Code: Name: FASM dynamic string library. Description: (c)2003 John Found You can use and modify this library, as long as modifyed versions are clearly marked (author of the modification and what is changed), copyright notice is not removed and the library remains free. Copyright for the library concept and parts written by me, remains to me, John Found Copyright for the modifyed/new parts remains to their authors. ---------------------------------------------------------------------------------- Name: InitStrings Description: Allocates memory for string table and allocates memory for strings. Start it before any work with strings. Arguments: Nothing. Returns: 0 if failed to allocate needed memory. ---------------------------------------------------------------------------------- Name: StrPtr Descripton: Returns the pointer in memory of the str handle eax Arguments: eax: handle or pointer of the string. Returns: eax: pointer to the string buffer or NULL if error ---------------------------------------------------------------------------------- Name: DelStr Description: Deletes the string if it is possible. Argumets: eax: handle or pointer of the string created using NewStr. Returns: Nothing. ---------------------------------------------------------------------------------- Name: GetControlText Description: Get the text of the [Control] using WM_GETTEXT and put it to the string with handle (only) in [string]. if [string] = NULL creates new string and returns the handle. if [string] <> NULL just copyes the text. Arguments: Control - control to aquire text from string - se description field for more info. ---------------------------------------------------------------------------------- Name: SetString Description: Creates string and assigns it to variable. If variable already contains string handle, the old string will be deleted. Arguments: ptrHString - pointer to variable containing string handle. ptrSource - pointer to the source for string. ---------------------------------------------------------------------------------- Name: NumToStr Description: NumToStr converts the number in eax to the string in any radix approx. [2..26] There is no parameter check, so be careful. Arguments: edi: pointer to the string buffer ecx: radix eax: number to convert. Returns: ? ----------------------------------------------------------------------------------
_________________ ... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself. - Bradley Kuhn |
|||||||||||
![]() |
|
scientica 27 Sep 2003, 14:09
JohnFound wrote: HI scientica: 1. Ok, I just thought that it might be gpood to differ registers from stack passed argumens. Ok, then the rule for arguments is: the first word after the ";" which is 'ended' with a ":" is a new argument, if the frirst word is not ended with a ":" then it's the continuation of the description of the previous argument. Ok, if no name filed is found then the comment block considered to be a description field that doesn't start with "Description: ". 2. That is one possible output, and then have the option in that app to export it to, for intance html code. Harsyra could be used as an doc writer for other projects too (possibly created with Fresh), kinda like javadoc, but more power full ![]() Currently I'm working on the file read and parser code, using a console for output (I'm thining of creatng a structure with pointers to dynamic strings - using strlib for the string work.). Depending on how fast/slow the parser becomes it might be possible to have it process the files in real time. _________________ ... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself. - Bradley Kuhn |
|||
![]() |
|
JohnFound 27 Sep 2003, 14:15
Absolutely agree.
![]() Keep good work. Regards. |
|||
![]() |
|
scientica 05 Oct 2003, 21:04
Ok, here is the current workcopy of harysyra. It's uggly because:
So why am I posting this if it's so bad? Well, first I'd like to know if it runs/&compiles onther computers than mine (I've had problems with apps only starting on mine PC, but not others). And then some comments on the debug code might be use full, so I know if it's worth making nicer/better or if it's a one app only debug code. I've attached these files: harsyra.exe - build with out debug code harsyra_debug.exe - build with debug code Test.asm - the test file which harsyra read input from. The rest of the files are just overbloated sources. ![]() How to compile without debug code: replace line 7 in Harsyra.asm with: Code: debug_mode equ 0 How to compile with debug code: replace line 7 in Harsyra.asm with: Code: debug_mode equ 1 If you compile it, look at the sizes and time, there should be some difference between w/ and w/o debug code. The exe's are console mode apps, so run tehm from a terminal/dos/cmd window, or else you'll probably just see something flicker. [EDIT]-- attachment removed --[/EDIT] _________________ ... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself. - Bradley Kuhn Last edited by scientica on 06 Oct 2003, 16:06; edited 1 time in total |
|||
![]() |
|
decard 06 Oct 2003, 15:31
I tried it, and it works just fine on my computer.
btw, do you "grab" the harsyra's output to some file? How? There's too much output and it scrolls too fast ![]() regards, decard |
|||
![]() |
|
scientica 06 Oct 2003, 15:57
Good.
![]() Redirrecting stdout and/or/xor stderr don't work for you either? (thought it was someting with my windows). Could it because I'm using WriteConsole rather than WriteFile (I'll check the API ref. and see if there is some note, and try replace one WriteConsole with WriteFile) I've tried: harsyra > outputfile harsyra | gvim - but neither works. _________________ ... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself. - Bradley Kuhn |
|||
![]() |
|
scientica 06 Oct 2003, 16:00
Aha, it's my fault, I'll switch to WriteFile instead, next time I'll read the entire remark...
Quote: Remarks [EDIT]Here is the WriteFile version uppdate (same files as above (was) but with WriteFile instead of WriteConsole)[/EDIT]
_________________ ... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself. - Bradley Kuhn |
|||||||||||
![]() |
|
decard 06 Oct 2003, 16:14
Thanks, now it works OK
![]() |
|||
![]() |
|
scientica 06 Oct 2003, 17:15
Hehe, currently you can type what ever after harsyra[.exe], it'll be ignored (currently test.asm is hard coded).
Code: Here is some lines that might be use full: (I currently use stderr as "debugout".) harsyra 1> std.out harsyra > std.out writes stdout to std.out. harsyra 2> err.out writes stderr to err.out. harsyra 1> std.out 2> err.out writes stdout to std.out and stderr to err.out. harsyra | gvim - sends stdout to gvim (which reads input from stdout, it's the "-" switch's work) _________________ ... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself. - Bradley Kuhn |
|||
![]() |
|
decard 06 Oct 2003, 19:11
Quote: Hehe, currently you can type what ever after harsyra[.exe], it'll be ignored (currently test.asm is hard coded). heheheh ![]() ![]() ![]() ![]() I was supposed to check if it works ok, not to look into the sources... and passing input filename as a parameter is simply a habbit ![]() btw, I didn't know that you can redirect also stderr. That's why I sometimes needed redir.exe. It is no more ![]() |
|||
![]() |
|
scientica 06 Oct 2003, 21:01
decard wrote: btw, I didn't know that you can redirect also stderr. That's why I sometimes needed redir.exe. It is no more I didn't know that either until I stumbeled into a page conainting different redirections (as usual one can do more in *nix than in windows), unfortainly I lost the url. I only knew of > and |. _________________ ... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself. - Bradley Kuhn |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.