flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
zjlcc 22 May 2004, 10:29
but can not make "overlay"
Code: format PE GUI 4.0 entry start include '%include%/WIN32A.INC' include 'dbg.INC' macro overlay basetype,name { _#basetype#.#name=1 } macro let basetype,name,[var] { if defined _#basetype#.#name if _#basetype#.#name=1 display 2h label name#_ _#basetype#.#name=0 else label name end if else label name end if common var } struc TPoint { .x dd 8 .y dd 9 } ;==================== macro _kk1{ label ._b_ .a dd 1 .t TPoint } struc kk1{ _kk1 } struct kk1 ;==================== macro _kk2{ _kk1 .b dd 2 } struc kk2{ _kk2 virtual at ._b_ .kk1 kk1 end virtual } struct kk2 ;==================== macro _kk3{ _kk2 .c dd 3 } struc kk3{ _kk3 virtual at ._b_ .kk2 kk2 end virtual } struct kk3 ;==================== start: xor eax,eax xor eax,eax mov eax,[m.a] ;1 mov eax,[m.b] ;2 mov eax,[m.kk1.a] ;1 mov eax,[m.kk1.t.x] ;8 mov eax,[m.t.y] ;9 nop mov eax,[o.a] ;1 mov eax,[o.b] ;2 mov eax,[o.c] ;3 mov eax,[o.kk2.b] ;2 mov eax,[o.kk2.kk1.a] ;1 nop mov eax,[p.a] ;1 mov eax,[p.b] ;2 mov eax,[p.c] ;3 mov eax,[p.kk2.b] ;2 mov eax,[p.kk2.kk1.a] ;1 ret m kk2 o kk3 p kk3 |
|||
![]() |
|
halyavin 21 Aug 2004, 05:06
What about this? It's my OOP macro library based on another idea.
I think you can easily extend it as you wish. Code: ;for internal macro use - we can't use # in embedded macros macro addlabel x,y { x#.#y: } macro struct name { virtual at 0 name name sizeof.#name = $ - name name equ sizeof.#name end virtual } macro fields parent,object,[fields,dir] { common macro object#_fields obj %_ parent#_fields obj _% forward macro object#_fields obj %_ object#_fields obj addlabel obj,fields dir _% common struc object %_ object#_fields _% struct object } macro tvm_define object,name { dd object#.#name } tvm_offset=0 macro tvm parent,object,[method] { common macro object#_tvm name ;return value in tvm_offset %_ parent#_tvm name _% macro object#_tvm_include name %_ parent#_tvm_include name _% forward display 'parameter used',13,10 parent#_tvm method if (tvm_offset < 0) display 'case 1',13,10 ;new method macro object#_tvm name %_ if (name eq method) object#_tvm .sizeof else object#_tvm name end if if (name eq .sizeof) object#_tvm .sizeof tvm_offset=tvm_offset+4 end if _% macro object#_tvm_include name %_ display 'add',13,10 object#_tvm_include name fixtable parent,object,name,method _% end if } macro fixtable parent,object,name,method { parent#_tvm method if (tvm_offset < 0) tvm_define object,method else display 'store used',13,10 store dword object#.#method at name#.tvm+tvm_offset end if } macro tobject_tvm name { if (name eq .sizeof) tvm_offset=0 else tvm_offset=-1 end if } macro tobject_tvm_include name { name#.tvm: } ;use include 'fix.inc' at the end of macro section %_ fix { _% fix } macro tobject_fields obj { obj#.self: rd 1 } fields tobject,my,x,dd 0x90909090 my_object my tvm tobject,my,add,sub my_tvm_include my my.add: nop ret my.sub: nop ret fields my,child my_child_object child tvm my,child,add,mul child_tvm_include child child.add: nop ret child.mul: nop ret Use hiew to see result. ![]() |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.