Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
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: 268
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: 4065
soci usually hangs around and will fill you in soon.
2017-01-16 18:21
Compyx

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

Registered: Sep 2003
Posts: 357
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: 268
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
Squad333
Fred/Channel 4
deizi
Guests online: 34
Top Demos
1 Uncensored  (9.7)
2 Edge of Disgrace  (9.7)
3 Coma Light 13  (9.6)
4 The Shores of Reflec..  (9.6)
5 Lunatico  (9.6)
6 Comaland 100%  (9.5)
7 Incoherent Nightmare  (9.5)
8 Quad Core 100%  (9.5)
9 Wonderland XII  (9.5)
10 Comaland  (9.5)
Top onefile Demos
1 Pandemoniac Part 2 o..  (9.6)
2 Field Sort  (9.6)
3 Dawnfall V1.1  (9.5)
4 Daah, Those Acid Pil..  (9.5)
5 Treu Love [reu]  (9.4)
6 Dawnfall  (9.2)
7 Veterans of Style  (9.2)
8 KAOS 64  (9.2)
9 One-Der  (9.2)
10 Game of Thrones [2sid]  (9.2)
Top Groups
1 Blazon  (9.5)
2 Booze Design  (9.4)
3 Censor Design  (9.4)
4 Oxyron  (9.4)
5 Crest  (9.3)
Top Graphicians
1 Mirage  (9.8)
2 Archmage  (9.7)
3 Carrion  (9.7)
4 Veto  (9.7)
5 DocJM  (9.7)

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