flat assembler
Message board for the users of flat assembler.

Index > Main > EQU (solved)

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 06 Mar 2010, 23:46

hi Wink

Is it possible to concatenate two "equ" ?
Code:
A1 equ aaa
B1 equ bbb

C1 equ ??? ; <--- C1 = A1 + B1 (Is it possible to do that ?)
    

_________________
I am not young enough to know everything (Oscar Wilde)- Image


Last edited by ouadji on 07 Mar 2010, 15:53; edited 1 time in total
Post 06 Mar 2010, 23:46
View user's profile Send private message Send e-mail Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4324
Location: Now
edfed 07 Mar 2010, 00:45
maybe:
Code:
C1 equ A1B1; C1 equ aaabbb
    
Post 07 Mar 2010, 00:45
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 07 Mar 2010, 01:42
Code:
loco@athlon64:~$ cat test.asm 
A1 equ aaa
B1 equ bbb

match concat, A1#B1
{
  C1 equ concat
}

; Verify concatenation 
match c, C1{display `c}
loco@athlon64:~$ fasm test.asm
flat assembler  version 1.69.11  (16384 kilobytes memory)
aaabbb
1 passes, 0 bytes.    
Post 07 Mar 2010, 01:42
View user's profile Send private message Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 07 Mar 2010, 09:40

Thank you LocoDelAssembly. Razz

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 07 Mar 2010, 09:40
View user's profile Send private message Send e-mail Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 07 Mar 2010, 11:30

Code:
if

A1 equ /      ;or /*

then

does not work.
    

it's a pity, this would have been useful .

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 07 Mar 2010, 11:30
View user's profile Send private message Send e-mail Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 07 Mar 2010, 12:06
ouadji,

It's only backtick that don't work. Symbol C1 is defined as /bbb. Try
Code:
match c, C1 { irps s, c \{ display \`s \} }    
to display it's value.
Post 07 Mar 2010, 12:06
View user's profile Send private message Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 07 Mar 2010, 12:25

yes, it works (display), but
in fact, I would like to do this:
Code:
A1 equ "
B1 equ /*
match concat, A1#B1#A1 ; A1#B1#A1== "/*"
{ 
  C1 equ concat 
}
mov eax,'C1'  ; == mov eax,'"/*"'
    

but I think I am asking something impossible!

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 07 Mar 2010, 12:25
View user's profile Send private message Send e-mail Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4324
Location: Now
edfed 07 Mar 2010, 13:09
Quote:

but I think I am asking something impossible!

and maybe a little useless too Very Happy
Post 07 Mar 2010, 13:09
View user's profile Send private message Visit poster's website Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 07 Mar 2010, 14:14

sorry but my English is not good enough to explain all this,
and edfed is French.

et non ce n'est pas inutile, pas dans mon cas.
Dans mon code, celui qui permet les commentaires multi-lignes et en blocs, je fais à plusieurs endroits référence aux symboles "start-comment" et "end-comment" ... Pouvoir définir ces symboles start/end avec des EQU m'aurait permis de changer rapidement de symboles dans tout mon code. Par exemple, passer de "/* */" à "(! !)". Je peux le faire, mais il faut que je définisse la totalité des "cas" ... exemple ... pour mov eax,'"/*"' ... je peux définir par un EQU <toto equ '"/*"'> et écrire ensuite : "mov eax,toto". Ca, c'est ok. Mais il faut alors que je définisse par des "equ" tous les cas ... "'/*'", '"/*'", "'*/'",'"*/"' . Pouvoir agir avec "equ + concaténation" m'aurait permis de changer uniquement 2 equ ...
celui pour /* et celui pour */. Les autres cas seraient alors définis d'office par concaténation. voilou.

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 07 Mar 2010, 14:14
View user's profile Send private message Send e-mail Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 501
Location: Belarus
zhak 07 Mar 2010, 14:17
wow! i don't know french, but i understood almost everything what ouadji wrote! )) sorry for offtopic )
Post 07 Mar 2010, 14:17
View user's profile Send private message Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 07 Mar 2010, 14:25

hat off zhak ! Wink
I am unable myself to understand a single word of Russian!

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 07 Mar 2010, 14:25
View user's profile Send private message Send e-mail Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 07 Mar 2010, 15:40

my solution
Code:
@S_ equ 2A2Fh
@E_ equ 2F2Ah

@S_qd = (@S_ shl 8) or 22000022h
@E_qd = (@E_ shl 8) or 22000022h

mov eax , @E_qd  ; mov eax,'"*/"'

if i change @E_ ... @E_ equ 2921h 
then, i have : mov eax,'"!)"'
    

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 07 Mar 2010, 15:40
View user's profile Send private message Send e-mail Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 07 Mar 2010, 16:49
ouadji,

Why are you need all those combinations of quotes? Half of them are invalid anyway: string literal must end with the same quote (single or double) as it was started. Wink

Backtick macro operator works in match too: match c, `A1#`B1 { C1 equ c } defines C1 as string '/*'. Moreover, simple Wink macro can be used to stringify (almost any) sequence of symbols:
Code:
COMMENT_START equ / *
COMMENT_END equ * /

struc textequ arg {
  local r
  r equ
  match v, arg \{ irps s, v \\{ match vv, r\\\#\\\`s \\\{ r equ vv \\\} \\} \}
  match v, r \{ . equ v \}
}

COMMENT_START_STRING textequ COMMENT_START
COMMENT_END_STRING textequ COMMENT_END

display COMMENT_START_STRING, 13, 10, COMMENT_END_STRING, 13, 10

SSQUOTED_COMMENT_START_STRING equ "'" shl 24 or (COMMENT_START_STRING) shl 8 or "'"
SDQUOTED_COMMENT_START_STRING equ "'" shl 24 or (COMMENT_START_STRING) shl 8 or '"'
DSQUOTED_COMMENT_START_STRING equ '"' shl 24 or (COMMENT_START_STRING) shl 8 or "'"
DDQUOTED_COMMENT_START_STRING equ '"' shl 24 or (COMMENT_START_STRING) shl 8 or '"'

mov eax, DDQUOTED_COMMENT_START_STRING    
The possibilities are endless! Wink
Post 07 Mar 2010, 16:49
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4324
Location: Now
edfed 07 Mar 2010, 17:29
to make coments on fasm, we use the ;

pour ce qui est du français, evidement que l'on peu comprendre le français ecrit lorsque l'on connait l'anglais, car l'anglais est une langue qui à importé une tonne de mots de france. mais les ont mis en anglais.
donc, on peu facilement anglishiser un mot français.
par exemple:

j'aime les galettes

i love the galets

ok, it is not always true.
Smile.

de plus, le russe est inspiré du français en partie car était la langue de la cour du temps des tsars. donc, les russes n'ont pas de merites a comprendre el français.
d'ailleur, un petit suet sur le russe serait interressant sur ce forum.
par exemple, du russe orienté fasm. Smile


n'empeche, je ne comprend pas pourquoi utiliser le C design dans fasm.

fasm is made to code asm
gcc is made to code C
then, if you want to code C, use GCC, not fasm. Smile
Post 07 Mar 2010, 17:29
View user's profile Send private message Visit poster's website Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 07 Mar 2010, 20:08

Quote:

from baldr :

Why are you need all those combinations of quotes ?
Half of them are invalid anyway
I only need 4 combinations.
"/*" ; "*/" ; '/*' and '*/'.
this, inside my multiline-comment code.
These combinations should not be detected as a beginning or end of comment (nested or not)
Quote:

Moreover, simple macro can ...
Macros are an unknown world for me.
There is not much information about this in the fasm doc.
Where to find good documentation on the macros language ?
Where to find good explanations and examples ... not in fasm.pdf.

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 07 Mar 2010, 20:08
View user's profile Send private message Send e-mail Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 07 Mar 2010, 20:35

Code:
start_symbol equ /*
end_symbol equ */

struc textequ arg { 
  local r 
  r equ 
  match v, arg \{ irps s, v \\{ match vv, r\\\#\\\`s \\\{ r equ vv \\\} \\} \} 
  match v, r \{ . equ v \} 
}

@S_ textequ start_symbol
@E_ textequ end_symbol

@S_qd equ '"' shl 24 or (@S_) shl 8 or '"' 
@E_qd equ '"' shl 24 or (@E_) shl 8 or '"'
    

thank you very much baldr Razz

This solution is perfect and meets my needs exactly.
But where did you learn the macros language ?
Where to find good documentation about this?

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 07 Mar 2010, 20:35
View user's profile Send private message Send e-mail Reply with quote
Fanael



Joined: 03 Jul 2009
Posts: 168
Fanael 07 Mar 2010, 22:18
Ar an drochuair, níl aon doiciméadú.
Post 07 Mar 2010, 22:18
View user's profile Send private message Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 07 Mar 2010, 22:39
Fanael wrote:
Ar an drochuair, níl aon doiciméadú.
if there is no documentation,
how those who know to use it, have they done ?

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 07 Mar 2010, 22:39
View user's profile Send private message Send e-mail Reply with quote
edemko



Joined: 18 Jul 2009
Posts: 549
edemko 07 Mar 2010, 22:49
Holy the google: http://translate.google.com/#auto|en|
The more macro the less assembler and more http://board.flatassembler.net/topic.php?t=11242&start=18(see baldr's post).
Post 07 Mar 2010, 22:49
View user's profile Send private message Reply with quote
Fanael



Joined: 03 Jul 2009
Posts: 168
Fanael 08 Mar 2010, 07:50
ouadji wrote:
Fanael wrote:
Ar an drochuair, níl aon doiciméadú.
if there is no documentation,
how those who know to use it, have they done ?
Perhaps they learned how to use macros from examples posted by someone else (mostly Tomasz). There is nothing what can be called "documentation of FASM macros", not to mention "good documentation".

You know Irish?!?
Post 08 Mar 2010, 07:50
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< 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-2023, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.