Skip to content

Commit e22f998

Browse files
committed
Use raw string literals R"()"
1 parent 9c37bdf commit e22f998

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1402
-1266
lines changed

driver/asm_formatter.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ StrBuffer &AsmFormatter::getLine(StrBuffer &out) {
7777
}
7878
out.rtext_P(PSTR(": error: ")).rtext_P(_error.errorText_P());
7979
if (_error.errorAt() && *_error.errorAt())
80-
out.rtext_P(PSTR(": \"")).rtext(_error.errorAt()).rletter('"');
80+
out.rtext_P(PSTR(R"(: ")")).rtext(_error.errorAt()).rletter('"');
8181
_nextLine = -1;
8282
} else {
8383
if (_nextLine < 0)

driver/dis_formatter.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void DisFormatter::formatComment(StrBuffer &out) {
9797
void DisFormatter::formatError(StrBuffer &out) {
9898
out.rtext(_inputName).rtext_P(PSTR(": error: ")).rtext_P(_error.errorText_P());
9999
if (*_error.errorAt())
100-
out.rtext_P(PSTR(": \"")).rtext(_error.errorAt()).rletter('"');
100+
out.rtext_P(PSTR(R"(: ")")).rtext(_error.errorAt()).rletter('"');
101101
}
102102

103103
void DisFormatter::formatLine(StrBuffer &out, int &next) {

test/driver/test_asm_formatter.cpp

+248-233
Large diffs are not rendered by default.

test/driver/test_formatter_cdp1802.cpp

+46-40
Original file line numberDiff line numberDiff line change
@@ -32,37 +32,41 @@ void test_asm_cdp1802() {
3232
driver.setUpperHex(false);
3333

3434
ASM("cdp1804",
35-
" cpu cdp1804\n"
36-
".. comment line\n"
37-
" org x'abcd'\n"
38-
" scal 3, #8485\n"
39-
"label: dc a(label)\n"
40-
"symbol = x'1234'\n"
41-
" ldi a.0(symbol)\n"
42-
" ldi a.1(symbol)\n"
43-
" lbr x'ab23'\n",
44-
" 0 : cpu cdp1804\n"
45-
" 0 : .. comment line\n"
46-
" abcd : org x'abcd'\n"
47-
" abcd : 68 83 84 85 scal 3, #8485\n"
48-
" abd1 : ab d1 label: dc a(label)\n"
49-
" abd3 : =1234 symbol = x'1234'\n"
50-
" abd3 : f8 34 ldi a.0(symbol)\n"
51-
" abd5 : f8 12 ldi a.1(symbol)\n"
52-
" abd7 : c0 ab 23 lbr x'ab23'\n");
35+
R"( cpu cdp1804
36+
.. comment line
37+
org x'abcd'
38+
scal 3, #8485
39+
label: dc a(label)
40+
symbol = x'1234'
41+
ldi a.0(symbol)
42+
ldi a.1(symbol)
43+
lbr x'ab23'
44+
)",
45+
R"( 0 : cpu cdp1804
46+
0 : .. comment line
47+
abcd : org x'abcd'
48+
abcd : 68 83 84 85 scal 3, #8485
49+
abd1 : ab d1 label: dc a(label)
50+
abd3 : =1234 symbol = x'1234'
51+
abd3 : f8 34 ldi a.0(symbol)
52+
abd5 : f8 12 ldi a.1(symbol)
53+
abd7 : c0 ab 23 lbr x'ab23'
54+
)");
5355

5456
driver.setOption("use-register", "on");
5557
driver.setOption("smart-branch", "on");
5658

5759
ASM("cdp1804",
58-
" org x'abcd'\n"
59-
" scal r3, x'8485'\n"
60-
" lbr x'ab23'\n"
61-
" br x'ac23'\n",
62-
" abcd : org x'abcd'\n"
63-
" abcd : 68 83 84 85 scal r3, x'8485'\n"
64-
" abd1 : 30 23 lbr x'ab23'\n"
65-
" abd3 : c0 ac 23 br x'ac23'\n");
60+
R"( org x'abcd'
61+
scal r3, x'8485'
62+
lbr x'ab23'
63+
br x'ac23'
64+
)",
65+
R"( abcd : org x'abcd'
66+
abcd : 68 83 84 85 scal r3, x'8485'
67+
abd1 : 30 23 lbr x'ab23'
68+
abd3 : c0 ac 23 br x'ac23'
69+
)");
6670
}
6771

6872
void test_dis_cdp1802() {
@@ -72,20 +76,22 @@ void test_dis_cdp1802() {
7276
EQ("use-register", OK, driver.setOption("use-register", "on"));
7377

7478
DIS8("cdp1804", 0xabcd,
75-
" cpu 1804\n"
76-
" org x'abcd'\n"
77-
" scal r3, x'8485'\n"
78-
".. test.bin: error: Unknown instruction\n"
79-
".. abd1 : 68 0f\n"
80-
" lbr x'ab23'\n"
81-
" br x'ab23'\n",
82-
" 0 : cpu 1804\n"
83-
" abcd : org x'abcd'\n"
84-
" abcd : 68 83 84 85 scal r3, x'8485'\n"
85-
"test.bin: error: Unknown instruction\n"
86-
" abd1 : 68 0f\n"
87-
" abd3 : c0 ab 23 lbr x'ab23'\n"
88-
" abd6 : 30 23 br x'ab23'\n",
79+
R"( cpu 1804
80+
org x'abcd'
81+
scal r3, x'8485'
82+
.. test.bin: error: Unknown instruction
83+
.. abd1 : 68 0f
84+
lbr x'ab23'
85+
br x'ab23'
86+
)",
87+
R"( 0 : cpu 1804
88+
abcd : org x'abcd'
89+
abcd : 68 83 84 85 scal r3, x'8485'
90+
test.bin: error: Unknown instruction
91+
abd1 : 68 0f
92+
abd3 : c0 ab 23 lbr x'ab23'
93+
abd6 : 30 23 br x'ab23'
94+
)",
8995
0x68, 0x83, 0x84, 0x85, 0x68, 0x0f, 0xc0, 0xab, 0x23, 0x30, 0x23);
9096
}
9197

test/driver/test_formatter_f3850.cpp

+49-44
Original file line numberDiff line numberDiff line change
@@ -31,38 +31,41 @@ void test_asm_f3850() {
3131

3232
TestReader inc("data/da.inc");
3333
sources.add(inc);
34-
inc.add(" rs 3\n" // RS allocates spaces
35-
" da H'1234', label1, H'9ABC'\n" // DA generates words
36-
" dc 'a,',',, '/, ' , 0\n" // DC can omit closing quote
37-
" dc c'a',',, c'bc''de', 0\n" // DC can accept string
38-
" dc C'A', #', C'C'+h'80'\n"); // C'c' requires surrounding quotes
34+
inc.add(R"( rs 3 ; RS allocates spaces
35+
da H'1234', label1, H'9ABC' ; DA generates words
36+
dc 'a,',',, '/, ' , 0 ; DC can omit closing quote
37+
dc c'a',',, c'bc''de', 0 ; DC can accept string
38+
dc C'A', #', C'C'+h'80' ; C'c' requires surrounding quotes
39+
)");
3940

4041
ASM("f3850",
41-
" cpu F3850\n"
42-
"* comment line\n"
43-
" org H'7BCD'\n"
44-
"label1 equ H'7BD0'\n"
45-
" clr\n"
46-
" lr a, j\n"
47-
" ds 10\n" // DS is the instruction of F3850
48-
" bp label1\n"
49-
" include \"data/da.inc\"\n",
50-
" 0 : cpu F3850\n"
51-
" 0 : * comment line\n"
52-
" 7BCD : org H'7BCD'\n"
53-
" 7BCD : =7BD0 label1 equ H'7BD0'\n"
54-
" 7BCD : 70 clr\n"
55-
" 7BCE : 49 lr a, j\n"
56-
" 7BCF : 3A ds 10\n"
57-
" 7BD0 : 81 FF bp label1\n"
58-
" 7BD2 : include \"data/da.inc\"\n"
59-
"(1) 7BD2 : rs 3\n"
60-
"(1) 7BD5 : 12 34 7B D0 9A BC da H'1234', label1, H'9ABC'\n"
61-
"(1) 7BDB : 61 2C 2C 2F 2C 20 dc 'a,',',, '/, ' , 0\n"
62-
" 7BE1 : 00\n"
63-
"(1) 7BE2 : 61 2C 62 63 27 64 dc c'a',',, c'bc''de', 0\n"
64-
" 7BE8 : 65 00\n"
65-
"(1) 7BEA : 41 27 C3 dc C'A', #', C'C'+h'80'\n");
42+
R"( cpu F3850
43+
* comment line
44+
org H'7BCD'
45+
label1 equ H'7BD0'
46+
clr
47+
lr a, j
48+
ds 10 ; DS is instruction
49+
bp label1
50+
include "data/da.inc"
51+
)",
52+
R"( 0 : cpu F3850
53+
0 : * comment line
54+
7BCD : org H'7BCD'
55+
7BCD : =7BD0 label1 equ H'7BD0'
56+
7BCD : 70 clr
57+
7BCE : 49 lr a, j
58+
7BCF : 3A ds 10 ; DS is instruction
59+
7BD0 : 81 FF bp label1
60+
7BD2 : include "data/da.inc"
61+
(1) 7BD2 : rs 3 ; RS allocates spaces
62+
(1) 7BD5 : 12 34 7B D0 9A BC da H'1234', label1, H'9ABC' ; DA generates words
63+
(1) 7BDB : 61 2C 2C 2F 2C 20 dc 'a,',',, '/, ' , 0 ; DC can omit closing quote
64+
7BE1 : 00
65+
(1) 7BE2 : 61 2C 62 63 27 64 dc c'a',',, c'bc''de', 0 ; DC can accept string
66+
7BE8 : 65 00
67+
(1) 7BEA : 41 27 C3 dc C'A', #', C'C'+h'80' ; C'c' requires surrounding quotes
68+
)");
6669
}
6770

6871
void test_dis_f3850() {
@@ -71,20 +74,22 @@ void test_dis_f3850() {
7174
driver.setUpperHex(false);
7275

7376
DIS8("f3850", 0x7bcd,
74-
" cpu 3850\n"
75-
" org h'7bcd'\n"
76-
" clr\n"
77-
" lr a, j\n"
78-
" bp h'7bcf'\n"
79-
"* test.bin: error: Unknown instruction\n"
80-
"* 7bd1 : 2e\n",
81-
" 0 : cpu 3850\n"
82-
" 7bcd : org h'7bcd'\n"
83-
" 7bcd : 70 clr\n"
84-
" 7bce : 49 lr a, j\n"
85-
" 7bcf : 81 ff bp h'7bcf'\n"
86-
"test.bin: error: Unknown instruction\n"
87-
" 7bd1 : 2e\n",
77+
R"( cpu 3850
78+
org h'7bcd'
79+
clr
80+
lr a, j
81+
bp h'7bcf'
82+
* test.bin: error: Unknown instruction
83+
* 7bd1 : 2e
84+
)",
85+
R"( 0 : cpu 3850
86+
7bcd : org h'7bcd'
87+
7bcd : 70 clr
88+
7bce : 49 lr a, j
89+
7bcf : 81 ff bp h'7bcf'
90+
test.bin: error: Unknown instruction
91+
7bd1 : 2e
92+
)",
8893
0x70, 0x49, 0x81, 0xFF, 0x2E);
8994
}
9095

test/driver/test_formatter_i8048.cpp

+24-20
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,18 @@ void test_asm_i8048() {
3232
driver.setUpperHex(false);
3333

3434
ASM("i8039",
35-
" cpu i8039\n"
36-
"; comment line\n"
37-
" org 0bcdh\n"
38-
"data1: equ 8ah\n"
39-
" orl p1, #data1\n",
40-
" 0 : cpu i8039\n"
41-
" 0 : ; comment line\n"
42-
" bcd : org 0bcdh\n"
43-
" bcd : =8a data1: equ 8ah\n"
44-
" bcd : 89 8a orl p1, #data1\n");
35+
R"( cpu i8039
36+
; comment line
37+
org 0bcdh
38+
data1: equ 8ah
39+
orl p1, #data1
40+
)",
41+
R"( 0 : cpu i8039
42+
0 : ; comment line
43+
bcd : org 0bcdh
44+
bcd : =8a data1: equ 8ah
45+
bcd : 89 8a orl p1, #data1
46+
)");
4547
}
4648

4749
void test_dis_i8048() {
@@ -50,16 +52,18 @@ void test_dis_i8048() {
5052
driver.setUppercase(true);
5153

5254
DIS8("i8039", 0xbcd,
53-
" CPU 8039\n"
54-
" ORG 0BCDH\n"
55-
" ORL P1, #8AH\n"
56-
"; test.bin: error: Unknown instruction\n"
57-
"; BCF : 08\n",
58-
" 0 : CPU 8039\n"
59-
" BCD : ORG 0BCDH\n"
60-
" BCD : 89 8A ORL P1, #8AH\n"
61-
"test.bin: error: Unknown instruction\n"
62-
" BCF : 08\n",
55+
R"( CPU 8039
56+
ORG 0BCDH
57+
ORL P1, #8AH
58+
; test.bin: error: Unknown instruction
59+
; BCF : 08
60+
)",
61+
R"( 0 : CPU 8039
62+
BCD : ORG 0BCDH
63+
BCD : 89 8A ORL P1, #8AH
64+
test.bin: error: Unknown instruction
65+
BCF : 08
66+
)",
6367
0x89, 0x8A, 0x08);
6468
}
6569

test/driver/test_formatter_i8051.cpp

+36-32
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,30 @@ void test_asm_i8051() {
3333
driver.setOption("smart-branch", "on");
3434

3535
ASM("i8051",
36-
" cpu i8051\n"
37-
"; comment line\n"
38-
" org 0abcdh\n"
39-
"data1: equ 0b0h\n"
40-
" anl c, /data1.1\n"
41-
" ljmp label2\n"
42-
" lcall label2\n"
43-
" ajmp label3\n"
44-
" acall label3\n"
45-
"label2: equ 0ac00h\n"
46-
"label3: equ 0b000h\n",
47-
" 0 : cpu i8051\n"
48-
" 0 : ; comment line\n"
49-
" abcd : org 0abcdh\n"
50-
" abcd : =b0 data1: equ 0b0h\n"
51-
" abcd : b0 b1 anl c, /data1.1\n"
52-
" abcf : 81 00 ljmp label2\n"
53-
" abd1 : 91 00 lcall label2\n"
54-
" abd3 : 02 b0 00 ajmp label3\n"
55-
" abd6 : 12 b0 00 acall label3\n"
56-
" abd9 : =ac00 label2: equ 0ac00h\n"
57-
" abd9 : =b000 label3: equ 0b000h\n");
36+
R"( cpu i8051
37+
; comment line
38+
org 0abcdh
39+
data1: equ 0b0h
40+
anl c, /data1.1
41+
ljmp label2
42+
lcall label2
43+
ajmp label3
44+
acall label3
45+
label2: equ 0ac00h
46+
label3: equ 0b000h
47+
)",
48+
R"( 0 : cpu i8051
49+
0 : ; comment line
50+
abcd : org 0abcdh
51+
abcd : =b0 data1: equ 0b0h
52+
abcd : b0 b1 anl c, /data1.1
53+
abcf : 81 00 ljmp label2
54+
abd1 : 91 00 lcall label2
55+
abd3 : 02 b0 00 ajmp label3
56+
abd6 : 12 b0 00 acall label3
57+
abd9 : =ac00 label2: equ 0ac00h
58+
abd9 : =b000 label3: equ 0b000h
59+
)");
5860
}
5961

6062
void test_dis_i8051() {
@@ -63,16 +65,18 @@ void test_dis_i8051() {
6365
driver.setUpperHex(false);
6466

6567
DIS8("i8051", 0xabcd,
66-
" cpu 8051\n"
67-
" org 0abcdh\n"
68-
" anl c, /0b0h.1\n"
69-
"; test.bin: error: Unknown instruction\n"
70-
"; abcf : a5\n",
71-
" 0 : cpu 8051\n"
72-
" abcd : org 0abcdh\n"
73-
" abcd : b0 b1 anl c, /0b0h.1\n"
74-
"test.bin: error: Unknown instruction\n"
75-
" abcf : a5\n",
68+
R"( cpu 8051
69+
org 0abcdh
70+
anl c, /0b0h.1
71+
; test.bin: error: Unknown instruction
72+
; abcf : a5
73+
)",
74+
R"( 0 : cpu 8051
75+
abcd : org 0abcdh
76+
abcd : b0 b1 anl c, /0b0h.1
77+
test.bin: error: Unknown instruction
78+
abcf : a5
79+
)",
7680
0xb0, 0xb1, 0xa5);
7781
}
7882

0 commit comments

Comments
 (0)