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?
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
;[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
}