flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Virtual registers. How do ? Goto page 1, 2 Next |
Author |
|
Roman 30 Jul 2020, 07:10
I write but not shoore its good solution or not.
I test on IDA Pro work fine. Code: VR1 EQU eax VR11 EQU ebx VR111 EQU edx VR1111 EQU ecx VR11111 EQU esi VR111111 EQU edi VR1111111 EQU [tmpVR1] VR11111111 EQU [tmpVR2] VR111111111 EQU [tmpVR3] VR1111111111 EQU [tmpVR4] VR11111111111 EQU [tmpVR5] VR111111111111 EQU [tmpVR6] VR1111111111111 EQU [tmpVR7] CurVR EQU VR ozzVR EQU 0 macro CyclVR { local i CurVR EQU CurVR\#1 match aa,CurVR \{ mov aa,2 \} LB_#i: ozzVR EQU LB_#i } macro VRLoop { match aa,CurVR \{ dec aa cmp aa,0 \} jnz ozzVR restore ozzVR restore CurVR } section '.code' code readable writeable executable gre dd 110 fur dd 0 freq dd 0 rept 10 n:1 { tmpVR#n dd 0 } start: CyclVR CyclVR CyclVR CyclVR CyclVR CyclVR CyclVR CyclVR CyclVR VRLoop VRLoop VRLoop VRLoop VRLoop VRLoop VRLoop VRLoop VRLoop |
|||
30 Jul 2020, 07:10 |
|
DimonSoft 30 Jul 2020, 08:48
Feels like you’re doing something really strange. What’s your real goal?
|
|||
30 Jul 2020, 08:48 |
|
Roman 30 Jul 2020, 09:39
No need to think about which register to write.
This method set auto register. And no need write labels. This method good for some individual utelites. Utelite out txt code. Profit PS: If write code for ARM , this good because easy change VR1 registers. Or 32 bits code change\rewrite for 64 bits(registers R8\R9\R10\R11\R12\R13\R14\R15). Last edited by Roman on 30 Jul 2020, 10:11; edited 2 times in total |
|||
30 Jul 2020, 09:39 |
|
Roman 30 Jul 2020, 10:01
I not realy like so long names VR1111111111111.
How fix this ? |
|||
30 Jul 2020, 10:01 |
|
DimonSoft 30 Jul 2020, 11:50
It is going to turn out to be a leaky abstraction as soon as your
Code: mov vr10, vr11 Code: mov [tmpVR10], [tmpVR11] If you expect this to become a cross-platform solution, you’re about to fail. Just think about other limitations of different architectures and just plain corner cases: Code: mov vr0, [vr10] Code: mov eax, [[tmpVR10]] Code: mov vr0, [vr0] Code: mov eax, [eax] Code: mov ax, [ax] I don’t think there’s an easy solution for what you ask for. But I’d think twice if you really need that. |
|||
30 Jul 2020, 11:50 |
|
Roman 30 Jul 2020, 11:59
I'm not saying my solution is perfect.
I'm just discussing this. And maybe something better to come up with this. I dont know. Code: Not good: mov vr10, vr11 ;get mov [tmpVR10], [tmpVR11] Good: macro VR10,VR11 ;get movss xmm1, VR11 and movss VR10,xmm1 Macro must translete to movss xmm1, VR11 and movss VR10,xmm1 Macro might get type. Is this register or [register] Code: macro VRMov chA,chB { if chA eqtype reg & chB eqtype reg movss xmm1,[chB] movss [chA],xmm1 end if if chA eqtype [] & chB eqtype [] movss xmm1,chB movss chA,xmm1 end if if chA eqtype [] & chB eqtype reg movss xmm1,[chB] movss chA,xmm1 end if if chA eqtype reg & chB eqtype [] movss xmm1,chB movss [chA],xmm1 end if } In code: VR_7 EQU VR1111111 VR_8 EQU VR11111111 VRMov VR_7,VR_8 I tested now. Work |
|||
30 Jul 2020, 11:59 |
|
Roman 31 Jul 2020, 07:30
How do this ?
Code: macro VRPush { local i i = VR_cnttz if VR_cnttz > 0 i = i - 1 push VR_#i end if } Fasm get error undefined symbol VR_i I want get this: push VR_5 push VR_4 push VR_3 push VR_2 push VR_1 |
|||
31 Jul 2020, 07:30 |
|
revolution 31 Jul 2020, 07:40
You can't mix assembler =, if, etc. and preprocessor macros like that.
Use rept Code: VR_cnttz equ 5 rept VR_cnttz i { reverse push VR_#i } |
|||
31 Jul 2020, 07:40 |
|
Roman 31 Jul 2020, 07:51
Thanks revolution
But i have litle problem. VR_cnttz = 5 And rept VR_cnttz i { reverse push VR_#i } Get me error invalid value Last edited by Roman on 31 Jul 2020, 07:56; edited 1 time in total |
|||
31 Jul 2020, 07:51 |
|
revolution 31 Jul 2020, 07:53
You can't use = there. You have to use EQU because it is a preprocessor value.
|
|||
31 Jul 2020, 07:53 |
|
Roman 31 Jul 2020, 07:59
CyclVR now work fine. And i need VR_cnttz
Code: macro CyclVR chNum { local i CurVR EQU CurVR\#1 match aa,CurVR \{ mov aa,chNum \} LB_#i: ozzVR EQU LB_#i VR_cnttz = VR_cnttz + 1 } How i can do EQU (get VR_cnttz for rept) in this case ? Last edited by Roman on 31 Jul 2020, 08:14; edited 1 time in total |
|||
31 Jul 2020, 07:59 |
|
revolution 31 Jul 2020, 08:13
Use rept again:
Code: VR_cnttz equ 0 ;... rept 2 x:VR_cnttz {VR_cnttz equ x} ; increment VR_cnttz |
|||
31 Jul 2020, 08:13 |
|
Roman 31 Jul 2020, 08:37
I put rept 2 x:VR_cnttz {VR_cnttz equ x} in macro CyclVR:
Code: VR_cnttu EQU 0 ;do this one time ! macro CyclVR chNum { local i CurVR EQU CurVR\#1 match aa,CurVR \{ mov aa,chNum \} LB_#i: ozzVR EQU LB_#i VR_cnttz = VR_cnttz + 1 rept 1 x:VR_cnttu \{ VR_cnttu equ x \} } In code i do only two CyclVR, but get VR_cnttu = 0 ! I rewrite Code: VR_cnttu EQU 0 ;do this one time ! macro CyclVR chNum { local i CurVR EQU CurVR\#1 match aa,CurVR \{ mov aa,chNum \} LB_#i: ozzVR EQU LB_#i VR_cnttz = VR_cnttz + 1 rept 2 x:VR_cnttu \{ VR_cnttu equ x \} } Now i do two CyclVR and get VR_cnttu = 2 |
|||
31 Jul 2020, 08:37 |
|
revolution 31 Jul 2020, 09:17
"rept 2 ..." is the correct value to increment by 1
|
|||
31 Jul 2020, 09:17 |
|
revolution 31 Jul 2020, 09:20
I think this also works:
Code: rept 1 x:VR_cnttz+1 {VR_cnttz equ x} ; increment VR_cnttz |
|||
31 Jul 2020, 09:20 |
|
Roman 31 Jul 2020, 12:13
Quote: rept 1 x:VR_cnttz+1 {VR_cnttz equ x} ; increment VR_cnttz Yes its work. I test. Last edited by Roman on 31 Jul 2020, 12:16; edited 1 time in total |
|||
31 Jul 2020, 12:13 |
|
Roman 31 Jul 2020, 12:16
Another problem. Not work If
Code: macro VRPush { rept VR_cnttu ri \{ if VR_\#ri eqtype reg reverse push VR_\#ri end if \} } Must do push eax\ebx\edx\ecx\esi\edi But get nothing. Without if work fine. Last edited by Roman on 31 Jul 2020, 12:18; edited 1 time in total |
|||
31 Jul 2020, 12:16 |
|
revolution 31 Jul 2020, 12:17
"reg" is not a type. Perhaps you mean "eax" which is a register.
|
|||
31 Jul 2020, 12:17 |
|
Roman 31 Jul 2020, 12:19
Yes. Your right.
I write if VR_\#ri eqtype eax now work how i expected. Another strange thing: Work fine. Code: rept VR_cnttu ri \{ reverse if VR_\#ri eqtype eax push VR_\#ri end if \} But not work correct: Code: rept VR_cnttu ri \{ if VR_\#ri eqtype eax reverse push VR_\#ri end if \} |
|||
31 Jul 2020, 12:19 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.