flat assembler
Message board for the users of flat assembler.

Index > Main > How display Mi. Mi EQU 2+3/2(2-2)

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1878
Roman 13 Jul 2013, 14:30
I write display \`Mi\`
And display 'Mi'
Not work.
How do this?
Post 13 Jul 2013, 14:30
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20513
Location: In your JS exploiting you and your system
revolution 13 Jul 2013, 14:44
Code:
display "'Mi'"    
Post 13 Jul 2013, 14:44
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1878
Roman 13 Jul 2013, 14:49
revolution
display "'Mi'"
You code not work. You compiling you code?

Work but print Mi.
Post 13 Jul 2013, 14:49
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1878
Roman 13 Jul 2013, 14:57
And new another question.
Mi EQU 2+3/2(2-2)
How cut Mi?
Mj EQU (2-2)
I mean Mi EQU Mi minus Mj and we get Mi = 2+3/2
Its can be done in fasm without macros ?
If not my function Cut must be done in next version Fasm.
Post 13 Jul 2013, 14:57
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20513
Location: In your JS exploiting you and your system
revolution 13 Jul 2013, 14:58
Oh I misread what you want. You can use match.
Code:
Mi equ 2+3/2(2-2)

match x,Mi {
        irps z,x \{
                display \`z
        \}
}    
Post 13 Jul 2013, 14:58
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1878
Roman 13 Jul 2013, 15:20
How to make with match, i know
Quote:

And new another question.
Mi EQU 2+3/2(2-2)
How cut Mi?
Mj EQU (2-2)
I mean Mi EQU Mi minus Mj and we get Mi = 2+3/2
Post 13 Jul 2013, 15:20
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 13 Jul 2013, 17:06
Roman,
Code:
Mi EQU 2+3/2(2-2)
Mj EQU (2-2)

match _Mj, Mj {
  match _Mi _Mj, Mi \{
    restore Mi
    Mi equ _Mi
  \}
}

; Test
match _Mi, Mi {
  irps s, _Mi \{ display \`s \}
}    
Beware though that numbers in pattern will match any symbols, even symbol characters, unless properly escaped.
Post 13 Jul 2013, 17:06
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1878
Roman 13 Jul 2013, 18:15
baldr
Thanks.
But I say that I know how do using match.
Post 13 Jul 2013, 18:15
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1878
Roman 13 Jul 2013, 18:51
baldr
Write this, and get wrong result !
Code:
Mi EQU 2+3/2(2-2)+5 
Mj EQU (2-2) 

match _Mj, Mj { 
  match _Mi _Mj, Mi \{ 
    restore Mi 
    Mi equ _Mi 
  \} 
} 

; Test 
match _Mi, Mi { 
  irps s, _Mi \{ display \`s \} 
}    


As I said a new feature like Cut need !
Post 13 Jul 2013, 18:51
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1878
Roman 13 Jul 2013, 19:16
My code:
Quote:

Mi EQU 2+3/2(2-2)+5
Mj fix(2-2)

match ctc=Mj kj ,Mi { Mi EQU ctc kj
}

We get Mi = 2+3/2+5


But if we write Mi EQU 2+3/2(2-2) then my code not work.
I'm trying to prove the limitation of match
Post 13 Jul 2013, 19:16
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1878
Roman 13 Jul 2013, 19:42
My macro:
Quote:

macro Cut arg,chu {
Mhh EQU ' '
Mff EQU arg Mhh
match tc=chu kj ,Mff \{ arg EQU \tc \kj
\}
}

section '.code' code readable writeable executable
Mi EQU 2+3/2-(2-2)+5.2/2
Mj fix (2-2)+

Cut Mi,Mj

match x,Mi {
irps z,x \{
display \`z
\}
display 13,10
}


We can write Mi EQU 2+3/2-(2-2)
Mj fix (2-2)
Cut Mi,Mj
and get Mi = 2+3/2-
Post 13 Jul 2013, 19:42
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1878
Roman 13 Jul 2013, 19:57
But my Cut its macro. Not new function. And for this reason, my Cut has limitations
Post 13 Jul 2013, 19:57
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 14 Jul 2013, 06:49
Roman,

There is "Edit" button at the bottom right of your posts, use it to add something to already submitted post. Otherwise it looks like that you're arguing with yourself.
Roman wrote:
And new another question.
Mi EQU 2+3/2(2-2)
How cut Mi?
Mj EQU (2-2)
I mean Mi EQU Mi minus Mj and we get Mi = 2+3/2
How could one suppose (in this context) that you want to remove Mj from Mi not only at the end, but in the middle too? Be more specific when you're describing problem.

Actually, your Cut macro does some extra modification to its first argument: ' ' trailer (i.e. quoted string consisting of single space) is appended to it, so after Cut Mi,Mj value of Mi will be «2+3/2-5.2/2 ' '» (space before string literal is added only to separate it from preceding digit 2, because 2' is a valid preprocessor symbol). Multiple invocations with the same symbolic constant name for arg will append more (in case of match, naturally).

Indeed, proper macro could be written even for general case (that is, replace one subsequence of symbols with another, perhaps empty, for particular, I mean first/n-th/last, occurrence or all of them), probably with some restrictions. The question is, will result justify the needed efforts? What are you trying to achieve using this cut operation?

If you speak Russian better, send me PM to assure that nothing is lost in translation. Wink
Post 14 Jul 2013, 06:49
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.