flat assembler
Message board for the users of flat assembler.

Index > Main > Why can't I use a macro inside the procedure?

Author
Thread Post new topic Reply to topic
EaxRax



Joined: 20 Jul 2013
Posts: 15
EaxRax
I can't compile the program. The compiler writes: illegal instruction. Why can't I use a macro inside the procedure? And how to fix it?
Code:
format PE GUI 4.0
entry START
include 'win32ax.inc'
include 'ConvertByteToANSIBinaryNumber.inc'

START:
        stdcall ConvertByteToANSIBinaryNumber, 10, _buf
        invoke MessageBox, 0, _buf, Caption, MB_ICONINFORMATION+MB_OK
        invoke ExitProcess, 0

Caption db 'Test programme.',0

_buf: db '        '
_buf_len = $ - _buf

data import

  library KERNEL32, 'KERNEL32.DLL',\
          USER32, 'USER32.DLL'

  import KERNEL32,\
  ExitProcess, 'ExitProcess'

  import USER32,\
  MessageBox, 'MessageBoxA'

end data
    
Code:
;[byte]  byten - byte, that we need to convert.
;[dword] buffer  - buffer address, that will be record our result.

proc ConvertByteToANSIBinaryNumber,byten:BYTE, buffer:DWORD
        _ConvertByteToANSIBinaryNumber   [byten], [buffer]
        ret
endp 

macro _ConvertByteToANSIBinaryNumber   byten, buffer
{
local cnv, set1, cont

        mov      al, byten
        mov     edi, buffer
        xor     ecx, ecx
        mov     cl, 8
cnv:
        rol     al, 1
        jc      set1
        mov     [edi], byte "0"
        jmp     cont
set1:
        mov     [edi], byte "1"
cont:
        inc     edi
        dec     cl
        jnz     cnv
}
    


Description:
Filesize: 3.03 KB
Viewed: 1945 Time(s)

Screenshot.png


Post 19 Nov 2013, 23:55
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17275
Location: In your JS exploiting you and your system
revolution
You must define the macro before you can instantiate it.
Code:
macro _ConvertByteToANSIBinaryNumber   byten, buffer
{ ... } ;define it first

proc ConvertByteToANSIBinaryNumber,byten:BYTE, buffer:DWORD
        _ConvertByteToANSIBinaryNumber   [byten], [buffer] ;then instantiate it
        ret
endp    
Post 20 Nov 2013, 00:13
View user's profile Send private message Visit poster's website Reply with quote
EaxRax



Joined: 20 Jul 2013
Posts: 15
EaxRax
Now the program is compiled. Very Happy Thank you very much! The question is removed.
Post 20 Nov 2013, 00:38
View user's profile Send private message Reply with quote
Sasha



Joined: 17 Nov 2011
Posts: 93
Sasha
Here we had a conversation about similar problem. Also I wanted to define a macro with the same name as a proc.
Post 20 Nov 2013, 15:55
View user's profile Send private message Reply with quote
EaxRax



Joined: 20 Jul 2013
Posts: 15
EaxRax
Clear. Image
Post 21 Nov 2013, 00:06
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-2020, Tomasz Grysztar.

Powered by rwasa.