flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Variable in quotes?

Author
Thread Post new topic Reply to topic
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu 24 Jul 2009, 06:00
Is there a way to do something similar to

var = 234
db "1var5"

and have it output "12345", without using some slow ITOA macro that'll make it take forever to compile if I use many of these?
Post 24 Jul 2009, 06:00
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 24 Jul 2009, 06:37
how about:
Code:
var equ "234"
db "1",var,"5"
    


or

Code:
macro itoa var
{
  display "1",`var,"5" ;debug
  db "1",`var,"5"
}

itoa 234
    
Post 24 Jul 2009, 06:37
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu 24 Jul 2009, 20:10
Let me post my exact code okay and tell me why it doesn't work together please

Code:
struc edb[a]{ common
                      . dd .len
                   label .data byte
            forward
                     local l,b
                   done equ
                    match =reverse b, a \{
                        done equ 1
                  l db b
                      repeat ($-l)/2
                              load b1 byte from l+%-1
                             load b2 byte from $-%
                               store byte b1 at $-%
                                store byte b2 at l+%-1
                              end repeat
                  \}
                    match , done \{
                               db a
                        \}
            common
                      .len = $-.data}


MrString        edb 'Hello, I am ',`MrString.len,' bytes long. In otherwords, ',`(MrString.len*8),' bits.'    


It fails to compile with "value out of range"! Sad
Post 24 Jul 2009, 20:10
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4024
Location: vpcmpistri
bitRAKE 25 Jul 2009, 01:54
Please, tell the value of MrString.len that you have calculated. It this equation possible to solve? I believe there are several correct answers, but haven't worked it out.
Post 25 Jul 2009, 01:54
View user's profile Send private message Visit poster's website Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu 25 Jul 2009, 01:59
Expected output:
Code:
MrString.len      = 51
MrString.l: dd MrString.len
MrString:        db 'Hello, I am 51 bytes long. In otherwords, 408 bits.'    



It would solve it by counting how long the string is, inserting the count into the right spots, and then recounting until the number stops changing, I guess. Or maybe it has a more optimized way.
Post 25 Jul 2009, 01:59
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4024
Location: vpcmpistri
bitRAKE 25 Jul 2009, 02:25
# and ` must be used in a macro.

Eh, should work in a struc too.


Last edited by bitRAKE on 25 Jul 2009, 02:29; edited 1 time in total
Post 25 Jul 2009, 02:25
View user's profile Send private message Visit poster's website Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu 25 Jul 2009, 02:28
So if I put it in a dummy rept or irp block it should work? It doesn't. Sad


Any other ideas?
Post 25 Jul 2009, 02:28
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4024
Location: vpcmpistri
bitRAKE 25 Jul 2009, 02:37
I can't get it to interpret MrString.len as a number - always a string.

Adding:
Code:
display    13,10,`.len,13,10    
..results in: MrString.len
Confused

(Even in Madis731's example above the macro argument is a string.)


Last edited by bitRAKE on 25 Jul 2009, 02:41; edited 1 time in total
Post 25 Jul 2009, 02:37
View user's profile Send private message Visit poster's website Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu 25 Jul 2009, 02:39
That wouldn't work anyways.. I need to be able to put it anywhere in the string, not in a hard coded location x_x


Thanks anyways though
Post 25 Jul 2009, 02:39
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4024
Location: vpcmpistri
bitRAKE 25 Jul 2009, 02:42
Well, when testing we might try other things to discover.
(I wasn't implying this was a solution to your problem.)

The manual says ` quotes a string as well.
Post 25 Jul 2009, 02:42
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4024
Location: vpcmpistri
bitRAKE 25 Jul 2009, 03:08
I suspect the macro invocation is stripping the ` as well. Sad
(Put as many as you want and they are gone: ````````MrString.len)


Last edited by bitRAKE on 25 Jul 2009, 03:11; edited 1 time in total
Post 25 Jul 2009, 03:08
View user's profile Send private message Visit poster's website Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu 25 Jul 2009, 03:09
Aww Sad

Is there a way to fix this besides making more changes to FASM's source? I'm sick of having to change it.. and then re-apply all my changes to it every time a new version comes out..



Please???????
Post 25 Jul 2009, 03:09
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number 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.