flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
bitRAKE 26 Jan 2021, 18:01
I'm way out of practice with fasm1, but if you had the size you could do:
Code: macro n cval,sz { rept 1 i:sz \{ match X|=i:A|Y,||1:al|2:ax|4:eax|8:rax|| \\{ mov [cval],A \\} \} } ![]() |
|||
![]() |
|
Tomasz Grysztar 26 Jan 2021, 18:25
Wow, that's a nice trick!
The standard "struct" macro for fasm defines some additional constants that you could use: Code: include 'macro/struct.inc' struct ar A dd 0 B dw 0 C db 0 E dq 0 ends display '0'+sizeof.ar.A |
|||
![]() |
|
Roman 27 Jan 2021, 06:03
Srt ar
Why we not get size Srt. X? But fine get size of struct ar. |
|||
![]() |
|
bitRAKE 27 Jan 2021, 20:44
Code: macro na cval,parent { local sz sz = sizeof.#parent if sz = 1 mov [cval],al else if sz = 2 mov [cval],ax else if sz = 4 mov [cval],eax else if sz = 8 mov [cval],rax else display "size of item is not register size" err end if } Code: child ar ; define an instance na child.A,ar.A |
|||
![]() |
|
Roman 28 Jan 2021, 05:29
Thanks bitRAKE !
Work fine. I little modified. Code: macro sSv cval { local sz sz = cval#_tp if sz = 1 mov [cval],al else if sz = 2 mov [cval],ax else if sz = 4 mov [cval],eax else if sz = 8 mov [cval],rax else display "size of item is not register size" err end if } mov eax,0xff3040aa zio.A_tp equ sizeof.ar.A ;would be nice if some macro do this automatically. zio.B_tp equ sizeof.ar.B zio.C_tp equ sizeof.ar.C sSv zio.A sSv zio.B sSv zio.C Last edited by Roman on 28 Jan 2021, 05:57; edited 1 time in total |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.