Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user Equinoxe_4 ! (Registered 2017-04-23) You are not logged in 
CSDb User Forums


Forums > C64 Coding > 64tass C-like escape sequences (ie '\xff')
2017-01-16 16:22
Compyx

Registered: Jan 2005
Posts: 211
64tass C-like escape sequences (ie '\xff')

After trying a few things and failing (using the latest SVN 64tass) to get C-like escape sequences to work, such as \xff (insert a $ff byte) inside .text or .byte blocks and checking the manual, I might as well ask here.

Is this at all supported? It seems like it isn't. I'm working on some simple editor that uses $f0-$ff inside a string of text to change the text color.

Right now I have:
.text $f1, "hello ", $f7, "world", 0

Which works fine, but makes using these color codes quite annoying, I'd prefer:
.text "\xf1hello \xf7world", 0


I know I can use .edef statements to construct my own encoding, but that seems a bit like overkill.

Any 64tass users out here who can help me?

-- Compyx
2017-01-16 18:00
Oswald

Registered: Apr 2002
Posts: 4022
soci usually hangs around and will fill you in soon.
2017-01-16 18:21
Compyx

Registered: Jan 2005
Posts: 211
I know, that's why I asked here ;)
2017-01-16 19:41
soci

Registered: Sep 2003
Posts: 315
No specific escaping style is enforced and "{cr}" and friends are only included as a convenience in the default encoding.

The only real escaping what's there is for entering the string ending quotes as a character which need to be duplicated to be not recognized as string ending.

Therefore you need to define what you needed, like this:
.for i = 0, i < 256, i += 1
.edef format("\x%02x", i), i
.next
Then you can use them as expected:
>1000	f1 48 45 4c 4c 4f 20 f7		.null "\xf1hello \xf7world"
>1008	57 4f 52 4c 44 00

You may adjust the loop to only generate a subset or add '.edef "\r", 13' and others. Creating a new encoding definition from scratch is not needed, it's fine just to add them to the default.

Older versions need "i = i + 1" instead of "i += 1", but I think you're on trunk so I wrote it accordingly ;)
2017-01-16 20:15
Compyx

Registered: Jan 2005
Posts: 211
Alright, thanks, that will work.

Didn't know I could loop over these .edef statements, In that case it's real easy.

And yes, I use trunk, so `i += 1` works fine, thanks for adding that, the old `i = i + 1` looked very BASIC-ish.
Of course `i++` would be even more hard core :)
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
bugjam
SigmaZeven/Alpha Fli..
redcrab/G★P
Alakran_64
Moloch/TRIAD
fieserWolF/Abyss-Con..
tlr
Joodas/Albion Crew
Zyron/GeNos¤ProjecTary
E$G/I-IokutO ForcE
alterus
Guests online: 47
Top Demos
1 Uncensored  (9.7)
2 Edge of Disgrace  (9.7)
3 The Shores of Reflec..  (9.7)
4 Coma Light 13  (9.6)
5 Lunatico  (9.6)
6 Comaland 100%  (9.6)
7 Incoherent Nightmare  (9.5)
8 Wonderland XII  (9.5)
9 Comaland  (9.5)
10 Wonderland XIII  (9.5)
Top onefile Demos
1 Dawnfall V1.1  (9.5)
2 Daah, Those Acid Pil..  (9.4)
3 SidRok  (9.4)
4 Treu Love [reu]  (9.4)
5 Tunnel Vision  (9.3)
6 Dawnfall  (9.3)
7 One-Der  (9.2)
8 Globe 2016 [reu]  (9.2)
9 Hardware Accelerated..  (9.2)
10 Safe VSP  (9.1)
Top Groups
1 Booze Design  (9.4)
2 Oxyron  (9.4)
3 Censor Design  (9.4)
4 Crest  (9.3)
5 SHAPE  (9.2)
Top Mega Swappers
1 Nightshade  (9.4)
2 Aslive  (9.3)
3 Calypso  (9.2)
4 Dishy  (9.0)
5 R.C.S.  (8.8)

Home - Disclaimer
Copyright © No Name 2001-2017
Page generated in: 0.23 sec.