flat assembler
Message board for the users of flat assembler.
![]() Goto page Previous 1, 2, 3 Next |
Author |
|
m3ntal 22 May 2014, 13:55
Note: Syntaxes like this can be automated:
Code: create TDog mov [Dog1], eax Code: create [Dog1]=new TDog ; in create macro (where p=[]) match [m]== =new type, p { create type mov [m], eax } Code: create John=new User 'John' destroy fresh.lib |
|||
![]() |
|
revolution 22 May 2014, 14:07
m3ntal wrote: Note: Syntaxes like this can be automated: The problem with custom macros is the documentation. They might, or might not, do weird things with memory and/or registers that is hidden from view. Will macro XYZ corrupt eax or edx or some memory below esp? It is already bad enough with lods, div and loop having hidden registers, and now we have to contend with macros on top of that. It took me many years just to get comfortable with stdcall, so you can imagine how hard it is to cope with create and exec, or that newfangled call. ![]() Last edited by revolution on 22 May 2014, 15:46; edited 1 time in total |
|||
![]() |
|
edfed 22 May 2014, 14:34
Code: DrawImage x,y,[content] i don't get why a esi reference is needed. |
|||
![]() |
|
JohnFound 22 May 2014, 14:58
revolution wrote: The problem with custom macros is the documentation. They might, or might not, do weird things with memory and/or registers that is hidden from view. Will macro XYZ corrupt eax or edx or some memory below esp? I am fully agree with you here. I always tried to keep the macros as non-intrusive and predictable, as possible. And to write some documentation of course. Sometimes... ![]() _________________ Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9 |
|||
![]() |
|
m3ntal 22 May 2014, 16:01
Quote: i don't get why a esi reference is needed Code: DrawImage esi, x, y call Image:Draw, x, y int DrawImage(Image *this, int x, int y); Quote: It took me many years just to get comfortable with stdcall |
|||
![]() |
|
typedef 22 May 2014, 16:15
m3ntal wrote:
hahahah |
|||
![]() |
|
revolution 22 May 2014, 16:23
m3ntal wrote: I thought the new call would make DOS programmers feel more comfortable about the transition to Windows. m3ntal wrote: It was never a good idea to RE-specify conventions: stdcall/invoke/cinvoke/ccall/pinvoke/pcall/etc. |
|||
![]() |
|
m3ntal 22 May 2014, 16:26
LOL. Check out this C code:
Code: USER *john=NULL; TRASH *fresh_lib=USELESS; for (;;) { recommend_to_dummies(fresh_lib); } |
|||
![]() |
|
m3ntal 22 May 2014, 16:46
Quote: It is never a good idea to override native CPU instructions |
|||
![]() |
|
revolution 22 May 2014, 16:54
I have never liked proc either. A lot is hidden inside proc also. But at least it isn't named the same as a native instruction.
|
|||
![]() |
|
r22 22 May 2014, 17:51
PRAJ - Push Return-address And Jump, would be a superior name for CALL.
1) Easier to type 2) Means what it does 3) Can be shortened to PRJ and still retain meaning 4) Can alias with RPJ and RPAJ for when you're too lazy to type correctly I win. |
|||
![]() |
|
revolution 23 May 2014, 01:13
No, it should be this:
Code: lea esp,[esp-4] | mov [esp],eip | lea eip,[eip+offset] |
|||
![]() |
|
JohnFound 23 May 2014, 04:50
Please, on topic. Some test cases and possible problems in the discussed library are welcome.
|
|||
![]() |
|
JohnFound 28 May 2014, 13:38
After several days of work, I managed to write short reference manual of the OOP macro library. Please, read it and comment:
Code: # Object oriented programming with FreshLib ## Objects definition The objects are defined using macro pair "object" and "endobj". The syntax of these macros is following: object OBJ_NAME [, PARENT_NAME] ; here object members are to be defined. endobj The object can contain three types of members: * Fields. They are simply some local labels with data definition, very similar to the structure fields. The fields are defined the same way as the structure fields: object TAnimal .length dd ? .height dd ? .weight dd ? endobj The fields are aimed to provide storage of private for the object data. Of course, it is assembly language and the fields are not hidden from the user, but a good practice is to not use them as an interface. (There are other members that are to be used as an interface). * Methods. The methods are procedures that provide an object engine - the code that to be executed on the object data. They are defined following way: object TAnimal .length dd ? .height dd ? .weight dd ? method .Jump, .height endobj Here we defined a method TAnimal.Jump that will make our animal to jump. _________________ Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9 |
|||
![]() |
|
revolution 28 May 2014, 14:00
Can you remove the requirement for "begin". This was long ago removed from fasm's "proc" macro and replaced by "local" and "locals".
Which raises this suggestion: Show an example of using local variables in method bodies. |
|||
![]() |
|
JohnFound 28 May 2014, 14:20
revolution wrote: Can you remove the requirement for "begin". This was long ago removed from fasm's "proc" macro and replaced by "local" and "locals". The syntax with "begin" is needed, because FreshLib uses slightly different structure of the local variables frame. This structure is impossible to be made without "begin" macro. Or at least it is syntactically better. (FASM macros can't create such type of local variables). Read more in the FreshLib reference manual. In addition, the macro syntax used in FASM library, because of too heavy use of preprocessor symbols is not able to support some advanced features of Fresh IDE - for example code completion and cross reference functions. There is nothing special in the local variables handling. Here is an example of local variables and arguments use in the method implementation. (and also, parameter set): Code: method MyObj.SetTop, .arg1 .rect RECT begin mov eax, [.arg1] mov [.rect.top], eax set [.self], MyObj:Top, eax return endp _________________ Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9 |
|||
![]() |
|
revolution 28 May 2014, 14:46
I think "impossible" is too strong a word here. For example you could simply make a macro (called localc or clocals or something) instead of begin:
Code: proc ... xor eax,eax clocals common_var1 dd ? endl mov ecx,[common_var1] clocals common_var2 dd ? endl mov edx,[common_var2] ;... |
|||
![]() |
|
JohnFound 28 May 2014, 15:02
revolution wrote: I think "impossible" is too strong a word here. For example you could simply make a macro (called localc or clocals or something) instead of begin: I wrote also "Or at least it is syntactically better". Or you can argue, that two macros is better than one? Quote: BTW: omission of the leading dot in local variable names is also something that is visually more appealing. No, it is not. Omission of the leading dot will make the local variables look the same way as global and this way will lower the code legibility. _________________ Tox ID: 48C0321ADDB2FE5F644BB5E3D58B0D58C35E5BCBC81D7CD333633FEDF1047914A534256478D9 |
|||
![]() |
|
revolution 28 May 2014, 15:07
"begin" only allows the common variables to be declared in one place. Whereas something like clocals/endl allows definitions in any, and multiple, places (or all at the top if so desired).
Do your macros allow for names without the dot, and give the user the choice to use them or not? If you force it then I'd suggest to make to more flexible for the user. |
|||
![]() |
|
Goto page Previous 1, 2, 3 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.