flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > [BUG?]Are numbers valid symbols?

Author
Thread Post new topic Reply to topic
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Check this out:
Code:
; OK
1 equ 'one', 13, 10
display 1

; OK
macro 2{
  display 'two', 13, 10
}
2

; INVALID NAME
;macro '3'{
;  display 'three', 13, 10
;}
;'3'

;'4' equ 'four', 13, 10 ; ILLEGAL INSTRUCTION
display '4', 13, 10

5.0 equ 'five', 13, 10
display 5.0

macro 6.0{
  display 'six', 13, 10
}
6.0    


This was discovered by ouadji when he tested numerical names on PROC arguments.
Post 24 Apr 2011, 00:09
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17463
Location: In your JS exploiting you and your system
revolution
Preprocessor is not sensitive to symbol contents. They are all just strings of characters to be processed as usual.
Post 24 Apr 2011, 01:12
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: 4633
Location: Argentina
LocoDelAssembly
I think it should, specially because of this:
Code:
1 equ 3
alpha equ 3

rept 1{display 'one, '}

display 13, 10
rept alpha{display 'alpha, '}

display 13, 10
rept alpha+1{display 'alpha+1, '}    


Also, are numbers really symbols or just tokens that the preprocessor is unconditionally considering them as symbols but making an exception for REPT?
Post 24 Apr 2011, 15:28
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17463
Location: In your JS exploiting you and your system
revolution
rept has special processing to evaluate values so it won't see the 'equ' substitutions for plain numbers.
Code:
display 13, 10
match x,1 {rept x{display 'one, '\}}    
Post 25 Apr 2011, 01:51
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7751
Location: Kraków, Poland
Tomasz Grysztar
Right, this was not an issue before the new REPT functionality was introduced, however now it is worth a reconsideration. Would disallowing a digit-starting names for symbolic variables cause any problems. I do not think anyone would use this feature for any serious purpose, but I may be wrong.
Post 26 Apr 2011, 18:15
View user's profile Send private message Visit poster's website 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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.