flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Confused about generated code |
Author |
|
Jerry 31 Dec 2016, 12:26
Hello,
I've encountered something i do not understand in fasmg (hll54). What i am attempting is to write a proc macro that takes some parameters. An example would be Code: proc dlgproc, 8, 4, HWND, MSG, WPARAM, LPARAM, LOCAL1 ....... ... end proc One can then access them by [HWND] or [LOCAL1] etc. The first parameter is how many qwords to reserve for the stack unconditionally (room for api calls). The second is the amount of actual arguments (a dlgproc has 4), and also allocate stack for that to back them up for more than 4 arguments one needs to look beyond the returnaddress of the caller and it's shadow space and find the other ( > 4) arguments stored right to left (that part is't working yet but doesn't matter for this question) Any additional argument names after the formal ones will be made local variables. Attached is procdemo.zip that consist of procdemo.asm and procdemo.png (a screenshot from x64dbg that shows the generated code) The line 'mov rax,qword ptr ss:[ ... ]' is repeated 4 times, the following 'mov qword ptr ss:[rsp+60], rax' only once (which is correct and even the correct offset) But they are generated within the same 'if', that's the part i don't understand, what am i missing ? Thanks in advance
|
|||||||||||
31 Dec 2016, 12:26 |
|
Jerry 31 Dec 2016, 13:24
Thanks,
I still have a lot to learn (then again, who doesn't). Will be reading the documentation again. Regards |
|||
31 Dec 2016, 13:24 |
|
Jerry 31 Dec 2016, 13:51
Looked again ....
It actually works, i was looking for the (my) handling of any (not local)) parameter beyond 4. The example proc usage i sent was 4 parameters and 1 local so there was no 5 parameters whatsoever to begin with. Second post, second time overlooking something ... Sorry for taking up unnecessary time. |
|||
31 Dec 2016, 13:51 |
|
Tomasz Grysztar 31 Dec 2016, 15:01
By the way, IRP/ITERATE allows to use % and %% parameters to access the number of current iteration and total count, so instead of:
Code: irp arg, args count = count + 1 if count > argcount Code: irp arg, args if % > argcount |
|||
31 Dec 2016, 15:01 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.