hello: I have created these 2 macros to handle the scape sequence characters like
in the C languaje the names are str and stru for ascii and unicode they can be put
wherever the db or du can. (I think)
message: str 'Hello\nThere'
the colon after the message label is required,but the final 0 is not.
one good thing about these macros is that you can change the scape character
indicator :
I use the '\' as the scape indicator, and put only the n and t to be recognized as
scape sequences, but you can add any others you like
the only problem i have found is when you terminate the string with the character
indicator so if you want to print 'hello\' it would give an 'out of range' error
and this is because when the macro finds the '\' character it will load the next
character to see if it's one of the scape characters defined but there is nothimg more
to load, that is why the same scape indicator must be defined also as scape character
so the problem gets solved typing 'hello\\' and it will get printed correctly as
'hello\'
the behavior is different from the C compilers for instance: typing 'hello\q'
in borland C compiler will print 'helloq',so the '\' is ignored.
with these macros you will get 'hello\q' unless you have defined q to be other thing
lets say:
else if char2 = 'q'
char = '"'
then you will get :
here are the macros
macro str string
{ ;get strinf size
virtual at 0
db string
size=$-$$
end virtual
;-------------------------------
count = 1
repeat size
virtual at 1
db string
load char byte from count
if char = '\'
load char2 byte from count+1
if char2 = '\'
char = '\'
count = count+1
else if char2 = 't'
char = 9
count =count+1
else if char2 = 'n'
char = 13
count = count+1
end if
end if
end virtual
db char
if count = size
break
end if
count = count+1
end repeat
db 0
}
macro stru string
{ ;get strinf size
virtual at 0
db string
size=$-$$
end virtual
;-------------------------------
count = 1
repeat size
virtual at 1
db string
load char byte from count
if char = '\'
load char2 byte from count+1
if char2 = '\'
char = '\'
count = count+1
else if char2 = 't'
char = 9
count =count+1
else if char2 = 'n'
char = 13
count = count+1
end if
end if
end virtual
dw char
if count = size
break
end if
count = count+1
end repeat
dw 0
}