flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > mov eax,$rgb(33,22,11)

Author
Thread Post new topic Reply to topic
Gyricon



Joined: 09 Jun 2011
Posts: 4
Location: Ukraine
Gyricon 27 Jan 2018, 14:08
[Eng]

How to create macro/equ for use as functions in expressions?

The problem here is that
1) The "macro" design can work with parameters, but it generates a text block!
2) The "equ" construct generates a string, but does not know how to work with parameters!
3) I do not want to override all instructions like "mov", "add", "sub" to special macros.
Is there another way?

Code:
;For example, ( 33 shl 16 ) or ( 22 shl 8 ) or ( 11 )
mov eax,$rgb(33,22,11)

;For example, ( 0 shl 24 ) + ( 10b shl 16 ) or ( 255 shl 8 ) or ( 'A' )
mov eax,$bbbb(0,10b,255,'A')

;For example, (File_Device_Keyboard shl 16) + (02h shl 14) + (Method_Buffered shl 2) + (File_Any_Access)
mov eax,$ctl_code(File_Device_Keyboard,02h,Method_Buffered,File_Any_Access)
    



[Rus]

Как создать macro/equ для использования в виде функций в выражениях?

Проблема здесь в том, что
1) Конструкция "macro" умеет работать с параметрами, но генерирует текстовый блок!
2) Конструкция "equ" генерирует строку, но не умеет работать с параметрами!
3) Не хочется переопределять все инструкции вида "mov", "add", "sub" на специальные макросы.
Есть ли другой способ?

Code:
;Например, (33 shl 16) or (22 shl 8) or (11)
mov eax,$rgb(33,22,11)

;Например, (0 shl 24) or (10b shl 16) or (255 shl 8) or ('A')
mov eax,$bbbb(0,10b,255,'A')

;Например, (File_Device_Keyboard shl 16) or (02h shl 14) or (Method_Buffered shl 2) or (File_Any_Access)
mov eax,$ctl_code(File_Device_Keyboard,02h,Method_Buffered,File_Any_Access)
    
Post 27 Jan 2018, 14:08
View user's profile Send private message ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 27 Jan 2018, 14:17
fasm doesn't support inline macros.

One way would be to create dedicated macros. You can call it something else, movrgb, movbytes, or whatever.

Another way is to do what you said you don't want and override mov, add etc.

A third way could be to create a macro for each type that assigns the value to a variable.
Code:
macro rgb var,r,g,b {
   var = (r) shl 16 + (g) shl 8 + b
}
rgb myvar,33,22,11
mov eax,myvar    
Post 27 Jan 2018, 14:17
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 798
Location: Russian Federation, Sochi
ProMiNick 27 Jan 2018, 15:02
[Rus]
Так не переопределяй все макросы. Переопредели только mov - это позволить решишь 98% всех случаев с полезной нагрузкой.

Иной путь предварить строки в которых ты хочешь использовать особый синтаксис (в том числе максросы в выражениях) набором знаков(например, let) - есть тема "3 games for kolibry & windows" - там неплохой пример как все это реализовать).

Если нужно без предварения строки макросом - то или ждать когда из fasmg будет бэкпортирован macro ? или переходить на fasmg, в нем такой макрос есть по нему есть тема "inline macroses in fasmg"

[Eng]
override only mov. that solves 98% of usuful cases.

declare one your macros, and precide by it each line in which you want special syntax (inline macroses).

or wait backporting of macro ?
Post 27 Jan 2018, 15:02
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.