flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > macro sizeof. for all fasm data |
Author |
|
Dima1205 02 Jul 2023, 18:14
Dear collegues, I propose a solution to problems with the use of sizeof. before all data. To do this, you need to supplement the definitions of FASM directives using struc in this way:
Code: ;Директивы sizof - по умолчанию её нет - поэтому придется доопределять ;данные. ;Директивы sizeof по выбранным данным (нужно для програботки данных): sizeof.db fix 1 sizeof.dw fix 2 sizeof.du fix 2 sizeof.dd fix 4 sizeof.dp fix 6 sizeof.df fix 6 sizeof.dq fix 8 sizeof.dt fix 10 ;Исходные константы для резервирования данных: sizeof.rb fix 1 sizeof.rw fix 2 sizeof.rd fix 4 sizeof.rp fix 6 sizeof.rf fix 6 sizeof.rq fix 8 sizeof.rt fix 10 ; ; ; Улучшенный механизм данных - дополняем размерностью автоматически: ; ; struc db [val] { common match any, val \{ . db val \} match , val \{ . db ? \} restore .size .size = $ - . restore sizeof.#. sizeof.#. = sizeof.db } ; struc du [val] { common match any, val \{ . du val \} match , val \{ . du ? \} restore .size .size = $ - . restore sizeof.#. sizeof.#. = sizeof.du } struc dw [val] { common match any, val \{ . dw val \} match , val \{ . dw ? \} restore .size .size = $ - . restore sizeof.#. sizeof.#. = sizeof.dw } struc dd [val] { common match any, val \{ . dd val \} match , val \{ . dd ? \} restore .size .size = $ - . restore sizeof.#. sizeof.#. = sizeof.dd } struc dq [val] { common match any, val \{ . dq val \} match , val \{ . dq ? \} restore .size .size = $ - . restore sizeof.#. sizeof.#. = sizeof.dq } struc df [val] { common match any, val \{ . df val \} match , val \{ . df ? \} restore .size .size = $ - . restore sizeof.#. sizeof.#. = sizeof.df } struc dt [val] { common match any, val \{ . dt val \} match , val \{ . dt ? \} restore .size .size = $ - . restore sizeof.#. sizeof.#. = sizeof.dt } ; ; ; Улучшенный механизм резервирования данных: ; ; struc rb val { . rb val restore .size .size = $ - . restore sizeof.#. sizeof.#. = $ - . } struc rw val { . rw val restore .size .size = $ - . restore sizeof.#. sizeof.#. = $ - . } struc rp val { . rp val restore .size .size = $ - . restore sizeof.#. sizeof.#. = $ - . } struc rd val { . rd val restore .size .size = $ - . restore sizeof.#. sizeof.#. = $ - . } struc rt val { . rt val restore .size .size = $ - . restore sizeof.#. sizeof.#. = $ - . } struc rq val { . rq val restore .size .size = $ - . restore sizeof.#. sizeof.#. = $ - . }
_________________ Best regards, Dmitry |
|||||||||||
02 Jul 2023, 18:14 |
|
Dima1205 02 Jul 2023, 20:31
Restore is needed as a protection if the constant has been defined before. For example from this phenomenon.
Code: define sizeof.test3 1 test3 db "test",0 Therefore, I left it - in general, it is not required, I agree here. _________________ Best regards, Dmitry |
|||
02 Jul 2023, 20:31 |
|
revolution 02 Jul 2023, 20:40
You can also use irpv to extend the defensiveness against multiple preceding equ or define.
Code: define sizeof.test3 1 define sizeof.test3 1 ;... irpv x,sizeof.test3 {restore sizeof.test3} ; remove any/all preceding equates/defines sizeof.test3 = 3 |
|||
02 Jul 2023, 20:40 |
|
Dima1205 02 Jul 2023, 21:03
Thank you. I think these macros will be a good help in the standard package.
They add 2 constants: 1.sizeof. - the size of the data type, or the size of the reserved data. 2. size. - is simply the size of the data that the given directive contains. |
|||
02 Jul 2023, 21:03 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.