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 15:22

Registered: Jan 2005
Posts: 330
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

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

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

Registered: Sep 2003
Posts: 385
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
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

Registered: Jan 2005
Posts: 330
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
Users Online
Knight Rider/Excess
Xiny6581/Dees Produc..
Guests online: 42
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 Comaland 100%  (9.6)
6 We Come in Peace  (9.6)
7 Lunatico  (9.6)
8 Incoherent Nightmare  (9.5)
9 Wonderland XII  (9.5)
10 Wonderland XIII  (9.5)
Top onefile Demos
1 FMX Music Demo  (9.5)
2 Pandemoniac Part 2 o..  (9.5)
3 Daah, Those Acid Pil..  (9.5)
4 Dawnfall V1.1  (9.5)
5 Treu Love [reu]  (9.5)
6 In Memoriam BHF  (9.5)
7 Merry Xmas 2017  (9.4)
8 Dawnfall  (9.4)
9 SWiRL  (9.4)
10 Synthesis  (9.4)
Top Groups
1 Oxyron  (9.4)
2 Booze Design  (9.4)
3 Censor Design  (9.4)
4 Finnish Gold  (9.4)
5 Crest  (9.3)
Top NTSC-Fixers
1 Pudwerx  (10)
2 Horizon  (9.8)
3 The Mind Slayer  (9.7)
4 The Shadow  (9.7)
5 Stormbringer  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2018
Page generated in: 0.05 sec.