flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
macomics 14 Feb 2025, 05:10
Any usage examples?
And Code: match any `arg rest,: 'rax' 'rbx' 'rcx' 'rdx' 'rsp' 'rbp' 'rsi' 'rdi' 'r8' 'r9' 'r10' 'r11' 'r12' 'r13' 'r14' 'r15' \{ op arg1,arg2 Code: match any `arg2 rest,: 'rax' 'rbx' 'rcx' 'rdx' 'rsp' 'rbp' 'rsi' 'rdi' 'r8' 'r9' 'r10' 'r11' 'r12' 'r13' 'r14' 'r15' \{ op arg1,arg2 |
|||
![]() |
|
ProMiNick 14 Feb 2025, 08:28
Code: macro rsp.helper op,arg1,arg2 { match any `arg2 rest,: 'rax' 'rbx' 'rcx' 'rdx' 'rsp' 'rbp' 'rsi' 'rdi' 'r8' 'r9' 'r10' 'r11' 'r12' 'r13' 'r14' 'r15' \{ op arg1,arg2 rept 0 \{\} rept 1 \{ local i,j,k j=(1+(('sub'-`op) shr 64) shl 1);sub=1,add=-1 if defined i k=i else k=0 end if irpv n,%%%rsp \\{ \\common if %%rsp=$ %%%rsp = j*(arg2)+k else op arg1,arg2+j*(k) end if rept 0 \\{\\} rept 1 \\{ if arg2+j*(k) if j*(arg2)+k=8 push rbp else op arg1,arg2+j*(k) end if end if \\} %%rsp=$ irpv n,%%%rsp { restore %%%rsp \\} %%%rsp equ i \} } Code: struc rsp args& { local i match any =sub =add rest=,arg,:sub . add: args \{ match more],arg \\{ . rsp args rept 0 \\{\\} rept 1 \\{ rsp.helper .,rsp,arg \\} rept 0 \{\} rept 1 \{ . rsp args \} } Code: ;usecase %%rsp = -500 use64 sub rsp,2 sub rsp,rax ; no matter what instruction would be here - just not changing rsp with constant sub rsp,-$2 Code: ;usecase %%rsp = -500 use64 sub rsp,2 sub rsp,[rax] ; no matter what instruction would be here - just not changing rsp with constant sub rsp,$6 Code: ;usecase %%rsp = -500 use64 sub rsp,2 ;sub rsp,rax sub rsp,-$2 Code: ;usecase %%rsp = -500 use64 sub rsp,2 ;sub rsp,rax sub rsp,$6 real code don`t starts with sequence of stack moves so definition " %%rsp = -500" needed only for test. And thanks for found bugs in previous realization(that was a bit raw). |
|||
![]() |
|
Roman 14 Feb 2025, 10:32
Very interesting.
I try this but ... Code: macro helper1 arg2 { match `arg2 , 'eax' \{ display `arg2 \}} ;in code helper1 eax ;display 'eax' macro helper2 arg2 { match `arg2 , 'eax' 'ecx' \{ display `arg2 \}} ;in code helper2 ecx ;not display any. expected 'ecx' Last edited by Roman on 14 Feb 2025, 11:05; edited 1 time in total |
|||
![]() |
|
ProMiNick 14 Feb 2025, 10:40
cutoff helper needance. I guess it is final solution
Code: struc rsp _,args& { ;separating comma from content of args give ability to "match some `args other" directly match any =sub =add rest,:sub . add: { match more],args { . rsp,args rept 0 {\\} rept 1 { match some `args other,: 'rax' 'rbx' 'rcx' 'rdx' 'rsp' 'rbp' 'rsi' 'rdi' 'r8' 'r9' 'r10' 'r11' 'r12' 'r13' 'r14' 'r15' :{ . rsp,args rept 0 {\\\} rept 1 { local i,j,k j=(1+(('sub'-`.) shr 64) shl 1);sub=1,add=-1 if defined i k=i else k=0 end if irpv n,%%%rsp { \\\\common if %%rsp=$ %%%rsp = j*(args)+k else . rsp,args+j*(k) end if rept 0 {\\\\} rept 1 { if args+j*(k) if j*(args)+k=8 push rbp else . rsp,args+j*(k) end if end if \\\\} %%rsp=$ irpv n,%%%rsp { restore %%%rsp \\\\} %%%rsp equ i \\\} \\} rept 0 {\} rept 1 { match ,args { . rsp ; this additional match is pay for separating comma from args rept 0 {\\} rept 1 { . rsp,args \\} \} } Last edited by ProMiNick on 14 Feb 2025, 12:44; edited 1 time in total |
|||
![]() |
|
ProMiNick 14 Feb 2025, 11:09
Roman wrote: I try this but ... Thou forgot that both sides of match should match. Remember my variant from both sides of match sequence at right part there are ":" and at left part there are "some" & "other" around tested fragment. Code: macro helper2 arg2 { match any `arg2 more, :'eax' 'ecx': \{ display `arg2 \}} ;in code helper2 ecx ;problem is solved? :) _________________ I don`t like to refer by "you" to one person. My soul requires acronim "thou" instead. |
|||
![]() |
|
Roman 14 Feb 2025, 11:29
Thanks.
Work fine. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.