Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user maak ! (Registered 2024-04-18) 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: 5017
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: 473
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
iAN CooG/HVSC
sebalozlepsi
JEZ
Higgie/Kraze/Onslaught
da Blondie/Resource
Sentinel/Excess/TREX
mutetus/Ald ^ Ons
Viti/Hokuto Force
Mihai
Guests online: 128
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 The Ghost  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.9)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 Rainbow Connection  (9.5)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Onscreen 5k  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Coders
1 Axis  (9.8)
2 Graham  (9.8)
3 Lft  (9.8)
4 Crossbow  (9.8)
5 HCL  (9.8)

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