flat assembler
Message board for the users of flat assembler.
Index
> Main > How implement class in fasm? |
Author |
|
ProMiNick 20 Aug 2020, 20:12
Class & object in HLL are usualy fixed size structures most of its fields are pointers to arrays, other field are count of items of such arrays.
for ex. Code: Class: intflist dd pIntfList fields dd pFields parent dd pParent classname dd PCharClassName ... pIntfList dd intf1vtbl dd intf2vtbl dd intf3vtbl ... intf1vtbl dd GetRekt,Spawn ... pFields dd a,b |
|||
20 Aug 2020, 20:12 |
|
Roman 21 Aug 2020, 04:46
Quote:
Its pointer to struct ? And why need in pIntfList intf2vtbl and intf3vtbl ? |
|||
21 Aug 2020, 04:46 |
|
Roman 21 Aug 2020, 05:11
And about inheritance one class from another.
I think new class(let say B) get from old (let say A) this: Vtbl dd pFuns ;i think c++ create interface for pFuns offset. a dd 0 ;struc class A b dd 0 pFuns dd GetRekt,Spawn And apply new functions in pFuns and put new values in struct A |
|||
21 Aug 2020, 05:11 |
|
revolution 21 Aug 2020, 05:16
If you are interfacing to HLL classes then check your compilers documentation for how it implements classes. Not all compilers generate the same format.
|
|||
21 Aug 2020, 05:16 |
|
Roman 21 Aug 2020, 05:27
Main question how class will simplify and where can't do without class ?
implement class or not implement class ? Be or not to be ?! |
|||
21 Aug 2020, 05:27 |
|
ProMiNick 21 Aug 2020, 07:29
Classes needed only in case thou want to HIDE something.
Interfaced proveded by OSes are not more complex actualy. But when thou wrap it all in classes thou became owner of sacred knowledge hidden from lazy ones. Lazy programmers mostly just use thour class only on level of understanding interface that thour class provided whithout searching deeper what class actualy does. Class is more friendly for documenting it or for understanding it by managers far from programming. But when thou make something for thour own (or for skilled programmer community) classes are absolutely useless. When thou port something from HLL to assembly thou could provide classes too (but it is wrong way. it usefull only for exploring porting process only, but for porting itself it absolutely uneffective). |
|||
21 Aug 2020, 07:29 |
|
Roman 21 Aug 2020, 08:27
I see few plus in class.
Auto initialization\release. Couple programers write diferent classes. Or you write class and using them. Or apply new functions. My class have two variants. Its macro and procs. Procs put in VTBL and macro might do call or do only asm code. Its more faster. Code: ;and new macro easy implement in not class field ! Class zi macro zi.GetLen { mov eax,[zi.len] } Class zi macro zi.GetLen2 b { mov eax,[zi.len] Call b } Or do more complex call: Code: mov eax,[zi.VTBL] push zi call [eax+interface.GetLen] |
|||
21 Aug 2020, 08:27 |
|
ProMiNick 21 Aug 2020, 09:13
macros hides from programmer nature of operations.
I would prefer to read code Code: mov eax,[zi.len] ; I could see zi is structure, len its field against to read less intuitive Code: zi.GetLen ; but when I see this I have to find where macro that defined that, that macro could be nested in another macro, so answer could be not so trivial reading is suffer. preprocessor resources are suffer. advantage? auto initialization\release - thou could provide these in includes & manualy use them no needance in building wrapper around of it all. In assembly more significant how exactly some value passed to class - via instruction or via procedure to see what exactly there happend. Class wrapping hide this difference, and hides many other significant things. |
|||
21 Aug 2020, 09:13 |
|
Roman 21 Aug 2020, 09:34
Quote:
Its for simple example. In real i put in macro many asm commands. Not comfortable all time write hands 20 asm commands in many places of code. And programer implement and change macro and all changed in code. Its big plus. If program very small, i agree no needed class. But if write compiler like Fasmw(160 kilobytes), class\macros could be very helpful. |
|||
21 Aug 2020, 09:34 |
|
DimonSoft 21 Aug 2020, 10:04
Roman wrote: I read about calss c++ that: Note that there’s no need to put non-virtual methods into VTable. |
|||
21 Aug 2020, 10:04 |
|
Roman 21 Aug 2020, 10:30
Last edited by Roman on 21 Aug 2020, 18:47; edited 2 times in total |
|||
21 Aug 2020, 10:30 |
|
ProMiNick 21 Aug 2020, 12:52
Роман, отсылка к классам Си++ лишняя.
То что у тебя реализоване - если тебе удобно, то почему бы и нет. Куски которые лично удобно в макросы - всегда удобно. Я же предпочитаю общие решения, поэтому мне классы не нравятся. П.С. на видео комменты в руглише, фасм позволяет комментить на русском, ну а если на английском, то не английскими буквами же русские слова писать, по английски и комментировать. А если классы на фасме интересуют посмотри фреш ИДЕ. |
|||
21 Aug 2020, 12:52 |
|
Roman 21 Aug 2020, 13:28
Да класс иногда нужен когда пишешь редакторы для 3д игр.
И класс для 3д игр тоже облегчает жизнь. Честно говоря пока не знаю насколько будет полезен и нужен в Fasm++ класс. Quote: А если классы на фасме интересуют посмотри фреш ИДЕ. Не знал что в фреш ИДЕ есть классы. А есть ли примеры классов или видео , как они сделаны в Fresh IDE ? |
|||
21 Aug 2020, 13:28 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.