[Tutorial] AMX Assembly (#emit)
#14

WTF?! Just wanted to ask: Y_Less did it on purpose?!!111

IN "Usage of stack as temporary storage":
we see:
PHP Code:
     #emit POP.pri  //Pop the last pushed value into PRI 
     //last pushed was local, which had a value of 10 when pushed and hence PRI = 10
//by me: PRI is 10, ALT is 5
     #emit CONST.alt 5  //ALT = 5
     #emit SDIV //PRI = ALT / PRI (signed divide),ALT = ALT mod PRI
//by me: let's count, 5/10=0
// 5 mod 10= 5
    //Now ALT = 0 since 5 divides 10 completely and leaves no remainder
    //PRI = 2 since 10 divided by 5 gives 2 <=== WTF?! 
Did anyone get it? xD (Usually, in asm's it collects to PRI(As PRI is A, ALT is B, where a is accumulator register, b is base register))

IN "Finding the address of functions"

PHP Code:
new addr;
#emit CONST.pri func1
#emit STOR.S.pri addr 
Doesn't work with public function, should it be or what?!(Compared with funcidx)

IN "Accessing elements of arrays that are arguments"

PHP Code:
public OnPlayerCommandText(playerid,cmdtext[])
{
     new 
index 2;
     
#emit LOAD.S.alt cmdtext 
     #emit LOAD.pri index  //<==================== GOOD joke! 
#emit LOAD.pri index FACEPALM x999


Also it's ok:
PHP Code:
#emit LOAD.S.alt cmdtext 
You are loading a value, NOT address!
I think, it should be:
PHP Code:
#emit CONST.pri cmdtext 
And btw, write right sematics for IDXADDR:
PHP Code:
PRI ALT + (PRI Ч cell size) (calculate indexed address
Everyone can get it.
Change it to understandable(not everyone can understand it):
PHP Code:
 PRI ALT CELLSIZE PRI 
And where is wrong(who didn't get it):

PHP Code:
public OnPlayerCommandText(playerid,cmdtext[])
{
     new 
index 2;
     
#emit CONST.alt cmdtext 
     #emit LOAD.S.pri index 
     #emit IDXADDR //PRI = ALT + (PRI * cell size) (calculate indexed address)
    //Now PRI contains the address of the element stored in index 2 of cmdtext (cmdtext[2])
     #emit LOAD.I //PRI = [PRI] //Since PRI contains the address of cmdtext[2], [PRI] will give the value stored at index 2
     //Instead of using IDXADDR and then LOAD.I, you can do the same with just one instruction using LIDX
     //LIDX = PRI = [ALT + (PRI x cell size)]

I read until it, Gonna post more <s>bugs</s> easter eggs(maybe).
I see no the first time when Y_Less using trololo functions.

edit 1:

PHP Code:
main()
{
     new 
a[] = "AMX Assembly";
     new 
character;     
     
#emit ADDR.pri a
     #emit ADD.C 8
     #emit LOAD.I
     #emit STOR.S.pri character
     
printf("%c"character);

Just gonna wrote here. 8 is 2 symbols as cell is 4. u wouldn't understand maybe cos I wrote it.
PHP Code:
#emit ADD.C 4*n //where n is amount of symbols 
Reply


Messages In This Thread
AMX Assembly (#emit) - by Yashas - 15.10.2015, 17:33
Re: AMX Assembly (#emit) - by Yashas - 15.10.2015, 17:35
Re: AMX Assembly (#emit) - by Yashas - 15.10.2015, 17:37
Re: AMX Assembly (#emit) - by Ahmad45123 - 15.10.2015, 18:10
Re: AMX Assembly (#emit) - by SecretBoss - 15.10.2015, 20:31
Re: AMX Assembly (#emit) - by DaniceMcHarley - 17.10.2015, 08:49
Re: AMX Assembly (#emit) - by Stanford - 13.01.2016, 23:19
Re: AMX Assembly (#emit) - by darkdevil - 17.05.2016, 14:37
Re: AMX Assembly (#emit) - by Dutheil - 24.06.2016, 20:59
Re: AMX Assembly (#emit) - by Nero_3D - 24.06.2016, 21:32
Re: AMX Assembly (#emit) - by Yashas - 25.06.2016, 06:59
Re: AMX Assembly (#emit) - by Yashas - 15.07.2016, 15:00
Re: AMX Assembly (#emit) - by Luicy. - 05.08.2016, 19:07
Re: AMX Assembly (#emit) - by Sanya4 - 26.08.2016, 21:16
Re: AMX Assembly (#emit) - by Nero_3D - 27.08.2016, 03:14
Re: AMX Assembly (#emit) - by Sanya4 - 27.08.2016, 19:12
Re: AMX Assembly (#emit) - by Nero_3D - 27.08.2016, 22:15
Re: AMX Assembly (#emit) - by JakeXxX - 28.08.2016, 07:35
Re: AMX Assembly (#emit) - by spookie - 31.01.2017, 22:14
Re: AMX Assembly (#emit) - by HydraHumza - 01.02.2017, 12:03
Re: AMX Assembly (#emit) - by Dutheil - 18.07.2017, 13:43
Re: AMX Assembly (#emit) - by KushalD - 30.07.2017, 06:00
Re: AMX Assembly (#emit) - by Yashas - 01.10.2017, 09:39
Re: AMX Assembly (#emit) - by Yashas - 03.06.2018, 11:31

Forum Jump:


Users browsing this thread: 7 Guest(s)