flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Macro parts. How do this? |
Author |
|
Roman 28 Sep 2024, 09:23
I do this variant. But not variant from first topic.
Code: macro mGet x,a,[p] { common rept 1 n:x \{ GetBufr equ GetBufr+n \} mov a,[GetBufr] forward match :,p \{ mov a,[a] display ':' \} match =+v,p \{ add a,v display '+' \} match =-v,p \{ sub a,v display '-' \} match ==>v,p \{ shr a,v display '>' \} match ==<v,p \{ shl a,v display '<' \} } ;in code GetBufr equ edx+16 mGet 0,eax,:,=>5,+-8,+16,-4,-edx,=<2 mGet 4,esi,+8 mGet 32,edi,+16 ;my question is how do this ? mGet2 0,eax,<=>5,+-8,+16,-4,-edx,=<2> ;I want separate part params for mGet2 macro mGet2 [x,a,part] {mGet x,a,[part] } Last edited by Roman on 28 Sep 2024, 09:38; edited 2 times in total |
|||
28 Sep 2024, 09:23 |
|
macomics 28 Sep 2024, 09:33
Code: format PE macro mGet [args] { common macro mGetArg base*,[arg] \{ \common mov base,[GetBufr] match any,GetBufr \\{ define GetBufr any+4 \\} \forward match =+ x, arg \\{ add base, x \\} match =~ x, arg \\{ shl base, x \\} \} if ~ args eq forward mGetArg args common end if purge mGetArgs } GetBufr equ myBuffData mGet <eax,+8>,<esi,+8, ~2>,edx myBuffData rd 4 Code: $ fasm test_mGet.asm flat assembler version 1.73.32 (16384 kilobytes memory, x64) 2 passes, 1024 bytes. $ hexdump -C test_mGet.exe 00000000 4d 5a 80 00 01 00 00 00 04 00 10 00 ff ff 00 00 |MZ..............| 00000010 40 01 00 00 00 00 00 00 40 00 00 00 00 00 00 00 |@.......@.......| 00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00000030 00 00 00 00 00 00 00 00 00 00 00 00 80 00 00 00 |................| 00000040 0e 1f ba 0e 00 b4 09 cd 21 b8 01 4c cd 21 54 68 |........!..L.!Th| 00000050 69 73 20 70 72 6f 67 72 61 6d 20 63 61 6e 6e 6f |is program canno| 00000060 74 20 62 65 20 72 75 6e 20 69 6e 20 44 4f 53 20 |t be run in DOS | 00000070 6d 6f 64 65 2e 0d 0a 24 00 00 00 00 00 00 00 00 |mode...$........| 00000080 50 45 00 00 4c 01 01 00 d2 cd f7 66 00 00 00 00 |PE..L......f....| 00000090 00 00 00 00 e0 00 0f 01 0b 01 01 49 00 02 00 00 |...........I....| 000000a0 00 02 00 00 00 00 00 00 00 10 00 00 00 10 00 00 |................| 000000b0 00 10 00 00 00 00 40 00 00 10 00 00 00 02 00 00 |......@.........| 000000c0 01 00 00 00 00 00 00 00 03 00 0a 00 00 00 00 00 |................| 000000d0 00 20 00 00 00 02 00 00 65 60 00 00 03 00 00 00 |. ......e`......| 000000e0 00 10 00 00 00 10 00 00 00 00 01 00 00 00 00 00 |................| 000000f0 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00 |................| 00000100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00000170 00 00 00 00 00 00 00 00 2e 66 6c 61 74 00 00 00 |.........flat...| 00000180 2a 00 00 00 00 10 00 00 00 02 00 00 00 02 00 00 |*...............| 00000190 00 00 00 00 00 00 00 00 00 00 00 00 60 00 00 e0 |............`...| 000001a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00000200 a1 1a 10 40 00 83 c0 08 8b 35 1e 10 40 00 83 c6 |...@.....5..@...| 00000210 08 c1 e6 02 8b 15 22 10 40 00 00 00 00 00 00 00 |......".@.......| 00000220 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * Code: $ objdump -M intel -D test_mGet.exe test_mGet.exe: формат файла pei-i386 Дизассемблирование раздела .flat: 00401000 <.flat>: 401000: a1 1a 10 40 00 mov eax,ds:0x40101a 401005: 83 c0 08 add eax,0x8 401008: 8b 35 1e 10 40 00 mov esi,DWORD PTR ds:0x40101e 40100e: 83 c6 08 add esi,0x8 401011: c1 e6 02 shl esi,0x2 401014: 8b 15 22 10 40 00 mov edx,DWORD PTR ds:0x401022 |
|||
28 Sep 2024, 09:33 |
|
Roman 28 Sep 2024, 09:41
Quote:
If i needed do shr reg,2 What should I do? |
|||
28 Sep 2024, 09:41 |
|
macomics 28 Sep 2024, 09:48
Roman wrote: If i needed do shr reg,2 e.g. Code: mGet <eax,+8>,<esi,+8, ~2>,edx ; mGet.arg1 = eax,+8 ; mGet.arg2 = esi,+8, ~2 ; mget.arg3 = edx Code: forward mGetArg args ; mGetArg.base = eax ; mGetArg.arg1 = +8 ; mGetArg.base = esi ; mGetArg.arg1 = +8 ; mGetArg.arg2 = ~2 ; mGetArg.base = edx ; mGetArg.arg = You need to use other symbols to indicate shifts so that preprocessor does not mistake them for errors. |
|||
28 Sep 2024, 09:48 |
|
Roman 28 Sep 2024, 09:54
Quote:
Did exist way to using () instead <> for preprocessor ? Or replace ~ to :~ this shl and ~: this shr |
|||
28 Sep 2024, 09:54 |
|
macomics 28 Sep 2024, 10:29
Code: format PE macro mGet [args] { common macro mGetArg base*,[arg] \{ \common mov base,[GetBufr] match any,GetBufr \\{ define GetBufr any+4 \\} \forward match =+ x, arg \\{ add base, x \\} match =:=~ x, arg \\{ shl base, x \\} match =~=: x, arg \\{ shr base, x \\} \} if ~ args eq forward mGetArg args common end if purge mGetArgs } GetBufr equ myBuffData mGet <eax,+8, ~:3>,<esi,+8, :~2>,edx myBuffData rd 4 Code: $ fasm test_mGet.asm flat assembler version 1.73.32 (16384 kilobytes memory, x64) 2 passes, 1024 bytes. $ hexdump -C test_mGet.exe 00000000 4d 5a 80 00 01 00 00 00 04 00 10 00 ff ff 00 00 |MZ..............| 00000010 40 01 00 00 00 00 00 00 40 00 00 00 00 00 00 00 |@.......@.......| 00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00000030 00 00 00 00 00 00 00 00 00 00 00 00 80 00 00 00 |................| 00000040 0e 1f ba 0e 00 b4 09 cd 21 b8 01 4c cd 21 54 68 |........!..L.!Th| 00000050 69 73 20 70 72 6f 67 72 61 6d 20 63 61 6e 6e 6f |is program canno| 00000060 74 20 62 65 20 72 75 6e 20 69 6e 20 44 4f 53 20 |t be run in DOS | 00000070 6d 6f 64 65 2e 0d 0a 24 00 00 00 00 00 00 00 00 |mode...$........| 00000080 50 45 00 00 4c 01 01 00 56 da f7 66 00 00 00 00 |PE..L...V..f....| 00000090 00 00 00 00 e0 00 0f 01 0b 01 01 49 00 02 00 00 |...........I....| 000000a0 00 02 00 00 00 00 00 00 00 10 00 00 00 10 00 00 |................| 000000b0 00 10 00 00 00 00 40 00 00 10 00 00 00 02 00 00 |......@.........| 000000c0 01 00 00 00 00 00 00 00 03 00 0a 00 00 00 00 00 |................| 000000d0 00 20 00 00 00 02 00 00 5e b1 00 00 03 00 00 00 |. ......^.......| 000000e0 00 10 00 00 00 10 00 00 00 00 01 00 00 00 00 00 |................| 000000f0 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00 |................| 00000100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00000170 00 00 00 00 00 00 00 00 2e 66 6c 61 74 00 00 00 |.........flat...| 00000180 2d 00 00 00 00 10 00 00 00 02 00 00 00 02 00 00 |-...............| 00000190 00 00 00 00 00 00 00 00 00 00 00 00 60 00 00 e0 |............`...| 000001a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00000200 a1 1d 10 40 00 83 c0 08 c1 e8 03 8b 35 21 10 40 |...@........5!.@| 00000210 00 83 c6 08 c1 e6 02 8b 15 25 10 40 00 00 00 00 |.........%.@....| 00000220 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * Code: $ objdump -M intel -D test_mGet.exe test_mGet.exe: формат файла pei-i386 Дизассемблирование раздела .flat: 00401000 <.flat>: 401000: a1 1d 10 40 00 mov eax,ds:0x40101d 401005: 83 c0 08 add eax,0x8 401008: c1 e8 03 shr eax,0x3 40100b: 8b 35 21 10 40 00 mov esi,DWORD PTR ds:0x401021 401011: 83 c6 08 add esi,0x8 401014: c1 e6 02 shl esi,0x2 401017: 8b 15 25 10 40 00 mov edx,DWORD PTR ds:0x401025 ... Code: format PE macro mGet [args] { common macro mGetArg base*,[arg] \{ \common mov base,[GetBufr] match any,GetBufr \\{ define GetBufr any+4 \\} \forward match =+ x, arg \\{ add base, x \\} match =( x, arg \\{ shl base, x \\} match =) x, arg \\{ shr base, x \\} \} if ~ args eq forward mGetArg args common end if purge mGetArgs } GetBufr equ myBuffData mGet <eax,+8, )3>,<esi,+8, (2>,edx myBuffData rd 4 Code: $ fasm test_mGet.asm flat assembler version 1.73.32 (16384 kilobytes memory, x64) 2 passes, 1024 bytes. $ hexdump -C test_mGet.exe 00000000 4d 5a 80 00 01 00 00 00 04 00 10 00 ff ff 00 00 |MZ..............| 00000010 40 01 00 00 00 00 00 00 40 00 00 00 00 00 00 00 |@.......@.......| 00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00000030 00 00 00 00 00 00 00 00 00 00 00 00 80 00 00 00 |................| 00000040 0e 1f ba 0e 00 b4 09 cd 21 b8 01 4c cd 21 54 68 |........!..L.!Th| 00000050 69 73 20 70 72 6f 67 72 61 6d 20 63 61 6e 6e 6f |is program canno| 00000060 74 20 62 65 20 72 75 6e 20 69 6e 20 44 4f 53 20 |t be run in DOS | 00000070 6d 6f 64 65 2e 0d 0a 24 00 00 00 00 00 00 00 00 |mode...$........| 00000080 50 45 00 00 4c 01 01 00 e3 da f7 66 00 00 00 00 |PE..L......f....| 00000090 00 00 00 00 e0 00 0f 01 0b 01 01 49 00 02 00 00 |...........I....| 000000a0 00 02 00 00 00 00 00 00 00 10 00 00 00 10 00 00 |................| 000000b0 00 10 00 00 00 00 40 00 00 10 00 00 00 02 00 00 |......@.........| 000000c0 01 00 00 00 00 00 00 00 03 00 0a 00 00 00 00 00 |................| 000000d0 00 20 00 00 00 02 00 00 eb b1 00 00 03 00 00 00 |. ..............| 000000e0 00 10 00 00 00 10 00 00 00 00 01 00 00 00 00 00 |................| 000000f0 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00 |................| 00000100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00000170 00 00 00 00 00 00 00 00 2e 66 6c 61 74 00 00 00 |.........flat...| 00000180 2d 00 00 00 00 10 00 00 00 02 00 00 00 02 00 00 |-...............| 00000190 00 00 00 00 00 00 00 00 00 00 00 00 60 00 00 e0 |............`...| 000001a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00000200 a1 1d 10 40 00 83 c0 08 c1 e8 03 8b 35 21 10 40 |...@........5!.@| 00000210 00 83 c6 08 c1 e6 02 8b 15 25 10 40 00 00 00 00 |.........%.@....| 00000220 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * Code: $ objdump -M intel -D test_mGet.exe test_mGet.exe: формат файла pei-i386 Дизассемблирование раздела .flat: 00401000 <.flat>: 401000: a1 1d 10 40 00 mov eax,ds:0x40101d 401005: 83 c0 08 add eax,0x8 401008: c1 e8 03 shr eax,0x3 40100b: 8b 35 21 10 40 00 mov esi,DWORD PTR ds:0x401021 401011: 83 c6 08 add esi,0x8 401014: c1 e6 02 shl esi,0x2 401017: 8b 15 25 10 40 00 mov edx,DWORD PTR ds:0x401025 ... |
|||
28 Sep 2024, 10:29 |
|
Roman 28 Sep 2024, 10:41
Thanks.
Little changed your macro. Code: macro mGet2 [args] { common macro mGetArg af*,base*,[arg] \{ \common ;match any,GetBufr \\{ define GetBufr any+af mov base,[GetBufr+af] ;\\} \forward match =+ x, arg \\{ add base, x \\} match =:=~ x, arg \\{ shl base, x \\} match =~=: x, arg \\{ shr base, x \\} match : , arg \\{ mov base, [base] \\} match # , arg \\{ call base \\} match =* x , arg \\{ x base \\} \} if ~ args eq forward mGetArg args common end if purge mGetArgs } macro mpu a {push a call a pop a } Start: GetBufr equ edx+16 mGet2 <0,eax,:,+8, ~:3,#>,\ <4,esi,+8, :~2,*mpu>,\ <16,edx,:> Last edited by Roman on 28 Sep 2024, 11:57; edited 1 time in total |
|||
28 Sep 2024, 10:41 |
|
macomics 28 Sep 2024, 11:36
You should not use # symbol to indicate operations, because it is also used by the preprocessor to connect operators.
|
|||
28 Sep 2024, 11:36 |
|
Roman 28 Sep 2024, 11:40
Ok.
Using &. Bad idea. Farm get error. Idea using "&" or ">" and could using "!=" or "\" or "@" Code: macro mGet2 [args] { common macro mGetArg af*,base*,[arg] \{ \common ;match any,GetBufr \\{ define GetBufr any+af mov base,[GetBufr+af] GetReg equ base ;\\} \forward match =+ x, arg \\{ add base, x \\} ;match =:=~ x, arg \\{ shl base, x \\} ;match =~=: x, arg \\{ shr base, x \\} match ">" x, arg \\{ shr base, x \\} match "<" x, arg \\{ shl base, x \\} match : , arg \\{ mov base, [base] \\} match 'do' , arg \\{ call base \\} match =* x , arg \\{ x base \\} \} if ~ args eq forward mGetArg args common end if purge mGetArgs } GetBufr equ edx+16 mGet2 <0,eax,:,+8, ">"3>,\ <4,GetReg,+8, "<"2, 'do'> My opinion we need set for macro special symbols using for preprocessor. Or using <\ and \> for preprocessor. New feature for fasmw. |
|||
28 Sep 2024, 11:40 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.