Jump to content

Ansi C Escape Sequences Not Fully Implemented


Recommended Posts

Bug description:

Partial implementation of Ansi C escape sequences.

 

Partial implementation of Ansi C escape sequences.

 

Ansi C defines the following escape sequences that can be used within strings:

\0 - 0x00 - null

\a - 0x07 - Alert = Produces an audible or visible alert.

\b - 0x08 - Backspace = Moves the cursor back one position (non-destructive).

\f - 0x0c - Form Feed = Moves the cursor to the first position of the next page.

\n - 0x0a - New Line = Moves the cursor to the first position of the next line.

\r - 0x0d - Carriage Return = Moves the cursor to the first position of the current line.

\t - 0x09 - Horizontal Tab = Moves the cursor to the next horizontal tabular position.

\v - 0x0b- Vertical Tab = Moves the cursor to the next vertical tabular position.

\\ - \ character

 

It seems like only some escape sequences are implemented. Even the ones implemented, are not always recognized in strings.

 

The following code:

    rom char* ESCAPE_TEST1 = "\0\a\b\f\n\r\t\v";    //Does not work
   rom char* ESCAPE_TEST2 = "\0\r\n";                 //OK
   char c1 = ESCAPE_TEST1[0];
   char c2 = ESCAPE_TEST2[0];

 

Generates the following in memory:

label4026531872
RETLW 0x00
RETLW 0x5C
RETLW 0x61
RETLW 0x5C
RETLW 0x62
RETLW 0x5C
RETLW 0x66
RETLW 0x5C
RETLW 0x6E
RETLW 0x5C
RETLW 0x72
RETLW 0x5C
RETLW 0x74
RETLW 0x5C
RETLW 0x76
RETLW 0x00
label4026531873
RETLW 0x00
RETLW 0x0D
RETLW 0x0A
RETLW 0x00

 

Seems like escape sequences in #pragma DATA strings are not recognized at all. The following code:

#pragma DATA 0x200, "\0\a\b\f\n\r\t\v"
#pragma DATA 0x300, "\0\r\n"

 

Generates the following in memory:

 ORG 0x00000200
DW 0x005C
DW 0x0030
DW 0x005C
DW 0x0061
DW 0x005C
DW 0x0062
DW 0x005C
DW 0x0066
DW 0x005C
DW 0x006E
DW 0x005C
DW 0x0072
DW 0x005C
DW 0x0074
DW 0x005C
DW 0x0076
DW 0x0000
ORG 0x00000300
DW 0x005C
DW 0x0030
DW 0x005C
DW 0x0072
DW 0x005C
DW 0x006E
DW 0x0000

 

Is the problem 100% reproduceable:

Yes

 

 

IDE version: SourceBoost IDE version

Compiler: BoostC

Compiler version: V6.14

Target device: PIC16f689

OS: Windows 2000

[/CODE][CODE][CODE]asdf

Link to post
Share on other sites

Forgot some escape codes there. The full list seems to be:

 

Escape Sequences

\\ - 0x5c - Backslash

\' - 0x27 - Single Quote (not sure if it is hex 27 ???)

\" - 0x22 - Double Quote (not sure if it is hex 22 ???)

\? - 0x3f - Question Mark

\0 - 0x00 - null

\a - 0x07 - Alert = Produces an audible or visible alert.

\b - 0x08 - Backspace = Moves the cursor back one position (non-destructive).

\f - 0x0c - Form Feed = Moves the cursor to the first position of the next page.

\n - 0x0a - New Line = Moves the cursor to the first position of the next line.

\r - 0x0d - Carriage Return = Moves the cursor to the first position of the current line.

\t - 0x09 - Horizontal Tab = Moves the cursor to the next horizontal tabular position.

\v - 0x0b- Vertical Tab = Moves the cursor to the next vertical tabular position.

 

Numeric Escape Sequences

\nnn - n = octal digit, 8 bit

\xnn - n = hexadecimal digit, 8 bit

\Xnn - n = hexadecimal digit, 8 bit

\unnnn - n = hexadecimal digit, 16 bit

\Unnnnnnnn - n = hexadecimal digit, 32 bit

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...