flat assembler
Message board for the users of flat assembler.

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

Joined: 21 Apr 2012
Posts: 1701
Roman 13 Jul 2013, 14:30
I write display \`Mi\`
And display 'Mi'
Not work.
How do this?
13 Jul 2013, 14:30
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 20146
revolution 13 Jul 2013, 14:44
Code:
`display "'Mi'"    `
13 Jul 2013, 14:44
Roman

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

Work but print Mi.
13 Jul 2013, 14:49
Roman

Joined: 21 Apr 2012
Posts: 1701
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.
13 Jul 2013, 14:57
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 20146
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
\}
}    ```
13 Jul 2013, 14:58
Roman

Joined: 21 Apr 2012
Posts: 1701
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
13 Jul 2013, 15:20
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.
13 Jul 2013, 17:06
Roman

Joined: 21 Apr 2012
Posts: 1701
Roman 13 Jul 2013, 18:15
baldr
Thanks.
But I say that I know how do using match.
13 Jul 2013, 18:15
Roman

Joined: 21 Apr 2012
Posts: 1701
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 !
13 Jul 2013, 18:51
Roman

Joined: 21 Apr 2012
Posts: 1701
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
13 Jul 2013, 19:16
Roman

Joined: 21 Apr 2012
Posts: 1701
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-
13 Jul 2013, 19:42
Roman

Joined: 21 Apr 2012
Posts: 1701
Roman 13 Jul 2013, 19:57
But my Cut its macro. Not new function. And for this reason, my Cut has limitations
13 Jul 2013, 19:57
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.
14 Jul 2013, 06:49
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainTutorials and ExamplesDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsOS ConstructionIDE DevelopmentProjects and IdeasNon-x86 architecturesHigh Level LanguagesProgramming Language DesignCompiler Internals Other----------------FeedbackHeapTest Area

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum