On Jul 31, 2021, at 2:09 PM, Shaikhul Hadi <shaikh...@gmail.com> wrote:
I'm trying to understand how to implement my own magic function in sniper. I have gone through many posts in this group and the manual but could not find anything that properly explained this. Let's see some code from sim_api.h file.#define SimMagic2(cmd, arg0, arg1) ({ \unsigned long _cmd = (cmd), _arg0 = (arg0), _arg1 = (arg1), _res; \__asm__ __volatile__ ( \"mov %1, %%" MAGIC_REG_A "\n" \"\tmov %2, %%" MAGIC_REG_B "\n" \"\tmov %3, %%" MAGIC_REG_C "\n" \"\txchg %%bx, %%bx\n" \: "=a" (_res) /* output */ \: "g"(_cmd), \"g"(_arg0), \"g"(_arg1) /* input */ \: "%" MAGIC_REG_B, "%" MAGIC_REG_C ); /* clobbered */ \_res; \}).........#define SimUser(cmd, arg) SimMagic2(SIM_CMD_USER, cmd, arg)Now I have multiple questions, if anyone bothers to explain it to me, I would be grateful. Thanks in advance.
- Who assigned or provide _res value? There is no return type is defined for SimMagic2() or SimUser(). In that case, who is using the value or _res?
- Is there any proper guideline on how I should write the assembly portion of the instruction (__asm__)? I searched on the internet and most of the tutorials I got on assembly in C++, their structure does not clear everything the way SimMagic2() is defined. (Perdon my lack of knowledge on writing assembly in C++, I never tried this before.)
- %1 will use value _cmd , %2 will use value _arg0 ; is my assumption write? What task does the line with the comment "/* clobbered */" perform?
I apologize if my question is silly. I just want to clear my concept about how to work with magic function in sniper and what is its limit. Any resources (except sniper manual and this group) suggestions will be greatly appreciated.
Thank you
--
--
--
You received this message because you are subscribed to the Google
Groups "Sniper simulator" group.
To post to this group, send email to snip...@googlegroups.com
To unsubscribe from this group, send email to
snipersim+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/snipersim?hl=en
---
You received this message because you are subscribed to the Google Groups "Sniper simulator" group.
To unsubscribe from this group and stop receiving emails from it, send an email to snipersim+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/snipersim/77654e1d-48d2-4e4a-992f-19d1321bcd45n%40googlegroups.com.