flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > How to do these

Author
Thread Post new topic Reply to topic
l4m2



Joined: 15 Jan 2015
Posts: 674
l4m2 26 Jan 2015, 03:24
make a macro:
mov eax,ebx => mov eax,ebx
mov eax,ebx+ecx => lea eax,[ebx+ecx]
mov ax,[bx+cx] => lea ax,[ebx+ecx] ;May be harder somehow
mov dword [eax],[ebx] => push dword [ebx]|pop dword [eax]
So how many of them can be done?
Mov ax,[ebx+ecx] can be used to replace the third command
I think there should be some ways to know if a command is illegal ...
Post 26 Jan 2015, 03:24
View user's profile Send private message Reply with quote
RIxRIpt



Joined: 18 Apr 2013
Posts: 50
RIxRIpt 26 Jan 2015, 12:06
2.2.2 Conditional assembly
Quote:
The eqtype operator checks whether the two compared values have the same structure, ...

Code:
use32

macro mov op1, op2 {
        if op2 eqtype eax+eax
                lea op1, [op2]
        else if op1 eqtype dword[eax] & op2 eqtype [eax]
                push dword op2
                pop op1
        else ;the rest cases you could do your self..
                mov op1, op2
        end if
}

mov eax, ebx + ecx
mov eax, ebx
mov edx, esi + edi
mov dword[edi], [esi]

;compiles to:
CPU Disasm
Address   Hex dump          Command
00CA2FF0    8D040B          LEA EAX,[ECX+EBX]
00CA2FF3    89D8            MOV EAX,EBX
00CA2FF5    8D143E          LEA EDX,[EDI+ESI]
00CA2FF8    FF36            PUSH DWORD PTR DS:[ESI]
00CA2FFA    8F07            POP DWORD PTR DS:[EDI]
    
Post 26 Jan 2015, 12:06
View user's profile Send private message Visit poster's website Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 674
l4m2 26 Jan 2015, 13:22
RIxRIpt wrote:
2.2.2 Conditional assembly
Quote:
The eqtype operator checks whether the two compared values have the same structure, ...

Code:
use32

macro mov op1, op2 {
        if op2 eqtype eax+eax
                lea op1, [op2]
        else if op1 eqtype dword[eax] & op2 eqtype [eax]
                push dword op2
                pop op1
        else ;the rest cases you could do your self..
                mov op1, op2
        end if
}

mov eax, ebx + ecx
mov eax, ebx
mov edx, esi + edi
mov dword[edi], [esi]

;compiles to:
CPU Disasm
Address   Hex dump          Command
00CA2FF0    8D040B          LEA EAX,[ECX+EBX]
00CA2FF3    89D8            MOV EAX,EBX
00CA2FF5    8D143E          LEA EDX,[EDI+ESI]
00CA2FF8    FF36            PUSH DWORD PTR DS:[ESI]
00CA2FFA    8F07            POP DWORD PTR DS:[EDI]
    

But can it know "lea eax,[eax*4+ecx]"?Infinity ways to mean so.
Post 26 Jan 2015, 13:22
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.