Yep - PureBasic actually already has macros!!!!
Because PureBasic's assembler is FASM - you can use the features of fasm to create macros!!!
Code: Select all
!macro test
!{
MessageRequester("test","hello")
!}
!test
!test
-Anthony
Code: Select all
!macro test
!{
MessageRequester("test","hello")
!}
!test
!test
Code: Select all
!macro test
!{
MessageRequester("test","hello")
!}
! test
! test
Heh, in that sample, doing the same in a procedure would give the same resultdagcrack wrote:May I say orgasmic!!? because it is. But although, why some of you guys would kill for macros? What do they have that I dont know of?
Oh by the way if I call !test I get assembler error [70] error invalid operand. but if I use just test it works ok. why is this? im an ASM nooblet .Using 3.91 maybe thats the reason of my problem. ill update soon then.
It is possible:AFAIK you can't use params with that approach, can you?
Code: Select all
!macro ErrText string{
!JMP $+37
MessageBox_(0,0,0,0)
!Push 48
!Push 0
!Push [v_#string]
!Push 0
!CALL _MessageBoxA@16
!}
a$="Hello !"
!ErrText a$
Code: Select all
!macro DISASM Count{
!PUSH ECX
!JMP $+19
DisASMCommand(0)
!MOV Ecx,Count
!MOV Eax,$+55
!PUSH ECX
!Call PB_DisASMCommand
!PUSH EAX
Debug GetDisASMString()
!POP EAX
!POP ECX
!LOOP $-47
!POP ECX
!}
!DISASM 3 ;Disassembles the next 3 ASM-Commands
A=5
Code: Select all
!macro test
!{
bla / 5 * 99
d = 70 * 100000 / (90 + 700)
l = a > c
d * 1000
!}
Procedure test()
bla / 5 * 99
d = 70 * 100000 / (90 + 700)
l = a > c
d * 1000
EndProcedure
#N = 100000000
t1 = GetTickCount_()
For I = 0 To #N
! test
Next
t1 = GetTickCount_() - t1
t2 = GetTickCount_()
For I = 0 To #N
test()
Next
t2 = GetTickCount_() - t2
out.s = "macro: "+Str(t1)+#CRLF$
out.s + "proc: "+Str(t2)
MessageRequester("result",out)