flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Nikolay Petrov 25 Oct 2004, 17:47
Code: include '%fasminc%/win32ax.inc' struc TEST x,y,color { .x dd x .y dd y .color dd color } macro COPY_TEST src,dst ;only for dword struct { push dword[src] dword[src+4] dword[src+8] pop dword[dst+8] dword[dst+4] dword[dst] } buffer rb 32 source_test TEST 34,45,500 dest_test TEST 0,0,0 .code start: COPY_TEST source_test,dest_test invoke wsprintf,buffer,'%d, %d, %d',\ [dest_test.x], [dest_test.y], [dest_test.color] invoke MessageBox,HWND_DESKTOP,buffer,"blah blah",MB_OK invoke ExitProcess,0 .end start for more struct elements - use that Code: macro COPY_TEST src,dst,nelements ;only for dword struct { repeat nelements push dword[src+4*%-4] pop dword[dst+4*%-4] end repeat } |
|||
![]() |
|
Mac2004 27 Oct 2004, 07:55
Thanx Nickolay for an example!
![]() regards, Mac2004 |
|||
![]() |
|
Klod 29 Oct 2004, 03:18
I have a similar question.
How could I load registers from a table of DWORDS for fast call with macros that have different number of elements, 1 to 6? table: dd 1, 10,4,6,0,100 dd 2,5,3,102,0,0 first call would load values 1,10,4,6,0,100 into regs eax,ebx,ecx,edx,esi,edi second call would load values 2,5,3,102 to regs eax,ebx,ecx,edx etc _________________ Do not Assume, it makes an ASS out of U and ME! |
|||
![]() |
|
Nikolay Petrov 08 Nov 2004, 06:46
You haven't a problem:
[table] = 1 [table+4] = 10 ... [table+28] = 2 .... |
|||
![]() |
|
Klod 09 Nov 2004, 02:54
What I try to do is this:
Table is a 2 dimensional table, consists of 24 bytes per record. First dword has first byte encoded with number of elements to move, 2nd byte is not used, next to bytes are arg 1,next 4 Bytes arg 2 etc. I’d like to the folowing (pseudo code): Macro funcl table{ Read first byte ;determine number of elements if element = 3 Move eax Word [table +2 ] ;arg 1 Move ebx Dword [table + 4] ;arg 2 Move ecx Dword [table + 8] ;arg 3 Call function End if } If elements were 6, registers edx,edi, esi would have to be used as well. Then I could use it like: funcl table+ offset Or funcl ptrThisElement etc The problem I have is I don’t know how to build the variable arg list for the macro call _________________ Do not Assume, it makes an ASS out of U and ME! |
|||
![]() |
|
Nikolay Petrov 11 Nov 2004, 07:17
Code: include '%fasminc%/win32ax.inc' my_count = 0 num_calls = 0 macro chg_regs table,[regs] { if ~ regs eq forward mov regs,dword[table+4*my_count] my_count=my_count+1 ; end if common num_calls = num_calls + 1 if num_calls = 2 my_count = 0 num_calls = 0 end if } buffer rb 64 table dd 1, 10,4,6,0,100 dd 2,5,3,102,0,0 .code start: ; first call chg_regs table,eax,ebx,ecx,edx,esi,edi invoke wsprintf,buffer,'eax=%d, ebx=%d, ecx=%d, edx=%d, esi=%d, edi=%d',\ eax,ebx,ecx,edx,esi,edi invoke MessageBox,HWND_DESKTOP,buffer,"first call chg_regs",MB_OK ;second call chg_regs table,eax,ebx,ecx,edx invoke wsprintf,buffer,'eax=%d, ebx=%d, ecx=%d, edx=%d',\ eax,ebx,ecx,edx invoke MessageBox,HWND_DESKTOP,buffer,"second call chg_regs",MB_OK ;third call chg_regs table,eax,ebx,ecx,edx,esi,edi invoke wsprintf,buffer,'eax=%d, ebx=%d, ecx=%d, edx=%d, esi=%d, edi=%d',\ eax,ebx,ecx,edx,esi,edi invoke MessageBox,HWND_DESKTOP,buffer,"third call chg_regs",MB_OK invoke ExitProcess,0 .end start |
|||
![]() |
|
Klod 16 Nov 2004, 03:09
Thanks for your help Nickolay:
This is not quite what I was looking for. I did this: macro funcl ptr { cnt db 1 local end mov ebx, dword[ptr+4] inc [cnt] cmp [ptr+0],cnt jpe end mov ecx, dword[ptr+8] inc [cnt] cmp [ptr+0],cnt jpe end mov edx, dword[ptr+12] inc [cnt] ; cmp [ptr+0],cnt ; jpe end ; mov edi, dword[ptr+16] inc [cnt] ; cmp [ptr+0],cnt ; jpe end ; mov esi, dword[ptr+20] end: mov ax, word [ptr+2] call int 40 } This is not very pretty however I found these macros on the Menuet thread: macro mcall a,b,c,d,e,f { ; mike.dld __mov eax,a __mov ebx,b __mov ecx,c __mov edx,d __mov esi,e __mov edi,f int 0x40 } macro __mov reg,a,b { ; mike.dld if (~a eq)&(b eq) mov reg,a end if } How could I build the arg list in a Macro to take advantage of these macros? Pseudo code: macro funcl ptr { argcnt word [ptr+2] ;count = 1 to 6 depending on function called arg1 dd [ptr+4] argn dd [ptr+n] …. Arglist[arg1,arg2…,argn] ;arglist varies 1 to 6 args depending on argcnt Mcall arglist } The move macro would have to be modified to accept memops. With tis stile of programming I hope to make function calls using arguments from tables or structures. funcl pointr funcl struc Could you help me with this? _________________ Do not Assume, it makes an ASS out of U and ME! |
|||
![]() |
|
Klod 18 Nov 2004, 02:44
I just red my post.
I have some typos: All those jpe instructions shoul read je macro __mov reg,a { if ~a eq mov reg,a end if } argcnt word [ptr+0] ;count = 1 to 6 depending on function called I typed it all out of memory after work, must have been very tiered ![]() _________________ Do not Assume, it makes an ASS out of U and ME! |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.