English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 18 February 2014, 14:42   #1
AGS
XoXo/Tasko Developer
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 46
Posts: 450
Happy Backslash Problem

Hi,

this is supposed to be an ascii string:

dc.b "\uXoXo Usage and Behaviour\x",$a,$a


And when I type it in the CLI then it looks exactly the same. But in my Program the Result is this:

UXoXo Usage and BehaviourX


It is a text-styling function. When I replace the

cmp.b "\"

by a

cmp.b "/"

and write "/" as the 'escape char' in the text, everything works fine and I get an underlined text (/u). But when I use "\" as escape char I get caps. Why? Does anybody know how to solve this? (a also tried to use #92, still didn't work)

Used Geany/linux as texteditor with document encoding "no encoding". I loaded the text into a hex editor and saw, that the ascii-code of the "\" is really 92, which is correct.

Last edited by AGS; 18 February 2014 at 14:51.
AGS is offline  
Old 18 February 2014, 15:42   #2
BigFan
Registered User

BigFan's Avatar
 
Join Date: Feb 2014
Location: Germany
Posts: 261
Afaik, "\u" is for unicode output. Lower u for 4 digits and capital for 8.

But i am c-coder, no assembler, so maybe i'm wrong.

cheers
BigFan is offline  
Old 18 February 2014, 16:53   #3
matthey
Banned
 
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
@AGS
Which assembler are you using? The '\' character starts an escape sequence with some assemblers while a '/' should do nothing and be treated as normal text. Vasm has the -noesc option to turn off interpretation of '\' as the start of an escape sequence and treat it as a normal ASCII character.
matthey is offline  
Old 19 February 2014, 10:04   #4
AGS
XoXo/Tasko Developer
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 46
Posts: 450
I use phxass. I just checked the contents of my assembled file and found that there are really a caps X and a caps U in it. So the assembler has understood the \ as start of an escape sequence.
AGS is offline  
Old 19 February 2014, 13:38   #5
phx
Natteravn

phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 1,913
Unfortunately PhxAss interprets an escape character in strings similar to a C compiler (refer to the "Expressions" chapter in PhxAss.guide). And even vasm inherited this feature in its default mode (but can be disabled).

Today I would say that this was a fault as it causes much more trouble than it has advantages. An assembler should not care about such characters.

You can fix your source like this:
Code:
    dc.b $5c,"uXoXo Usage and Behaviour",$5c,x",$a,$a
phx is offline  
Old 19 February 2014, 14:19   #6
AGS
XoXo/Tasko Developer
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 46
Posts: 450
That works. However I think I can 'fix' phxass. There are only three occurences of $005c in the code, which may be a cmp.b #$5c,something. Any recommendations which one to nop out or so?

ps: one of the $5c belongs to a lea $52(ax),blah. So there are only 2 occurences of interest. One of them might be for parsing macro definitions, where a \ also plays a role. The other may be the one I am looking for. The code around them is:

1

cmp.b #$5c,-2(a2)
beq.s ...
cmp.b (a0),d2
beq.s ...


2

cmp.b #$5c,(a2)
bne.s ...
cmp.b #$2e,1(a2)
bne.s ...


The #$2e would be the dot character (".").

Last edited by AGS; 19 February 2014 at 14:33.
AGS is offline  
Old 19 February 2014, 17:07   #7
phx
Natteravn

phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 1,913
Quote:
Originally Posted by AGS View Post
There are only three occurences of $005c in the code, which may be a cmp.b #$5c,something.
There must be more. Did you search for $005c? I know several places where I loaded the '\' character with MOVEQ.


Quote:
Any recommendations which one to nop out or so?
It is not so easy. Especially when '\' is loaded into a register and checked much later.
Code:
frank@tethys grep ESCSYM *.asm
AssCode.asm:    moveq   #ESCSYM,d6
AssCode.asm:    moveq   #ESCSYM,d3
AssCode.asm:    moveq   #ESCSYM,d3
Assemble.asm:   moveq   #ESCSYM,d2
Assemble.asm:   cmp.b   #ESCSYM,-2(a1)          ; war jedoch nur ein \" oder \' ?
Assemble.asm:   moveq   #ESCSYM,d0
Assemble.asm:   cmp.b   #ESCSYM,(a2)            ; <symbol>\<.local> ?
Assemble.asm:   moveq   #ESCSYM,d3
Quote:
cmp.b #$5c,-2(a2)
beq.s ...
cmp.b (a0),d2
beq.s ...
That's a test while parsing a string in an operand. When I found a ' or " character this code checks whether the quote was preceded by an escape character.


Quote:
cmp.b #$5c,(a2)
bne.s ...
cmp.b #$2e,1(a2)
bne.s ...
That's the check for <global>\<.local> symbols.

I should rather add a new option to PhxAss which disables escape characters. Maybe I find some time for it...
phx is offline  
Old 19 February 2014, 17:12   #8
AGS
XoXo/Tasko Developer
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 46
Posts: 450
Would be very appreciated. If adding an option is too much work I would also be happy with just replacing the ESCSYM by "|" for now. Or rather %. Special quick version just for me?

Last edited by AGS; 19 February 2014 at 17:17.
AGS is offline  
Old 19 February 2014, 18:04   #9
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 3,191
It seems you can use two backslashes to tell PhxAss to insert a single backslash in the output. I'm not sure how compatible that is between different assemblers, but if you only use PhxAss try this:
dc.b "blah\\blah\\blah"
which assembles to give:
blah\blah\blah
mark_k is offline  
Old 19 February 2014, 18:26   #10
AGS
XoXo/Tasko Developer
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 46
Posts: 450
Worx. Maybe the escape sequences are not that bad at all. If I can write \n instead of ",$a," it's less to type.
AGS is offline  
Old 19 February 2014, 19:37   #11
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 3,191
Yes it's quite C-like, compare with the possible C escape sequences. A quick test reveals that PhxAss doesn't implement the C \a (alarm/bell, $07) , \v (vertical tab), octal (\nnn where n are octal digits), hex (\xNN) or Unicode (\uNNNN). But it does implement \0, \" and \' (as well as \? but there's not much point using that when you can just type ?).

For example
dc.b "This is \'single-quoted text\' and this is \"double-quoted text\" and the string is zero-terminated.\0"
mark_k is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mike the Magic Dragon: in-game problem or WinUAE problem? petran support.WinUAE 19 13 May 2021 20:26
aspi problem (was: auto resize problem) Kyon support.WinUAE 34 31 May 2009 16:56
Problem with Kickstarts [rare problem with faulty scripts in early v1.1 release] Topgun project.MAGE 14 08 June 2006 22:19

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 20:23.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Page generated in 0.08667 seconds with 15 queries