flat assembler
Message board for the users of flat assembler.

flat assembler > Macroinstructions > Macro for placing bytes after DB

Author
Thread Post new topic Reply to topic
burris



Joined: 09 Dec 2017
Posts: 2
Hi,
I'm trying to make some helper macros for placing ANSI terminal codes (ie. for changing text colour or making it bold):

Code:
; Example usage

msg db ansi_bold, 'Hello world!', 0x0A

    


At this moment my version is as follows:

Code:
ESC = 0x1B ; Escape character
macro escape ansi_code { store ESC, ansi_code at . }
macro ansi_bold        { escape '[1m' }          ; Set "bright" attribute
macro ansi_fg_red      { escape '[31m' }         ; Set foreground to color #1 - red
    


But this is not working, obviously I'm doing something wrong. Would someone help me with it?
Post 23 Dec 2017, 20:15
View user's profile Send private message Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 211
Location: Russian Federation, Sochi
Make highlightings with such method worst thing.

I think all such decorations should be stay of code syntax.
for such purpose use comments.
Code:
msg db 'Hello world!', 0x0A ; #HL# ansi_bold quotedtext
    

than tell highlight function to detect content of comments

I think everything out of valuable source code should be in comments
I think about something closer - code folding. place in comment #+ or #- that would be hidden in IDE but according such comment code will be folded or not.
Post 23 Dec 2017, 23:13
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 16129
Location: Hyperborea
burris wrote:
Hi,
I'm trying to make some helper macros for placing ANSI terminal codes (ie. for changing text colour or making it bold):

Code:
; Example usage

msg db ansi_bold, 'Hello world!', 0x0A

    


At this moment my version is as follows:

Code:
ESC = 0x1B ; Escape character
macro escape ansi_code { store ESC, ansi_code at . }
macro ansi_bold        { escape '[1m' }          ; Set "bright" attribute
macro ansi_fg_red      { escape '[31m' }         ; Set foreground to color #1 - red
    


But this is not working, obviously I'm doing something wrong. Would someone help me with it?
fasm doesn't support inline macros. Instead you can use equ.
Code:
ESC     equ     0x1B
BOLD    equ     ESC,'[1m'
FG_RED  equ     ESC,'[31m'

msg db BOLD, 'Hello world!', 0x0a    
Post 24 Dec 2017, 08:04
View user's profile Send private message Visit poster's website Reply with quote
burris



Joined: 09 Dec 2017
Posts: 2
revolution wrote:
burris wrote:
Hi,
I'm trying to make some helper macros for placing ANSI terminal codes (ie. for changing text colour or making it bold):

Code:
; Example usage

msg db ansi_bold, 'Hello world!', 0x0A

    


At this moment my version is as follows:

Code:
ESC = 0x1B ; Escape character
macro escape ansi_code { store ESC, ansi_code at . }
macro ansi_bold        { escape '[1m' }          ; Set "bright" attribute
macro ansi_fg_red      { escape '[31m' }         ; Set foreground to color #1 - red
    


But this is not working, obviously I'm doing something wrong. Would someone help me with it?

fasm doesn't support inline macros. Instead you can use equ.
Code:
ESC     equ     0x1B
BOLD    equ     ESC,'[1m'
FG_RED  equ     ESC,'[31m'

msg db BOLD, 'Hello world!', 0x0a    


Revolution your example is what I need, thank you Smile
Post 24 Dec 2017, 11:01
View user's profile Send private message 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-2018, Tomasz Grysztar.

Powered by rwasa.