Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


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

Registered: Jan 2005
Posts: 631
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 17:00
Oswald

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

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

Registered: Sep 2003
Posts: 480
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 19:15
Compyx

Registered: Jan 2005
Posts: 631
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
wil
algorithm
Peacemaker/CENSOR/Hi..
Guests online: 108
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 No Listen  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Rainbow Connection  (9.5)
7 Dawnfall V1.1  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Triad  (9.3)
5 Censor Design  (9.3)
Top Fullscreen Graphicians
1 Joe  (9.7)
2 Sulevi  (9.6)
3 The Sarge  (9.6)
4 Veto  (9.6)
5 Facet  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.038 sec.