flat assembler
Message board for the users of flat assembler.
Index
> Main > Try for fasm standard library and standard macro library |
Function naming style | |||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||
Total Votes : 40 |
Author |
|
aaro 23 Feb 2004, 03:09
I have started making multi OS fasm libraries. Currently there's only few functions and they'r all for windows but i hope someone would write functions for linux and menuet also. I haven't tested the functions so please report errors.
I can't make it all by myself so i would be more than happy to get code from you guys(optimisations, menuet/linux versions, code for missing functions, etc..) In the macro library there's new version of proc/invoke macros. Usage: Code: proc name[, arg1, arg2, ...] [type frame/noframe, stdcall/cdecl] [uses reg1, reg2, ...] [var variable1] ; Works for frame and noframe types [.variable1 dd ?] ; This works only with frame type. begin return [val] endp [preserve reg1, reg2, ...] ; pushs and pops matching registers invoke name[, arg1, arg2, ...] ; You can invoke your own functions and api functions with or without parameters There's also macros that aren't written by me so if you find your macro there please say so so i can add your name there or if you don't want it to be there i will delete it.. I have one problem with the macro library: i have defined import macros in StdMacLib\Windows.inc and fasm is complaining: Code: .import %fasminc%\StdMacLib\windows.inc [9] .import [3]: library \ %fasminc%\StdMacLib\windows.inc [95] library [3]: if ~ name#.needed error: undefined symbol. So if at the moment you have to include '%fasminc%\macro\import.inc' before your import section.. Any ideas how to fix this? Simple example how to use these files: Code: format PE GUI 4.0 entry Start OS fix Windows ; Use windows version of StdMacLib and StdLib include '%fasminc%\stdmaclib.inc' .code proc foo uses edx begin mov edx, 100 return 2 endp Start: preserve edx ; proc uses edx so invoke will push and pop edx invoke foo invoke ExitProcess, 0 .udata ; Uninitialised data section NotUsed dd ? .idata ; Initialised data section NotUsed2 dd ? .cdata ; Constant data section NotUsedStr db 'foobar',0 include '%fasminc%\macro\import.inc' ; How to fix this?!? .import And what about the structure macros there's on this board somewhere, should we start using them? And witch version of import/export macros should we use? COMMENTS PLEASE! It's 5:30 so i'm going to sleep.. Good night! =) Tab size used to edit files below was equal to 2 spaces
Last edited by aaro on 23 Mar 2004, 19:17; edited 10 times in total |
|||||||||||
23 Feb 2004, 03:09 |
|
aaro 23 Feb 2004, 12:54
decard wrote: Hi Aaro, Thanks, and welcome to the team! Quote:
Yeah, it would be very nice Quote:
I will add console i/o soon, thx for that and keep 'em coming Quote:
This is what i have used: Code: udata MemLib.Var1 enddata proc MemCopy, pDest, pSource, Count But i like your style for functions too.. I think we need to have poll. Quote:
I'll add something like that. Quote:
Didn't have anything better to do.. Seriously, if i remember correctly fresh strlib is using string handles that i think is unnecessary, but if fresh team gives me approval of using some of their functions i'll check those out. |
|||
23 Feb 2004, 12:54 |
|
aaro 24 Feb 2004, 02:46
There's new version at the top, nothing big has changed. I just added copyright texts and names of those whose macros i have used in the macro library. And most importantly TODO file so if you want to help READ IT!
And seems like we'r going to stick to function naming allready used, but if you want to change it please vote! Voting will stop on next monday, then i'll change the poll to ask you for naming of library variables. I also changed .code macro in windows.inc to include StdLib.asm automaticly. Yeah, i know, i know.. There will be changes.log in the next release.. |
|||
24 Feb 2004, 02:46 |
|
decard 24 Feb 2004, 13:44
aaro wrote: Seriously, if i remember correctly fresh strlib is using string handles that i think is unnecessary, but if fresh team gives me approval of using some of their functions i'll check those out. I'm in the Fresh team and I'm maintaining StrLib Although Fresh StrLib uses string handles, its functions can work with string pointers as well. Actually you can just take this library and convert it that it would match your needs - just preserve the copytight note in the beggining of the source <-- that is the requirement of Fresh Artistic License regards |
|||
24 Feb 2004, 13:44 |
|
aaro 25 Feb 2004, 16:18
First release that should actually work..
Added: StdLibApi.txt __% and %__ fixes MemMove MemFill StrCat Fixed: proc macros Code: format PE GUI 4.0 OS fix Windows include '%fasminc%\stdmaclib.inc' .code Start: invoke StrCat, sHello, sWorld push eax invoke StrRight, eax, 4 push eax invoke MessageBox, 0, eax, eax, MB_OK call StrFree call StrFree invoke ExitProcess, 0 .cdata sWorld db 'World',0 sHello db 'Hello',0 include '%fasminc%\macro\import.inc' .end Start decard: Thanks for the info, but i don't think i want to convert the whole library.. What if i only take few functions from there what kind of text i should add then? Sorry i'm askind stupid guestions, but i'm connected thru gprs and it costs me 5,99€/MB so i'm not very willing to download anything.. Have 41€ bill allready and have used it just yesterday.. :´( Last edited by aaro on 26 Feb 2004, 13:58; edited 1 time in total |
|||
25 Feb 2004, 16:18 |
|
decard 25 Feb 2004, 16:37
well then just write which functions you took from our StrLib and write who is an author (authors) of this functions. If you don't wan't to download whole Fresh package, here's the StrLib:
regards |
|||
25 Feb 2004, 16:37 |
|
aaro 26 Feb 2004, 13:56
New version at the top:
Code: Added: StrCompCs StrCopy StrAlloc and StrFree (Linux and Menuet) .end macro (Windows.inc) FileSetPos (Windows) Changed: StrAlloc and StrFree (Windows) MemMove -> MemCopy Fixed: push and pop macros (Proc.inc) StrMid Updated: proc macro to align procedures (Proc.inc) StdLibApi.txt TODO.txt decard: Thanks i'll have a look |
|||
26 Feb 2004, 13:56 |
|
aaro 01 Mar 2004, 17:11
New version at the top:
Code: Added: pushd, pushw, pushf, pushfd, pusha, pushad, popd, popw, popf, popfd, popa and popad macros (Proc.inc) StrRepeat StrInsert StrDelMid StrReplaceAt ConInit, ConUninit, ConRead, ConWrite (Windows) Changed: pop macro to pop in same order that fasm does (Proc.inc) push and pop macros to check for argument size (Proc.inc) invoke and proc macros to use pushd and popd (Proc.inc) Updated: TODO.txt |
|||
01 Mar 2004, 17:11 |
|
Tommy 01 Mar 2004, 18:20
At first glance, very nice!
|
|||
01 Mar 2004, 18:20 |
|
aaro 02 Mar 2004, 17:57
Code: Added: StrToNum StrFromNum enumflags (StdMacLib.inc) stackcheck and endcheck (StdMacLib.inc) Changed: return and endp macros not to halt on push/pop miscount (Proc.inc) Here's little example that demostrates power of StrToNum and StrFromNum: Code: format PE GUI 4.0 OS fix Windows include '%fasminc%\stdmaclib.inc' .code Start: invoke StrToNum, sTestNum, 16 invoke StrFromNum, eax, 16, STR_UPPER+STR_SIGNED;+STR_PREFIX push eax invoke MessageBox, 0, eax, eax, MB_OK call StrFree invoke ExitProcess, 0 .idata sTestNum db '-0xFA09afh',0 include '%fasminc%\macro\import.inc' .end Start Tommy: Thank you |
|||
02 Mar 2004, 17:57 |
|
Kevin_Zheng 03 Mar 2004, 12:25
Hi, Aaro:
Please see the belowing link: http://board.flatassembler.net/topic.php?t=1151. http://board.flatassembler.net/topic.php?t=1054 I supported some of new macros (proc/call/stdcall/ccall/import/export/library). It can work on Win32/DOS platform and supported number ordinal APIs import/export. It maybe reference for you. |
|||
03 Mar 2004, 12:25 |
|
aaro 03 Mar 2004, 16:15
Code: Added: FileSetPos (Windows) FileGetPos (Windows) FileGetSize (Windows) FileGetTime (Windows) FileSetAttributes (Windows) FileGetAttributes (Windows) FileMove (Windows) Changed: FileDelete FileClose Updated: StdLibApi.txt TODO.txt Kevin_Zheng: Thanks, i'll have a look tomorrow when i get back home |
|||
03 Mar 2004, 16:15 |
|
aaro 11 Mar 2004, 14:30
Code: Added: ConFlush, ConSetPos, ConGetPos, ConSetColor, ConGetColor (Windows) LF equ 13, 10 (Windows.inc) Changed: FileOpen (Windows) FileSetAttributes -> FileSetAttribs FileGetAttributes -> FileGetAttribs var so now you can specify size of buffer allocated (Proc.inc) Removed: FileCreate (Windows) Updated: library, import and export macros with ones by Kevin_Zheng (Windows.inc) FileRead (Windows) FileSetPos (Windows) StdLipApi.txt TODO.txt There's now 51 functions in the library if i counted them right! Please give me more ideas for functions/libraries to add! And even more happy news: jInuQ send me pm that he and gorshing are joining the StdLib team. jInuQ said that he's willing to start converting functions for Linux so we can finally start using this lib on other OSes than Windows as well. Any Menuet coders out there willing to help? Kevin_Zheng: I changed import, export and library macros to your versions. But there's still this issue to deal with: Quote:
Would you have a look at this problem? |
|||
11 Mar 2004, 14:30 |
|
Kevin_Zheng 16 Mar 2004, 05:59
Hi, aaro:
Thank your work. Can you write a simple program for implementing your question? Please see the below link: http://board.flatassembler.net/topic.php?p=7896#7896 Please see the demo file ord_dll in the package, I have tested it ok. And it maybe help you. Thank you. |
|||
16 Mar 2004, 05:59 |
|
aaro 23 Mar 2004, 19:15
!!!!!!!!!! Combined StdMacLib with StdLib. Now to include this library you do it like this: "include '%fasminc%\StdLib.xxx.inc'" where xxx is OS you'r wanting code to be run(win,lnx,mnt) You can use "OUTPUT fix type" to change output file type. Types at the moment are: Windows: PE_GUI (default) PE_GUI_DLL PE_CONSOLE PE_CONSOLE_DLL Linux: ELF_EXECUTABLE (default) Added skeletons of all the libs for Linux and Menuet so if someone wants to start converting functions it should be somewhat easier now. !!!!!!!!!! Added: StrReverse .code, .idata, .udata, .cdata and .end macros for Linux and Menuet Changed: StrFromNum removed prefix option StrToFloat so now it converts numbers from any base and returns value in st0 LF -> %lf ALL_PROCS -> PROC_INCLUDE_ALL Global variables aren't included if not used (ConLib.win.asm, MemLib.win.asm, Debug.inc) Updated: StdLibApi.txt StrToNum ConInit to check if it needs to allocate console (Windows) Here's little example how to use it now on: Code: include '%fasminc%\stdlib.win.inc' .idata Tmp db 'FooBar',0 .udata hStr dd ? .code Start: invoke ConInit invoke StrReverse, Tmp mov [hStr], eax invoke ConWrite, eax, 0 invoke ConRead, Tmp, 7 invoke StrFree, [hStr] invoke ConUninit invoke ExitProcess, 0 .end Start Kevin_Zheng: Your macros are working now, i had to re-structure my whole package to get it working but it should be good now All: I'm planning to write StrFromFloat function and i'm thinking that it would be wisest to pass the floating point value in st0 so i don't have to write different versions of it for every float data type. What do you think? If you agree i'm going to extend my proc and invoke macros so it will be transparent to the coder calling the function(invoke will fld value automaticly).. I'm also going to add vararg type to procedures and pascal calling convention when i have enought time. It's quite possible that there's bugs in the package because of the re-structuring so please report if you find any. Thanks. |
|||
23 Mar 2004, 19:15 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.