flat assembler
Message board for the users of flat assembler.

Index > Heap > WTF

Goto page Previous  1, 2, 3  Next
Author
Thread Post new topic Reply to topic
Enko



Joined: 03 Apr 2007
Posts: 678
Location: Mar del Plata
Enko
typedef.... you got his example wrong.

Where do you see
X = api.Call?


its still somehow assembly with many macros.

lea esi, loc.rect1
mov eax, "... this code is weird !.."


If I get it right, the example should look like
Code:
api.GetModuleHandle(api.LoadLibrary("my_DLL.dll")),"my_fucntion")) 
api.addCustom(eax)
api.callCustom(eax,param1,param2)
    

its not very diferent of using win32ax.inc

Code:
invoke GetModuleHandle, <invoke LoadLibrary, "my_DLL.dll>, "my_function"
invoke addCustom, eax
invoke callCustom, eax, [param1], [param2]
    


Last edited by Enko on 11 Aug 2011, 19:53; edited 1 time in total
Post 11 Aug 2011, 19:44
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
ok. So I am using ASM++, and I want my code to be 4 byte aligned but I have a string somewhere that is 14 bytes + 1 terminating byte making it 15 bytes. Is your compiler going to add 1 byte to make my code even as to comply with my alignment?
Post 11 Aug 2011, 19:49
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
Enko wrote:

Where do you see
X = api.Call?


I thought OOP...? Sad Shocked
Post 11 Aug 2011, 19:53
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
Enko wrote:
typedef.... you got his example wrong.

Where do you see
X = api.Call?


its still somehow assembly with many macros.

lea esi, loc.rect1
mov eax, "... this code is weird !.."


If I get it right, the example should look like
Code:
api.GetModuleHandle(api.LoadLibrary("my_DLL.dll")),"my_fucntion")) 
api.addCustom(eax)
api.callCustom(eax,param1,param2)
    

its not very diferent of using win32ax.inc

Code:
invoke GetModuleHandle, <invoke LoadLibrary, "my_DLL.dll>, "my_function"
invoke addCustom, eax
invoke callCustom, eax, [param1], [param2]
    

so can you make a parser to do that?
Post 11 Aug 2011, 19:55
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
i don't see the point if you can just use call instead of using the latter
Post 11 Aug 2011, 20:04
View user's profile Send private message Reply with quote
Enko



Joined: 03 Apr 2007
Posts: 678
Location: Mar del Plata
Enko
As I see by his code, asmguru already have the macros.


Code:
invoke GetModuleHandle, <invoke LoadLibrary, "my_DLL.dll">, "my_function" 
invoke addCustom, eax 
invoke callCustom, eax, [param1], [param2] 
    

win32ax.inc support nested calls. use "<>" and the function is called and the result is pushed to the stack.
Code:
 cinvoke printf, szInt, <stdcall myproc, 2, <stdcall myproc,3, 3>>
    



and what I ment befor, is the '=', in asm is used MOV, and in his example, asmguru use lea and mov. not '='
Post 11 Aug 2011, 20:06
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
yeah, but I don't see the point if FASM is already capable of doing that.
Post 11 Aug 2011, 20:36
View user's profile Send private message Reply with quote
addes3



Joined: 09 May 2011
Posts: 29
addes3
^ Agreed.
Post 12 Aug 2011, 00:07
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1409
Location: Toronto, Canada
AsmGuru62
No complex stuff like that. It is not going to be another C.
Not intimidated at all - I am writing the tool for myself, but I'll upload it when it's done.

Here is what will happen:
Code:
[eax]=api.GetLastError()
    

will become (by simple replacement - no complex stuff):
Code:
[eax]=invoke GetLastError
    

and when FASM gets to assemble the generated source - you'll get an error.
Post 12 Aug 2011, 00:45
View user's profile Send private message Send e-mail Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1409
Location: Toronto, Canada
AsmGuru62
The main point of this is not how lines of code are generated. In fact, you can write native FASM code on every line if you want. Main point is that you can have a base object with virtual table and derived object with its own virtual table, so you can call virtual methods.

In pure FASM - you'll have to create all of that manually - the structures, the virtual tables, put the method pointers into tables, etc. Now, you need to add a virtual method: you need to modify a few files and not make a mistake. IDE automates all that, because all that is generated before FASM runs through it.

Here is how I envision that:

1. You want to create a new class. The list of available classes opens and you select one. Give a name to the new class and click 'Next'.

2. List of possible overrides opens - ones that are possible from ALL base classes if the object is derived a few times. Select few and click 'Next'.

...

3. Select some objects to be CONTAINED in a new one. The IDE adds these as data fields into new class.

Click 'Generate code'.
Done.

All you need to do is warp to the prepared places, like:
Code:
method MyClass::Method1 ()
{
... your code here ...
}
    

and write code lines. Native lines or "improved" lines, like in my example, whatever.

And the beauty of it - new class can be placed into class library and can be re-used - you can create new classes from it or put it as fields into other classes.
Post 12 Aug 2011, 01:05
View user's profile Send private message Send e-mail Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
AsmGuru62 wrote:

Code:
method MyClass::Method1 ()
{
... your code here ...
}
    



Dude Rolling Eyes Question .
By having a class / or a V-Table in memory, you have reached the High Level Language mark, Ok ? That is a waste of time dude. Evil or Very Mad

What is the purpose of having a v-table in assembly when you already have access to every little fucking bit and byte in your space ?

Question Question Question Question Question Evil or Very Mad Twisted Evil Evil or Very Mad Mad


Proud member of the ASM++ Rolling Eyes
Post 12 Aug 2011, 02:48
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
Maybe you should re-invent Visual Basic.
Make it Visual Basic-- (-- for low level capability)
Post 12 Aug 2011, 02:52
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1409
Location: Toronto, Canada
AsmGuru62
Think large projects, guys. In pure ASM it is impossible. You need a code re-use and there is no code re-use in ASM right now. btw, anyone really knows how V-tables are done? There is no High Level stuff there - just pointers, statically placed into data section. Why V-tables scare everyone? Why is it a waste of time? You mean waste of CPU cycles?
Post 12 Aug 2011, 12:54
View user's profile Send private message Send e-mail Reply with quote
Enko



Joined: 03 Apr 2007
Posts: 678
Location: Mar del Plata
Enko
AsmGuru62 wrote:
, anyone really knows how V-tables are done?

vid in his homepage has an oop/asm article.

I don't think that a virtual table is a high level language mark.

C, Basic, Javascript, PHP etc... are HLL but they don't have VTables.

THE OOP is just a paradigm, its possible to implement manually in assembly if you wanted.
Post 12 Aug 2011, 13:55
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1409
Location: Toronto, Canada
AsmGuru62
It is possible to do manually, but easier to use tools.
I'll go visit vid's page now.

Smile
Post 12 Aug 2011, 14:01
View user's profile Send private message Send e-mail Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
does Vtables look like flist?

if yes then:
fool.zip/fool/flist.inc wrote:

Code:
include 'macros.inc'
align 4
graphix = 1
f:
;-null----------------------;
.null      dd   0          ,0
;-a-------------------------;
.anim      dd   anim       ,1
.asm       dd   asm        ,0
.ascii     dd   ascii      ,0
.ata       dd   ata        ,0
;-b-------------------------;
.bip       dd   bip        ,1
.bits      dd   bits       ,1
.bmp       dd   bmp        ,1
.border    dd   border     ,1
.box       dd   box        ,1
.boxs      dd   boxs       ,1
.but       dd   but        ,1
.buts      dd   buts       ,1
;-c-------------------------;
.chgptr    dd   chgptr     ,0
.circle    dd   circle     ,1
.crypt     dd   crypt      ,0
.cursor    dd   cursor     ,1
.cmos      dd   cmos       ,0
;-d-------------------------;
.date      dd   date       ,0
.dir       dd   dir        ,0
.disk      dd   disk       ,0
.dnode     dd   node       ,0
;-e-------------------------;
;-f-------------------------;
.fad       dd   fad        ,1
.findstr   dd   findstr    ,0
.fptr      dd   0          ,0
.frame     dd   frame      ,1
.fxdec     dd   fixeddecimal,0
;-g-------------------------;
.get       dd   get        ,0
.ginit     dd   ginit      ,0
.gnode     dd   gnode      ,1
.grab      dd   grab       ,1
;-h-------------------------;
.hexa      dd   hexa       ,0
.hit       dd   hit        ,0
.htm       dd   htm        ,1
.html      dd   xhtml      ,0
;-i-------------------------;
.init      dd   init       ,0
.input     dd   input      ,0
.int33     dd   int33      ,1
;-j-------------------------;
;-k-------------------------;
;-l-------------------------;
.limb      dd   limb       ,0
.limd      dd   limd       ,0
.limw      dd   limw       ,0
.line      dd   line       ,1
;-m-------------------------;
.mouse     dd   mous       ,1
;-n-------------------------;
.node      dd   node       ,0
.numbin    dd   num.bin    ,0
.numhex    dd   num.hex    ,0
;-o-------------------------;
.otk       dd   kb.otk     ,0
;-p-------------------------;
.pad       dd   pad        ,1
.palette   dd   palette    ,0
.parse     dd   parse      ,0
.path      dd   0,0;path       ,0
.plotb     dd   plotb      ,1
.plotc     dd   plotc      ,1
.plotd     dd   plotd      ,1
.plotw     dd   plotw      ,1
.put       dd   put        ,1
.pong      dd   pong       ,0
.push      dd   puch       ,1
.pix       dd   pix        ,1
;-q-------------------------;
;-r-------------------------;
.refresh   dd   refresh    ,0
.rnd       dd   rnd        ,0
.rndinit   dd   rndinit    ,0
.read      dd   DOSread    ,0
;-s-------------------------;
.scope     dd   scope      ,1
.snode     dd   snode      ,1
;-t-------------------------;
.task      dd   task       ,1
.tex       dd   tex        ,1
.time      dd   time       ,0
.timer     dd   timer      ,0
.tmk       dd   kb.tmk     ,0
.txt       dd   txt        ,1
;-u-------------------------;
;-v-------------------------;
.vga       dd   vga13      ,0
.vread     dd   vdisk.read ,0
.vtxt      dd   vtxt       ,1
.vwrite    dd   vdisk.write,0
;-w-------------------------;
.write     dd   DOSwrite   ,0
;-x-------------------------;
.xhtml     dd   xhtml      ,0
.xorx      dd   xorx       ,0
;-y-------------------------;
;-z-------------------------;
.znode     dd   znode      ,1
.zone      dd   zone       ,1
;-0-------------------------;
;-1-------------------------;
;-2-------------------------;
;-3-------------------------;
;-4-------------------------;
;-5-------------------------;
;-6-------------------------;
;-7-------------------------;
;-8-------------------------;
;-9-------------------------;

    

code reuse is not a problem, the problem is dynamic linking to the Vtable (or flist)
Code:
mov eax,[object.func_id]
call [flist+eax]
    



else, don't read this post

end if
Post 12 Aug 2011, 14:02
View user's profile Send private message Visit poster's website Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1409
Location: Toronto, Canada
AsmGuru62
vid has a great article on OOP. I am impressed!
I also have one here:

http://www.codexxi.com/Oop.html

It was written very long ago and some of my ideas may be different now, but basics are the same.
Post 12 Aug 2011, 14:19
View user's profile Send private message Send e-mail Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
??
Do whatever you want to do man. I'm not stopping you Very Happy
Post 12 Aug 2011, 18:14
View user's profile Send private message Reply with quote
Enko



Joined: 03 Apr 2007
Posts: 678
Location: Mar del Plata
Enko
It took me 10 minuts to find the vids homepage again, he links to fasmlib, and in the fasmlib... the link to x86asm.net is too small.
http://x86asm.net/articles/oop-from-low-level-perspective/index.html
Post 12 Aug 2011, 23:25
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
Not so great, really. Today I probably wouldn't even publish it because some parts might give some misconceptions (the "type", it had its rationale at the time, but not obvious in current version of article).
Post 12 Aug 2011, 23:35
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3  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 can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.