SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Discussion

Reply
 
Thread Tools Display Modes
Old 13/04/2013, 05:26 PM   #1
Slice
High-roller
 
Join Date: Mar 2008
Location: Sweden
Posts: 1,831
Reputation: 1607
Default @emit

Quote:
Originally Posted by ****** View Post
...
Nice find ******! This also allows inserting code at the end of a line!

pawn Code:
#define EAT_LINE:%0\10;%1 The line contained: <%0> nom nom

EAT_LINE:boop boop () {}

Last edited by Y_Less; 16/04/2013 at 08:39 PM.
Slice is offline   Reply With Quote
Old 16/04/2013, 01:55 PM   #2
xeeZ
Huge Clucker
 
Join Date: Feb 2013
Posts: 320
Reputation: 382
Default Re: Today I learned - Share your newly found knowledge!

Wonderful! I just wrote a new new macro for asm.inc using this trick

pawn Code:
// Looks pretty much like inline assembly
@emit proc      ;
@emit push_s    12;
@emit push_c    4;
@emit sysreq_d  GetNativeAddressFromName("print");
@emit stack     8;
@emit retn      ;

Edit:

Oh, and today I learned how to include spaces in macros!

Last edited by Y_Less; 16/04/2013 at 08:38 PM.
xeeZ is offline   Reply With Quote
Old 16/04/2013, 02:13 PM   #3
xeeZ
Huge Clucker
 
Join Date: Feb 2013
Posts: 320
Reputation: 382
Default Re: Today I learned - Share your newly found knowledge!

Quote:
Originally Posted by ****** View Post
Ha! You beat me to it... There is a note on the corner of the bit of paper in front of me that just says "@emit", reminding me to write exactly that macro later tonight (I went for @emit instead of just emit as I thought it looked more like #emit, but that's a minor point).
Hmm, that's actually a good idea, it looks even better that way
xeeZ is offline   Reply With Quote
Old 16/04/2013, 05:05 PM   #4
Slice
High-roller
 
Join Date: Mar 2008
Location: Sweden
Posts: 1,831
Reputation: 1607
Default Re: Today I learned - Share your newly found knowledge!

Quote:
Originally Posted by xeeZ View Post
Wonderful! I just wrote a new new macro for asm.inc using this trick

pawn Code:
// Looks pretty much like inline assembly
@emit proc      ;
@emit push_s    12;
@emit push_c    4;
@emit sysreq_d  GetNativeAddressFromName("print");
@emit stack     8;
@emit retn      ;

Edit:

Oh, and today I learned how to include spaces in macros!
You could match \10 in the end to avoid the semicolon.

pawn Code:
#define @emit%0\32;%1\32;%2\10; asm_emit_%1(ctx, %2);
Slice is offline   Reply With Quote
Old 16/04/2013, 06:44 PM   #5
Slice
High-roller
 
Join Date: Mar 2008
Location: Sweden
Posts: 1,831
Reputation: 1607
Default Re: Today I learned - Share your newly found knowledge!

@******:
It doesn't, actually. The lst will show the output without the newline character, but it still counts it as a new line.

I tried putting a bunch of them together, which ended up with 4000 chars on one line, but it compiled just fine.
Slice is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Emit Help Snir_sofer Scripting Help 2 25/09/2012 06:54 PM
#emit rVar Scripting Help 2 08/09/2012 07:26 PM
Help with #emit _Petrol_ Scripting Help 0 23/08/2012 04:54 PM
#emit Max_Coldheart Scripting Help 6 08/03/2012 09:17 PM


All times are GMT. The time now is 07:53 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.