flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > [fasmg] C style fastcall macro toolkit - version 1 |
| Author |
|
|
Jessé 08 Jun 2025, 12:56
This is the final stable (at least to my tests
Changes from BETA2: - irpv demon is now gone! - overall performance has become quite good now! - removed internal TRUE, FALSE and NULL definitions. Internal types for this still exist. - default size statement for unsizable parameters is now permanent (see this post); - upgrade 'testtype' internal macro following Tomasz recomendations about register identification; - 32 bit computed address with 32 registers now is recognized as 32-bit size; - added support to pass MMX registers for integer type parameters (dword, qword); - enhance tword parameter decision taking on FPU parameters (including FPU registers); - added PI number (TT or π represented) as a tword parameter; - added support for ("CHARDATA") format to pass up to qword characters parameter (not string); - added 'alias' macro inside proto macro, which defines only the alias not the function name as macro; - internal aliased functions now call function 'name' instead of '_name'; - added _bss macro for uninitialized data section (alpha stage, due to limitations on how 'virtual' directive handles uninitialized data); - added '_code rwx' for declaring a self modifying code section (read, write and execute); - made _data, _rdata and _code reusable, outputting sections contents to the topmost _data, _rdata or _code macro; - label x number thing is removed, completely unreliable. But it is not a problem, because it still has *label or the classical [label] to do its stuff. I included the updated user guide version, please read it. There's some points to consider when using the new stuff. Also helper texts are alongside macro code to complement what's in the user guide. The 'irpv' problem is due to me keeping using my first premature version of 'testtype', which has wrong define/equ/= usage for some global variables. 100% fixed now! The one here is much more refined, stable, and has a much much better performance than the BETA2 approach. And extra features, too. This also makes it extremely bounded to fasm2 environment, which is never an issue, because it is made for fasm2 assembler/x86-64/Linux O.S./System V ABI Fastcall calling convention. So, backup that copy of BETA2 if you have it. One might need to reuse my text-based register detect melhod if doing anything customized. Have fun! ✌️
|
|||||||||||
|
|
Jessé 13 Jun 2025, 05:44
From now on, one can get any updates on this macro toolkit under my GitHub repo for it (finally).
I know I'm changing the wheel while the car is moving, but, I can't wait... |
|||
|
|
Jessé 11 Jun 2026, 07:37
|
|||
|
|
Jessé 25 Jul 2026, 08:21
I dive deep to make an upgraded version of it, and thanks to the prompt help of Tomasz Grysztar and bitRAKE, alongside with many others that help me figured out several things with fasmg (again, thank you guys for your patience and good explanations and suggestions), it's now possible (at my current not published yet development stage: version 3) to achieve this beautiful syntax:
Code: format ELF64 executable 3 include 'fastcall3.inc' include 'stdio.inc' struct DUMMY1 .a dq ? .b dq ? .c dq ? end struct struct SUB_FIELD .sub_a dq ? .sub_b dq ? .sub_c: dq ? .sub_d: dq ? .sub_e DUMMY2 end struct struct TEST_FIELDS .data.first dq ? .data.second dq ? .ptr.first: dq ? .ptr.second: dq ? .what.third SUB_FIELD .data.fourth dq ? .data.fifth: dq ? end struct struct DUMMY2 .d: dq ? .e: dq ? .f: dq ? .g dq ? end struct _bss dmys DUMMY2 var TEST_FIELDS dmye DUMMY1 _code Start entry: libc.StartMain(Main); Main: push 0 mov rax, [stdout] mov rdx, [stderr] push [rax] push [rdx] pop [stderr] pop [stdout] fputs("Loading structure...", stdout); fflush(stdout); mov [var.data.first], +1000 mov [var.data.second], +2000 mov [var.what.third.sub_e.g], -3000 fputs(" done."\n, stdout); fflush(stdout); fprintf(stderr, "Dumping fields:"\n \ " Data: %d, %d, %d Address: 0x%lX, 0x%lX, 0x%lX"\n, \ var.data.first, var.data.second, var.what.third.sub_e.g, \ var.ptr.first, var.ptr.second, var.what.third.sub_e.f); pop rax ret .testpost: db 'This message pointer must be seen as address type!', 10, 0 When compiling (the verbosity is on because of its current 'development' phase) it results in: Quote:
For reference: Type 1: data at memory Type 3: effective address Type 17: simple string (which will be rendered null terminated) Type 18: absolute literal number Type 37: escaped string type (also null terminated) And, when running it: Quote:
Another example, with comments to ease understanding (now, dynamic address ELF): Code: format ELF64 include 'fastcall3.inc' ; The almighty header behind this stuff include 'stdio.inc' ; Reusable header related to libc.so.6 CONSTANT1 := 585585h ; Numeric literal data labels CONSTANT2 = 100001h ; _rdata DATA dd 800008h ; By value [data] label POINTER: db 'this is a pointer-type label', 0 ; By reference pointer label _code Start entry: libc.StartMain(Main); ; This is a macro at 'stdio.inc' header Main: push 0 @1 fprintf(stdout, "Values of 'CONSTANT's are: 0x%X 0x%X."\n, CONSTANT1, CONSTANT2); @2 fprintf(stdout, "Data at 'DATA' variable is: 0x%X."\n, DATA); @3 fprintf(stdout, "String at pointer 'POINTER' label is: '%s'."\n, POINTER); pop rax ret ; For reference, about the last parameters of each line: ; ; Data at '@1' label resolves to: mov reg, CONSTANTx ; Data at '@2' label resolves to: mov reg, [DATA] ; Data at '@3' label resolves to: lea reg, [POINTER] ; Compiling: Quote:
And running: Quote:
At its current development, all of those previous problems I've faced are now solved, and all of them were because of my lack of experience with fasmg at that moment, which is making me realize how limitless fasmg really appears to be. As soon as I can, I'll publish it here, as always, and let you know. Cheers! |
|||
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2026, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.