This file is indexed.

/usr/share/doc/cc65-doc/html/cc65.html is in cc65-doc 2.16-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
 <LINK REL="stylesheet" TYPE="text/css" HREF="doc.css">
 <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.72">
 <TITLE>cc65 Users Guide</TITLE>
</HEAD>
<BODY>
<H1>cc65 Users Guide</H1>

<H2>
<A HREF="mailto:uz@cc65.org">Ullrich von Bassewitz</A>,<BR>
<A HREF="mailto:gregdk@users.sf.net">Greg King</A></H2>2017-03-21
<HR>
<EM>cc65 is a C compiler for 6502 targets. It supports several 6502 based home
computers like the Commodore and Atari machines, but it is easily retargetable.</EM>
<HR>
<P>
<H2><A NAME="toc1">1.</A> <A HREF="cc65.html#s1">Overview</A></H2>

<P>
<H2><A NAME="toc2">2.</A> <A HREF="cc65.html#s2">Usage</A></H2>

<UL>
<LI><A NAME="toc2.1">2.1</A> <A HREF="cc65.html#ss2.1">Command line option overview</A>
<LI><A NAME="toc2.2">2.2</A> <A HREF="cc65.html#ss2.2">Command line options in detail</A>
</UL>
<P>
<H2><A NAME="toc3">3.</A> <A HREF="cc65.html#s3">Input and output</A></H2>

<P>
<H2><A NAME="toc4">4.</A> <A HREF="cc65.html#s4">Differences to the ISO standard</A></H2>

<P>
<H2><A NAME="toc5">5.</A> <A HREF="cc65.html#s5">Extensions</A></H2>

<P>
<H2><A NAME="toc6">6.</A> <A HREF="cc65.html#s6">Predefined macros</A></H2>

<P>
<H2><A NAME="toc7">7.</A> <A HREF="cc65.html#s7">#pragmas</A></H2>

<UL>
<LI><A NAME="toc7.1">7.1</A> <A HREF="cc65.html#ss7.1"><CODE>#pragma allow-eager-inline ([push,] on|off)</CODE></A>
<LI><A NAME="toc7.2">7.2</A> <A HREF="cc65.html#ss7.2"><CODE>#pragma bss-name ([push,] &lt;name&gt;)</CODE></A>
<LI><A NAME="toc7.3">7.3</A> <A HREF="cc65.html#ss7.3"><CODE>#pragma charmap (&lt;index&gt;, &lt;code&gt;)</CODE></A>
<LI><A NAME="toc7.4">7.4</A> <A HREF="cc65.html#ss7.4"><CODE>#pragma check-stack ([push,] on|off)</CODE></A>
<LI><A NAME="toc7.5">7.5</A> <A HREF="cc65.html#ss7.5"><CODE>#pragma code-name ([push,] &lt;name&gt;)</CODE></A>
<LI><A NAME="toc7.6">7.6</A> <A HREF="cc65.html#ss7.6"><CODE>#pragma codesize ([push,] &lt;int&gt;)</CODE></A>
<LI><A NAME="toc7.7">7.7</A> <A HREF="cc65.html#ss7.7"><CODE>#pragma data-name ([push,] &lt;name&gt;)</CODE></A>
<LI><A NAME="toc7.8">7.8</A> <A HREF="cc65.html#ss7.8"><CODE>#pragma inline-stdfuncs ([push,] on|off)</CODE></A>
<LI><A NAME="toc7.9">7.9</A> <A HREF="cc65.html#ss7.9"><CODE>#pragma local-strings ([push,] on|off)</CODE></A>
<LI><A NAME="toc7.10">7.10</A> <A HREF="cc65.html#ss7.10"><CODE>#pragma optimize ([push,] on|off)</CODE></A>
<LI><A NAME="toc7.11">7.11</A> <A HREF="cc65.html#ss7.11"><CODE>#pragma rodata-name ([push,] &lt;name&gt;)</CODE></A>
<LI><A NAME="toc7.12">7.12</A> <A HREF="cc65.html#ss7.12"><CODE>#pragma regvaraddr ([push,] on|off)</CODE></A>
<LI><A NAME="toc7.13">7.13</A> <A HREF="cc65.html#ss7.13"><CODE>#pragma register-vars ([push,] on|off)</CODE></A>
<LI><A NAME="toc7.14">7.14</A> <A HREF="cc65.html#ss7.14"><CODE>#pragma signed-chars ([push,] on|off)</CODE></A>
<LI><A NAME="toc7.15">7.15</A> <A HREF="cc65.html#ss7.15"><CODE>#pragma static-locals ([push,] on|off)</CODE></A>
<LI><A NAME="toc7.16">7.16</A> <A HREF="cc65.html#ss7.16"><CODE>#pragma warn (name, [push,] on|off)</CODE></A>
<LI><A NAME="toc7.17">7.17</A> <A HREF="cc65.html#ss7.17"><CODE>#pragma writable-strings ([push,] on|off)</CODE></A>
<LI><A NAME="toc7.18">7.18</A> <A HREF="cc65.html#ss7.18"><CODE>#pragma zpsym (&lt;name&gt;)</CODE></A>
</UL>
<P>
<H2><A NAME="toc8">8.</A> <A HREF="cc65.html#s8">Register variables</A></H2>

<P>
<H2><A NAME="toc9">9.</A> <A HREF="cc65.html#s9">Inline assembler</A></H2>

<P>
<H2><A NAME="toc10">10.</A> <A HREF="cc65.html#s10">Implementation-defined behavior</A></H2>

<P>
<H2><A NAME="toc11">11.</A> <A HREF="cc65.html#s11">Copyright</A></H2>


<HR>
<H2><A NAME="s1">1.</A> <A HREF="#toc1">Overview</A></H2>


<P>cc65 was originally a C compiler for the Atari 8-bit machines written by
John R. Dunning. In prior releases I've described the compiler by listing
up the changes made by me. I have made many more changes in the meantime
(and rewritten major parts of the compiler), so I will no longer do that,
since the list would be too large and of no use to anyone. Instead I will
describe the compiler in respect to the ANSI/ISO C standard.</P>
<P>There are separate documents named 
<A HREF="library.html">library.html</A> and 
<A HREF="funcref.html">funcref.html</A> that cover the library that is available for the compiler.
If you know C, and are interested in doing actual programming, the library
documentation is probably of much more use than this document.</P>
<P>If you need some hints for getting the best code out of the compiler, you
may have a look at 
<A HREF="coding.html">coding.html</A> which covers some code generation
issues.</P>



<H2><A NAME="s2">2.</A> <A HREF="#toc2">Usage</A></H2>


<P>The compiler translates C files into files containing assembly code that
may be translated by the ca65 macroassembler (for more information about
the assembler, have a look at 
<A HREF="ca65.html">ca65.html</A>).</P>


<H2><A NAME="ss2.1">2.1</A> <A HREF="#toc2.1">Command line option overview</A>
</H2>


<P>The compiler may be called as follows:</P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
---------------------------------------------------------------------------
Usage: cc65 [options] file
Short options:
  -Cl                           Make local variables static
  -Dsym[=defn]                  Define a symbol
  -E                            Stop after the preprocessing stage
  -I dir                        Set an include directory search path
  -O                            Optimize code
  -Oi                           Optimize code, inline more code
  -Or                           Enable register variables
  -Os                           Inline some standard functions
  -T                            Include source as comment
  -V                            Print the compiler version number
  -W warning[,...]              Suppress warnings
  -d                            Debug mode
  -g                            Add debug info to object file
  -h                            Help (this text)
  -j                            Default characters are signed
  -mm model                     Set the memory model
  -o name                       Name the output file
  -r                            Enable register variables
  -t sys                        Set the target system
  -v                            Increase verbosity

Long options:
  --add-source                  Include source as comment
  --all-cdecl                   Make functions default to __cdecl__
  --bss-name seg                Set the name of the BSS segment
  --check-stack                 Generate stack overflow checks
  --code-name seg               Set the name of the CODE segment
  --codesize x                  Accept larger code by factor x
  --cpu type                    Set cpu type (6502, 65c02)
  --create-dep name             Create a make dependency file
  --create-full-dep name        Create a full make dependency file
  --data-name seg               Set the name of the DATA segment
  --debug                       Debug mode
  --debug-info                  Add debug info to object file
  --debug-opt name              Debug optimization steps
  --dep-target target           Use this dependency target
  --disable-opt name            Disable an optimization step
  --eagerly-inline-funcs        Eagerly inline some known functions
  --enable-opt name             Enable an optimization step
  --help                        Help (this text)
  --include-dir dir             Set an include directory search path
  --inline-stdfuncs             Inline some standard functions
  --list-opt-steps              List all optimizer steps and exit
  --list-warnings               List available warning types for -W
  --local-strings               Emit string literals immediately
  --memory-model model          Set the memory model
  --register-space b            Set space available for register variables
  --register-vars               Enable register variables
  --rodata-name seg             Set the name of the RODATA segment
  --signed-chars                Default characters are signed
  --standard std                Language standard (c89, c99, cc65)
  --static-locals               Make local variables static
  --target sys                  Set the target system
  --verbose                     Increase verbosity
  --version                     Print the compiler version number
  --writable-strings            Make string literals writable
---------------------------------------------------------------------------
</PRE>
</CODE></BLOCKQUOTE>
</P>


<H2><A NAME="ss2.2">2.2</A> <A HREF="#toc2.2">Command line options in detail</A>
</H2>


<P>Here is a description of all the command line options:</P>
<P>
<DL>

<DT><B><CODE>--all-cdecl</CODE></B><DD>
<P>Tells the compiler that functions which aren't declared explicitly with
either the <CODE>__cdecl__</CODE> or <CODE>__fastcall__</CODE> calling conventions should
have the cdecl convention.  (Normally, functions that aren't variadic are
fast-called.)</P>

<P>
<A NAME="option-bss-name"></A> </P>
<DT><B><CODE>--bss-name seg</CODE></B><DD>
<P>Set the name of the bss segment. See also <CODE>
<A HREF="#pragma-bss-name">#pragma&nbsp;bss-name</A></CODE>.</P>

<P>
<A NAME="option-check-stack"></A> </P>
<DT><B><CODE>--check-stack</CODE></B><DD>
<P>Tells the compiler to generate code that checks for stack overflows. See
<CODE>
<A HREF="#pragma-check-stack">#pragma&nbsp;check-stack</A></CODE> for an
explanation of this feature.</P>

<P>
<A NAME="option-code-name"></A> </P>
<DT><B><CODE>--code-name seg</CODE></B><DD>
<P>Set the name of the code segment. See also <CODE>
<A HREF="#pragma-code-name">#pragma&nbsp;code-name</A></CODE></P>

<P>
<A NAME="option-codesize"></A> </P>
<DT><B><CODE>--codesize x</CODE></B><DD>
<P>This options allows finer control about speed vs. size decisions in the code
generation and optimization phases. It gives the allowed size increase
factor (in percent). The default is 100 when not using <CODE>-Oi</CODE> and 200 when
using <CODE>-Oi</CODE> (<CODE>-Oi</CODE> is the same as <CODE>-O --codesize&nbsp;200</CODE>).</P>

<P>
<A NAME="option--cpu"></A> </P>
<DT><B><CODE>--cpu CPU</CODE></B><DD>
<P>Set the CPU, the compiler generates code for. You may specify "6502" or
"65C02" as the CPU. The default depends on the selected target (see option
<CODE>
<A HREF="#option-t">-t</A></CODE>). It is the 6502 CPU for most targets or
if no target has been set. Specifying 65C02 will use a few 65C02
instructions when generating code. Don't expect too much from this option:
In most cases the difference in size and speed is just 1-2%.</P>

<P>
<A NAME="option-create-dep"></A> </P>
<DT><B><CODE>--create-dep name</CODE></B><DD>
<P>Tells the compiler to generate a file containing the dependency list for the
compiled module in makefile syntax. The output is written to a file with the
given name. The output does not include system include files (in angle
brackets).</P>

<P>
<A NAME="option-create-full-dep"></A> </P>
<DT><B><CODE>--create-full-dep name</CODE></B><DD>
<P>Tells the compiler to generate a file containing the dependency list for the
compiled module in makefile syntax. The output is written to a file with the
given name. The output does include system include files (in angle
brackets).</P>

<P>
<A NAME="option-data-name"></A> </P>
<DT><B><CODE>--data-name seg</CODE></B><DD>
<P>Set the name of the data segment. See also <CODE>
<A HREF="#pragma-data-name">#pragma&nbsp;data-name</A></CODE></P>


<DT><B><CODE>-d, --debug</CODE></B><DD>
<P>Enables debug mode, something that should not be needed for mere
mortals:-)</P>

<P>
<A NAME="option-dep-target"></A> </P>
<DT><B><CODE>--dep-target target</CODE></B><DD>
<P>When generating a dependency file, don't use the actual output file as the
target of the dependency, but the file specified with this option. The
option has no effect if neither <CODE>
<A HREF="#option-create-dep">--create-dep</A></CODE> nor <CODE>
<A HREF="#option-create-full-dep">--create-full-dep</A></CODE> is specified.</P>


<DT><B><CODE>-D sym[=definition]</CODE></B><DD>
<P>Define a macro on the command line. If no definition is given, the macro
is defined to the value "1".</P>


<DT><B><CODE>-g, --debug-info</CODE></B><DD>
<P>This will cause the compiler to insert a <CODE>.DEBUGINFO</CODE> command into the
generated assembler code. This will cause the assembler to include all
symbols in a special section in the object file.</P>

<P>
<A NAME="option-eagerly-inline-funcs"></A> </P>
<DT><B><CODE>--eagerly-inline-funcs</CODE></B><DD>
<P>Have the compiler eagerly inline these functions from the C library:
<UL>
<LI><CODE>memcpy()</CODE></LI>
<LI><CODE>memset()</CODE></LI>
<LI><CODE>strcmp()</CODE></LI>
<LI><CODE>strcpy()</CODE></LI>
<LI><CODE>strlen()</CODE></LI>
<LI>most of the functions declared in <CODE>&lt;ctype.h&gt;</CODE></LI>
</UL>
</P>
<P>Note: This has two consequences:
<UL>
<LI>You may not use names of standard C functions for your own functions.
If you do that, your program is not standard-compliant anyway; but,
using <CODE>--eagerly-inline-funcs</CODE> actually will break things.

</LI>
<LI>The inlined string and memory functions will not handle strings or
memory areas larger than 255 bytes.  Similarly, the inlined <CODE>is..()</CODE>
functions will not work with values outside the char. range (such as
<CODE>EOF</CODE>).

</LI>
</UL>
</P>
<P><CODE>--eagerly-inline-funcs</CODE> implies the <CODE>
<A HREF="#option-inline-stdfuncs">--inline-stdfuncs</A></CODE> command line option.</P>
<P>See also <CODE>
<A HREF="#pragma-allow-eager-inline">#pragma&nbsp;allow-eager-inline</A></CODE>.</P>


<DT><B><CODE>-h, --help</CODE></B><DD>
<P>Print the short option summary shown above.</P>

<P>
<A NAME="option-inline-stdfuncs"></A> </P>
<DT><B><CODE>--inline-stdfuncs</CODE></B><DD>
<P>Allow the compiler to inline some standard functions from the C library like
strlen.  This will not only remove the overhead for a function call, but will
make the code visible for the optimizer.  See also the <CODE>
<A HREF="#option-O">-Os</A></CODE> command line option and <CODE>
<A HREF="#pragma-inline-stdfuncs">#pragma&nbsp;inline-stdfuncs</A></CODE>.</P>

<P>
<A NAME="option-list-warnings"></A> </P>
<DT><B><CODE>--list-warnings</CODE></B><DD>
<P>List the names of warning types available for use with <CODE>
<A HREF="#option-W">-W</A></CODE>.</P>

<P>
<A NAME="option-local-strings"></A> </P>
<DT><B><CODE>--local-strings</CODE></B><DD>
<P>Emit string literals into the rodata segment as soon as they're encountered
in the source (even if you do nothing but get the sizeof those strings). The
default is to keep string literals until end of assembly, merge read only
literals if possible, and then output the literals into the data or rodata
segment that is active at that point. Use of this option prevents merging of
duplicate strings, but the options that change the name of one of the data
segments will work.</P>
<P>You can also use <CODE>
<A HREF="#pragma-local-strings">#pragma&nbsp;local-strings</A></CODE> for fine grained control.</P>


<DT><B><CODE>-o name</CODE></B><DD>
<P>Specify the name of the output file. If you don't specify a name, the
name of the C input file is used, with the extension replaced by ".s".</P>

<P>
<A NAME="option-register-vars"></A> </P>
<DT><B><CODE>-r, --register-vars</CODE></B><DD>
<P><CODE>-r</CODE> will make the compiler honor the <CODE>register</CODE> keyword. Local
variables may be placed in registers (which are actually zero page
locations). There is some overhead involved with register variables, since
the old contents of the registers must be saved and restored. Since register
variables are of limited use without the optimizer, there is also a combined
switch: <CODE>-Or</CODE> will enable both, the optimizer and register variables.</P>
<P>For more information about register variables see 
<A HREF="#register-vars">register variables</A>.</P>
<P>The compiler setting can also be changed within the source file by using
<CODE>
<A HREF="#pragma-register-vars">#pragma&nbsp;register-vars</A></CODE>.</P>

<P>
<A NAME="option-register-space"></A> </P>
<DT><B><CODE>--register-space</CODE></B><DD>
<P>This option takes a numeric parameter and is used to specify, how much
zero page register space is available. Please note that just giving this
option will not increase or decrease by itself, it will just tell the
compiler about the available space. You will have to allocate that space
yourself using an assembler module with the necessary allocations, and a
linker configuration that matches the assembler module. The default value
for this option is 6 (bytes).</P>
<P>If you don't know what all this means, please don't use this option.</P>

<P>
<A NAME="option-rodata-name"></A> </P>
<DT><B><CODE>--rodata-name seg</CODE></B><DD>
<P>Set the name of the rodata segment (the segment used for readonly data).
See also <CODE>
<A HREF="#pragma-rodata-name">#pragma&nbsp;rodata-name</A></CODE></P>
<P>
<A NAME="option-signed-chars"></A> </P>
<DT><B><CODE>-j, --signed-chars</CODE></B><DD>
<P>Using this option, you can make the default characters signed. Since the
6502 has no provisions for sign extending characters (which is needed on
almost any load operation), this will make the code larger and slower. A
better way is to declare characters explicitly as "signed" if needed. You
can also use <CODE>
<A HREF="#pragma-signed-chars">#pragma&nbsp;signed-chars</A></CODE> for better control of this option.</P>

<P>
<A NAME="option--standard"></A> </P>
<DT><B><CODE>--standard std</CODE></B><DD>
<P>This option allows to set the language standard supported. The argument is
one of
<DL>
<DT><B>c89</B><DD>
<P>This disables anything that is illegal in C89/C90. Among those things
are <CODE>//</CODE> comments and the non-standard keywords without
underscores. Please note that cc65 is not a fully C89 compliant compiler
despite this option. A few more things (like floats) are missing.</P>

<DT><B>c99</B><DD>
<P>This enables a few features from the C99 standard. With this option,
<CODE>//</CODE> comments are allowed. It will also cause warnings and even
errors in a few situations that are allowed with <CODE>--standard c89</CODE>.
For example, a call to a function without a prototype is an error in
this mode.</P>

<DT><B>cc65</B><DD>
<P>This is the default mode. It is like c99 mode, but additional features
are enabled. Among these are "void data", non-standard keywords without
the underlines, unnamed function parameters and the requirement for
main() to return an int.</P>
</DL>
</P>
<P>Please note that the compiler does not support the C99 standard and never
will. c99 mode is actually c89 mode with a few selected C99 extensions.</P>

<P>
<A NAME="option-t"></A> </P>
<DT><B><CODE>-t target, --target target</CODE></B><DD>
<P>This option is used to set the target system. The target system determines
the character set that is used for strings and character constants and the
default CPU. The CPU setting can be overriden by use of the <CODE>
<A HREF="#option--cpu">--cpu</A></CODE> option.</P>
<P>The following target systems are supported:</P>
<P>
<UL>
<LI>none</LI>
<LI>apple2</LI>
<LI>apple2enh</LI>
<LI>atari</LI>
<LI>atarixl</LI>
<LI>atmos</LI>
<LI>c16 (works also for the c116 with memory up to 32K)</LI>
<LI>c64</LI>
<LI>c128</LI>
<LI>cbm510 (CBM-II series with 40 column video)</LI>
<LI>cbm610 (all CBM-II II computers with 80 column video)</LI>
<LI>geos-apple</LI>
<LI>geos-cbm</LI>
<LI>lunix</LI>
<LI>lynx</LI>
<LI>nes</LI>
<LI>osic1p</LI>
<LI>pet (all CBM PET systems except the 2001)</LI>
<LI>plus4</LI>
<LI>sim6502</LI>
<LI>sim65c02</LI>
<LI>supervision</LI>
<LI>vic20</LI>
</UL>
</P>

<DT><B><CODE>-v, --verbose</CODE></B><DD>
<P>Using this option, the compiler will be somewhat more verbose if errors
or warnings are encountered.</P>

<P>
<A NAME="option-writable-strings"></A> </P>
<DT><B><CODE>--writable-strings</CODE></B><DD>
<P>Make string literals writable by placing them into the data segment instead
of the rodata segment. You can also use <CODE>
<A HREF="#pragma-writable-strings">#pragma&nbsp;writable-strings</A></CODE> to control this option from within
the source file.</P>

<P>
<A NAME="option-static-locals"></A> </P>
<DT><B><CODE>-Cl, --static-locals</CODE></B><DD>
<P>Use static storage for local variables instead of storage on the stack.
Since the stack is emulated in software, this gives shorter and usually
faster code, but the code is no longer reentrant. The difference between
<CODE>-Cl</CODE> and declaring local variables as static yourself is, that
initializer code is executed each time, the function is entered. So when
using</P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
        void f (void)
        {
            unsigned a = 1;
            ...
        }
  
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>the variable <CODE>a</CODE> will always have the value <CODE>1</CODE> when entering the
function and using <CODE>-Cl</CODE>, while in</P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
        void f (void)
        {
            static unsigned a = 1;
            ....
        }
  
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>the variable <CODE>a</CODE> will have the value <CODE>1</CODE> only the first time that the
function is entered, and will keep the old value from one call of the
function to the next.</P>
<P>You may also use <CODE>
<A HREF="#pragma-static-locals">#pragma&nbsp;static-locals</A></CODE> to change this setting in your
sources.</P>

<P>
<A NAME="option-include-dir"></A> </P>
<DT><B><CODE>-I dir, --include-dir dir</CODE></B><DD>
<P>Set a directory where the compiler searches for include files. You may
use this option multiple times to add more than one directory to the
search list.</P>

<P>
<A NAME="option-O"></A> </P>
<DT><B><CODE>-O, -Oi, -Or, -Os</CODE></B><DD>
<P>Enable an optimizer run over the produced code.</P>
<P>Using <CODE>-Oi</CODE>, the code generator will inline some code where otherwise a
runtime functions would have been called, even if the generated code is
larger. This will not only remove the overhead for a function call, but will
make the code visible for the optimizer. <CODE>-Oi</CODE> is an alias for
<CODE>-O --codesize&nbsp;200</CODE>.</P>
<P><CODE>-Or</CODE> will make the compiler honor the <CODE>register</CODE> keyword. Local
variables may be placed in registers (which are actually zero page
locations). See also the <CODE>
<A HREF="#option-register-vars">--register-vars</A></CODE> command line option, and the 
<A HREF="#register-vars">discussion of register variables</A> below.</P>
<P>Using <CODE>-Os</CODE> will allow the compiler to inline some standard functions
from the C library like strlen.  This will not only remove the overhead
for a function call, but will make the code visible for the optimizer.
See also the <CODE>
<A HREF="#option-inline-stdfuncs">--inline-stdfuncs</A></CODE>
command line option.</P>
<P>It is possible to concatenate the modifiers for <CODE>-O</CODE>. For example, to
enable register variables and inlining of standard functions, you may use
<CODE>-Ors</CODE>.</P>


<DT><B><CODE>-T, --add-source</CODE></B><DD>
<P>This include the source code as comments in the generated code. This is
normally not needed.</P>


<DT><B><CODE>-V, --version</CODE></B><DD>
<P>Print the version number of the compiler. When submitting a bug report,
please include the operating system you're using, and the compiler
version.</P>

<P>
<A NAME="option-W"></A> </P>
<DT><B><CODE>-W name[,name,...]</CODE></B><DD>
<P>This option allows to control warnings generated by the compiler. It is
followed by a comma-separated list of warnings that should be enabled or
disabled. To disable a warning, its name is prefixed by a minus sign. If
no such prefix exists, or the name is prefixed by a plus sign, the warning
is enabled.</P>
<P>The following warning names currently are recognized:
<DL>
<DT><B><CODE>const-comparison</CODE></B><DD>
<P>Warn if the result of a comparison is constant.</P>
<DT><B><CODE>error</CODE></B><DD>
<P>Treat all warnings as errors.</P>
<DT><B><CODE>no-effect</CODE></B><DD>
<P>Warn about statements that don't have an effect.</P>
<DT><B><CODE>remap-zero</CODE></B><DD>
<P>Warn about a <CODE>
<A HREF="#pragma-charmap">#pragma charmap()</A></CODE>
that changes a character's code number from/to 0x00.</P>
<DT><B><CODE>struct-param</CODE></B><DD>
<P>Warn when passing structs by value.</P>
<DT><B><CODE>unknown-pragma</CODE></B><DD>
<P>Warn about #pragmas that aren't recognized by cc65.</P>
<DT><B><CODE>unused-label</CODE></B><DD>
<P>Warn about unused labels.</P>
<DT><B><CODE>unused-param</CODE></B><DD>
<P>Warn about unused function parameters.</P>
<DT><B><CODE>unused-var</CODE></B><DD>
<P>Warn about unused variables.</P>
</DL>
</P>
<P>The full list of available warning names can be retrieved by using the
option <CODE>
<A HREF="#option-list-warnings">--list-warnings</A></CODE>.</P>
<P>You may use also <CODE>
<A HREF="#pragma-warn">#pragma&nbsp;warn</A></CODE> to
control this setting, for smaller pieces of code, from within your sources.</P>

</DL>
</P>




<H2><A NAME="s3">3.</A> <A HREF="#toc3">Input and output</A></H2>


<P>The compiler will accept one C file per invocation and create a file with
the same base name, but with the extension replaced by ".s". The output
file contains assembler code suitable for use with the ca65 macro
assembler.</P>
<P>Include files in quotes are searched in the following places:
<OL>
<LI>The current file's directory.</LI>
<LI>Any directory added with the <CODE>-I</CODE> option on the command line.</LI>
<LI>The value of the environment variable <CODE>CC65_INC</CODE> if it is defined.</LI>
</OL>
</P>
<P>Include files in angle brackets are searched in the following places:
<OL>
<LI>Any directory added with the <CODE>-I</CODE> option on the command line.</LI>
<LI>The value of the environment variable <CODE>CC65_INC</CODE> if it is defined.</LI>
<LI>A subdirectory named <CODE>include</CODE> of the directory defined in the
environment variable <CODE>CC65_HOME</CODE>, if it is defined.</LI>
<LI>An optionally compiled-in directory.</LI>
</OL>
</P>



<H2><A NAME="s4">4.</A> <A HREF="#toc4">Differences to the ISO standard</A></H2>


<P>Apart from the things listed below, the compiler does support additional
keywords, has several functions in the standard headers with names outside the
reserved namespace and a few syntax extensions. All these can be disabled with
the <CODE>
<A HREF="#option--standard">--standard</A></CODE> command line
option. Its use for maximum standards compatibility is advised.</P>
<P>Here is a list of differences between the language, the compiler accepts,
and the one defined by the ISO standard:</P>
<P>
<UL>
<LI>  The datatypes "float" and "double" are not available.

</LI>
<LI>  C Functions may not return structs (or unions), and structs may not
be passed as parameters by value. However, struct assignment *is*
possible.

</LI>
<LI>  Most of the C library is available with only the fastcall calling
convention (
<A HREF="#extension-fastcall">see below</A>).  It means
that you must not mix pointers to those functions with pointers to
user-written, cdecl functions (the calling conventions are incompatible).

</LI>
<LI>  The <CODE>volatile</CODE> keyword has almost no effect. That is not as bad
as it sounds, since the 6502 has so few registers that it isn't
possible to keep values in registers anyway.

</LI>
</UL>
</P>
<P>There may be some more minor differences I'm currently not aware of. The
biggest problem is the missing float data type. With this limitation in
mind, you should be able to write fairly portable code.</P>



<H2><A NAME="s5">5.</A> <A HREF="#toc5">Extensions</A></H2>


<P>This cc65 version has some extensions to the ISO C standard.</P>
<P>
<UL>
<LI>  The compiler allows to insert assembler statements into the output
file. The syntax is

<BLOCKQUOTE><CODE>
<PRE>
        asm [optional volatile] (&lt;string literal&gt;[, optional parameters]) ;
        
</PRE>
</CODE></BLOCKQUOTE>

or
<BLOCKQUOTE><CODE>
<PRE>
        __asm__ [optional volatile] (&lt;string literal&gt;[, optional parameters]) ;
        
</PRE>
</CODE></BLOCKQUOTE>


The first form is in the user namespace; and, is disabled if the <CODE>-A</CODE>
switch is given.

There is a whole section covering inline assembler statements,
<A HREF="#inline-asm">see there</A>.

<P>
<A NAME="extension-fastcall"></A> </P>
</LI>
<LI>  The normal calling convention -- for non-variadic functions -- is
named "fastcall". The syntax for a function declaration that
<EM>explicitly</EM> uses fastcall is

<BLOCKQUOTE><CODE>
<PRE>
        &lt;return type&gt; fastcall &lt;function name&gt; (&lt;parameter list&gt;)
        
</PRE>
</CODE></BLOCKQUOTE>

or
<BLOCKQUOTE><CODE>
<PRE>
        &lt;return type&gt; __fastcall__ &lt;function name&gt; (&lt;parameter list&gt;)
        
</PRE>
</CODE></BLOCKQUOTE>

An example is
<BLOCKQUOTE><CODE>
<PRE>
        void __fastcall__ f (unsigned char c)
        
</PRE>
</CODE></BLOCKQUOTE>

The first form of the fastcall keyword is in the user namespace and can
therefore be disabled with the <CODE>
<A HREF="#option--standard">--standard</A></CODE> command line option.

For functions that are <CODE>fastcall</CODE>, the rightmost parameter is not
pushed on the stack but left in the primary register when the function
is called. That significantly reduces the cost of calling those functions.


</LI>
<LI>  There is another calling convention named "cdecl". Variadic functions
(their prototypes have an ellipsis [<CODE>...</CODE>]) always use that
convention. The syntax for a function declaration using cdecl is

<BLOCKQUOTE><CODE>
<PRE>
        &lt;return type&gt; cdecl &lt;function name&gt; (&lt;parameter list&gt;)
        
</PRE>
</CODE></BLOCKQUOTE>

or
<BLOCKQUOTE><CODE>
<PRE>
        &lt;return type&gt; __cdecl__ &lt;function name&gt; (&lt;parameter list&gt;)
        
</PRE>
</CODE></BLOCKQUOTE>

An example is
<BLOCKQUOTE><CODE>
<PRE>
        int* __cdecl__ f (unsigned char c)
        
</PRE>
</CODE></BLOCKQUOTE>


The first form of the cdecl keyword is in the user namespace;
and therefore, can be disabled with the <CODE>
<A HREF="#option--standard">--standard</A></CODE> command-line option.

For functions that are <CODE>cdecl</CODE>, the rightmost parameter is pushed
onto the stack before the function is called. That increases the cost
of calling those functions, especially when they are called from many
places.


</LI>
<LI>  There are two pseudo variables named <CODE>__AX__</CODE> and <CODE>__EAX__</CODE>.
Both refer to the primary register that is used by the compiler to
evaluate expressions or return function results. <CODE>__AX__</CODE> is of
type <CODE>unsigned int</CODE> and <CODE>__EAX__</CODE> of type <CODE>long unsigned int</CODE>
respectively. The pseudo variables may be used as lvalue and rvalue as
every other variable. They are most useful together with short
sequences of assembler code. For example, the macro

<BLOCKQUOTE><CODE>
<PRE>
        #define hi(x)           \
            (__AX__ = (x),      \
             asm ("txa"),       \
             asm ("ldx #$00"),  \
             __AX__)
        
</PRE>
</CODE></BLOCKQUOTE>


will give the high byte of any unsigned value.


</LI>
<LI>  Inside a function, the identifier <CODE>__func__</CODE> gives the name of the
current function as a string. Outside of functions, <CODE>__func__</CODE> is
undefined.
Example:

<BLOCKQUOTE><CODE>
<PRE>
        #define PRINT_DEBUG(s)  printf ("%s: %s\n", __func__, s);
        
</PRE>
</CODE></BLOCKQUOTE>


The macro will print the name of the current function plus a given
string.


</LI>
<LI>  cc65 allows the initialization of <CODE>void</CODE> variables. This may be
used to create arbitrary structures that are more compatible with
interfaces written for assembler languages. Here is an example:

<BLOCKQUOTE><CODE>
<PRE>
        void GCmd = { (char)3, (unsigned)0x2000, (unsigned)0x3000 };
        
</PRE>
</CODE></BLOCKQUOTE>


That will be translated as follows:

<BLOCKQUOTE><CODE>
<PRE>
        _GCmd:
                .byte   3
                .word   $2000
                .word   $3000
        
</PRE>
</CODE></BLOCKQUOTE>


Since the variable is of type <CODE>void</CODE>, you may not use it as-is.
However, taking the address of the variable results in a <CODE>void*</CODE>
which may be passed to any function expecting a pointer.  Also, the
<CODE>sizeof</CODE> operator will give the length of the initializer:

<BLOCKQUOTE><CODE>
<PRE>
        GLen = sizeof GCmd;
        
</PRE>
</CODE></BLOCKQUOTE>


will assign the value 5 to <CODE>GLen</CODE>.

See the 
<A HREF="geos.html">GEOS library document</A> for examples
on how to use that feature.


</LI>
<LI>  cc65 implements flexible array struct members as defined in the C99 ISO
standard. As an extension, these fields may be initialized. There are
several exceptions, however (which is probably the reason why the
standard does not define this feature, because it is highly
unorthogonal). Flexible array members cannot be initialized ...

<UL>
<LI>... when defining an array of structs with flexible
members.</LI>
<LI>... if such a struct is a member field of another struct
which is not the last field.</LI>
<LI>... if the struct which contains a flexible array member is
declared as <CODE>register</CODE>, and the size and compiler settings
do allow the compiler actually to place the struct into the
register bank in the zero page.</LI>
</UL>


Please note that -- as defined in the ISO C standard -- the <CODE>sizeof</CODE>
operator returns the struct size with the flexible array member having
size zero, even if it is initialized.


</LI>
</UL>
</P>




<H2><A NAME="s6">6.</A> <A HREF="#toc6">Predefined macros</A></H2>


<P>The compiler defines several macros at startup:</P>
<P>
<DL>
<DT><B><CODE>__APPLE2__</CODE></B><DD>
<P>This macro is defined if the target is the Apple ][ (-t apple2) or the enhanced Apple //e (-t apple2enh).</P>

<DT><B><CODE>__APPLE2ENH__</CODE></B><DD>
<P>This macro is defined if the target is the enhanced Apple //e (-t apple2enh).</P>

<DT><B><CODE>__ATARI2600__</CODE></B><DD>
<P>This macro is defined if the target is the Atari 2600 game console.</P>

<DT><B><CODE>__ATARI5200__</CODE></B><DD>
<P>This macro is defined if the target is the Atari 5200 game console.</P>

<DT><B><CODE>__ATARI__</CODE></B><DD>
<P>This macro is defined if the target is the Atari 400/800 (-t atari) or the Atari 800XL/130XE (-t atarixl).</P>

<DT><B><CODE>__ATARIXL__</CODE></B><DD>
<P>This macro is defined if the target is the Atari 800XL/130XE (-t atarixl).</P>

<DT><B><CODE>__ATMOS__</CODE></B><DD>
<P>This macro is defined if the target is the Oric Atmos (-t atmos).</P>

<DT><B><CODE>__C128__</CODE></B><DD>
<P>This macro is defined if the target is the Commodore 128 (-t c128).</P>

<DT><B><CODE>__C16__</CODE></B><DD>
<P>This macro is defined if the target is the Commodore 16/116 (-t c16) or the Commodore Plus/4 (-t plus4).</P>

<DT><B><CODE>__C64__</CODE></B><DD>
<P>This macro is defined if the target is the Commodore 64 (-t c64).</P>

<DT><B><CODE>__CBM__</CODE></B><DD>
<P>This macro is defined if the target system is one of the CBM targets.</P>

<DT><B><CODE>__CBM510__</CODE></B><DD>
<P>This macro is defined if the target is the CBM 500 series of computers.</P>

<DT><B><CODE>__CBM610__</CODE></B><DD>
<P>This macro is defined if the target is one of the CBM 600/700 family of
computers (called B series in the US).</P>

<DT><B><CODE>__CC65__</CODE></B><DD>
<P>This macro is always defined. Its value is the version number of the
compiler in hex.  For example, version 2.14 of the compiler has this macro
defined as <CODE>0x02E0</CODE>.</P>

<DT><B><CODE>__CC65_STD__</CODE></B><DD>
<P>This macro is defined to one of the following depending on the <CODE>
<A HREF="#option--standard">--standard</A></CODE> command line option:
<UL>
<LI><CODE>__CC65_STD_C89__</CODE></LI>
<LI><CODE>__CC65_STD_C99__</CODE></LI>
<LI><CODE>__CC65_STD_CC65__</CODE></LI>
</UL>
</P>

<DT><B><CODE>__DATE__</CODE></B><DD>
<P>This macro expands to the date of translation of the preprocessing
translation unit in the form "Mmm dd yyyy".</P>

<DT><B><CODE>__EAGERLY_INLINE_FUNCS__</CODE></B><DD>
<P>Is defined if the compiler was called with the <CODE>
<A HREF="#option-eagerly-inline-funcs">--eagerly-inline-funcs</A></CODE> command line option.</P>

<DT><B><CODE>__FILE__</CODE></B><DD>
<P>This macro expands to a string containing the name of the C source file.</P>

<DT><B><CODE>__GEOS__</CODE></B><DD>
<P>This macro is defined if you are compiling for one of the GEOS systems.</P>

<DT><B><CODE>__GEOS_APPLE__</CODE></B><DD>
<P>This macro is defined if you are compiling for the Apple GEOS system (-t geos-apple).</P>

<DT><B><CODE>__GEOS_CBM__</CODE></B><DD>
<P>This macro is defined if you are compiling for the GEOS 64/128 system (-t geos-cbm).</P>

<DT><B><CODE>__LINE__</CODE></B><DD>
<P>This macro expands to the current line number.</P>

<DT><B><CODE>__LUNIX__</CODE></B><DD>
<P>This macro is defined if you are compiling for the LUnix system (-t lunix).</P>

<DT><B><CODE>__LYNX__</CODE></B><DD>
<P>This macro is defined if the target is the Atari Lynx (-t lynx).</P>

<DT><B><CODE>__NES__</CODE></B><DD>
<P>This macro is defined if the target is the Nintendo Entertainment System (-t nes).</P>

<DT><B><CODE>__OPT__</CODE></B><DD>
<P>Is defined if the compiler was called with the <CODE>-O</CODE> command line option.</P>

<DT><B><CODE>__OPT_i__</CODE></B><DD>
<P>Is defined if the compiler was called with the <CODE>-Oi</CODE> command line option.</P>

<DT><B><CODE>__OPT_r__</CODE></B><DD>
<P>Is defined if the compiler was called with the <CODE>-Or</CODE> command line option.</P>

<DT><B><CODE>__OPT_s__</CODE></B><DD>
<P>Is defined if the compiler was called with the <CODE>-Os</CODE> command line option.</P>

<DT><B><CODE>__OSIC1P__</CODE></B><DD>
<P>This macro is defined if the target is the Ohio Scientific Challenger 1P
(-t osic1p).</P>

<DT><B><CODE>__PET__</CODE></B><DD>
<P>This macro is defined if the target is the PET family of computers (-t pet).</P>

<DT><B><CODE>__PLUS4__</CODE></B><DD>
<P>This macro is defined if the target is the Commodore Plus/4 (-t plus4).</P>

<DT><B><CODE>__STDC_HOSTED__</CODE></B><DD>
<P>This macro is expands to the integer constant 1.</P>

<DT><B><CODE>__SIM6502__</CODE></B><DD>
<P>This macro is defined if the target is sim65 in 6502 mode (-t sim6502).</P>

<DT><B><CODE>__SIM65C02__</CODE></B><DD>
<P>This macro is defined if the target is sim65 in 65C02 mode (-t sim65c02).</P>

<DT><B><CODE>__SUPERVISION__</CODE></B><DD>
<P>This macro is defined if the target is the Supervision (-t supervision).</P>

<DT><B><CODE>__TIME__</CODE></B><DD>
<P>This macro expands to the time of translation of the preprocessing
translation unit in the form "hh:mm:ss".</P>

<DT><B><CODE>__VIC20__</CODE></B><DD>
<P>This macro is defined if the target is the Commodore VIC20 (-t vic20).</P>
</DL>
</P>



<H2><A NAME="pragmas"></A> <A NAME="s7">7.</A> <A HREF="#toc7">#pragmas</A></H2>


<P>The compiler understands some pragmas that may be used to change code
generation and other stuff. Some of these pragmas understand a special form:
If the first parameter is <CODE>push</CODE>, the old value is saved onto a stack
before changing it. The value may later be restored by using the <CODE>pop</CODE>
parameter with the <CODE>#pragma</CODE>.</P>


<H2><A NAME="pragma-allow-eager-inline"></A> <A NAME="ss7.1">7.1</A> <A HREF="#toc7.1"><CODE>#pragma allow-eager-inline ([push,] on|off)</CODE></A>
</H2>


<P>Allow eager inlining of known functions.  If the argument is "off", eager
inlining is disabled, otherwise it is enabled. Please note that (in contrast
to the <CODE>
<A HREF="#option-eagerly-inline-funcs">--eagerly-inline-funcs</A></CODE>
command line option) this pragma does not imply the <CODE>
<A HREF="#option-inline-stdfuncs">--inline-stdfuncs</A></CODE> command line option.  Rather it marks code to be safe for
eager inlining of known functions if inlining of standard functions is enabled.</P>
<P>The <CODE>#pragma</CODE> understands the push and pop parameters as explained above.</P>


<H2><A NAME="pragma-bss-name"></A> <A NAME="ss7.2">7.2</A> <A HREF="#toc7.2"><CODE>#pragma bss-name ([push,] &lt;name&gt;)</CODE></A>
</H2>


<P>This pragma changes the name used for the BSS segment (the BSS segment
is used to store uninitialized data). The argument is a string enclosed
in double quotes.</P>
<P>Note: The default linker configuration file does only map the standard
segments. If you use other segments, you have to create a new linker
configuration file.</P>
<P>Beware: The startup code will zero only the default BSS segment. If you
use another BSS segment, you have to do that yourself, otherwise
uninitialized variables do not have the value zero.</P>
<P>The <CODE>#pragma</CODE> understands the push and pop parameters as explained above.</P>
<P>Example:
<BLOCKQUOTE><CODE>
<PRE>
        #pragma bss-name ("MyBSS")
  
</PRE>
</CODE></BLOCKQUOTE>
</P>


<H2><A NAME="pragma-charmap"></A> <A NAME="ss7.3">7.3</A> <A HREF="#toc7.3"><CODE>#pragma charmap (&lt;index&gt;, &lt;code&gt;)</CODE></A>
</H2>


<P>Each literal string and each literal character in the source is translated
by use of a translation table. That translation table is preset when the
compiler is started, depending on the target system; for example, to map
ISO-8859-1 characters into PETSCII if the target is a Commodore machine.</P>
<P>This pragma allows to change entries in the translation table, so the
translation for individual characters, or even the complete table may be
adjusted. Both arguments are assumed to be unsigned characters with a valid
range of 0-255.</P>
<P>Beware of some pitfalls:
<UL>
<LI>The character index is actually the code of the character in the
C source; so, character mappings do always depend on the source
character set. That means that <CODE>#pragma&nbsp;charmap()</CODE> is not
portable -- it depends on the build environment.</LI>
<LI>While it is possible to use character literals as indices, the
result may be somewhat unexpected, since character literals are
themselves translated. For that reason, I would suggest to avoid
character literals, and use numeric character codes instead.</LI>
<LI>It is risky to change index <CODE>0x00</CODE>, because string functions depend
on it. If it is changed, then the <CODE>'\0'</CODE> at the end of string
literals will become non-zero. Functions that are used on those
literals won't stop at the end of them. cc65 will warn you if you do
change that code number. You can turn off that <CODE>remap-zero</CODE> warning
if you are certain that you know what you are doing (see <CODE>
<A HREF="#pragma-warn">#pragma&nbsp;warn()</A></CODE>).</LI>
</UL>
</P>
<P>Example:
<BLOCKQUOTE><CODE>
<PRE>
  /* Use a space wherever an 'a' occurs in ISO-8859-1 source */
  #pragma charmap (0x61, 0x20);
  
</PRE>
</CODE></BLOCKQUOTE>
</P>


<H2><A NAME="pragma-check-stack"></A> <A NAME="ss7.4">7.4</A> <A HREF="#toc7.4"><CODE>#pragma check-stack ([push,] on|off)</CODE></A>
</H2>


<P>Tells the compiler to insert calls to a stack checking subroutine to detect
stack overflows. The stack checking code will lead to somewhat larger and
slower programs, so you may want to use this pragma when debugging your
program and switch it off for the release version. If a stack overflow is
detected, the program is aborted.</P>
<P>If the argument is "off", stack checks are disabled (the default), otherwise
they're enabled.</P>
<P>The <CODE>#pragma</CODE> understands the push and pop parameters as explained above.</P>


<H2><A NAME="pragma-code-name"></A> <A NAME="ss7.5">7.5</A> <A HREF="#toc7.5"><CODE>#pragma code-name ([push,] &lt;name&gt;)</CODE></A>
</H2>


<P>This pragma changes the name used for the CODE segment (the CODE segment
is used to store executable code). The argument is a string enclosed in
double quotes.</P>
<P>Note: The default linker configuration file does only map the standard
segments. If you use other segments, you have to create a new linker
configuration file.</P>
<P>The <CODE>#pragma</CODE> understands the push and pop parameters as explained above.</P>
<P>Example:
<BLOCKQUOTE><CODE>
<PRE>
        #pragma code-name ("MyCODE")
  
</PRE>
</CODE></BLOCKQUOTE>
</P>


<H2><A NAME="pragma-codesize"></A> <A NAME="ss7.6">7.6</A> <A HREF="#toc7.6"><CODE>#pragma codesize ([push,] &lt;int&gt;)</CODE></A>
</H2>


<P>This pragma allows finer control about speed vs. size decisions in the code
generation and optimization phase. It gives the allowed size increase factor
(in percent). The default is can be changed by use of the <CODE>
<A HREF="#option-codesize">--codesize</A></CODE> compiler option.</P>
<P>The <CODE>#pragma</CODE> understands the push and pop parameters as explained above.</P>


<H2><A NAME="pragma-data-name"></A> <A NAME="ss7.7">7.7</A> <A HREF="#toc7.7"><CODE>#pragma data-name ([push,] &lt;name&gt;)</CODE></A>
</H2>


<P>This pragma changes the name used for the DATA segment (the DATA segment
is used to store initialized data). The argument is a string enclosed in
double quotes.</P>
<P>Note: The default linker configuration file does only map the standard
segments. If you use other segments, you have to create a new linker
configuration file.</P>
<P>The <CODE>#pragma</CODE> understands the push and pop parameters as explained above.</P>
<P>Example:
<BLOCKQUOTE><CODE>
<PRE>
        #pragma data-name ("MyDATA")
  
</PRE>
</CODE></BLOCKQUOTE>
</P>


<H2><A NAME="pragma-inline-stdfuncs"></A> <A NAME="ss7.8">7.8</A> <A HREF="#toc7.8"><CODE>#pragma inline-stdfuncs ([push,] on|off)</CODE></A>
</H2>


<P>Allow the compiler to inline some standard functions from the C library like
strlen.  If the argument is "off", inlining is disabled, otherwise it is enabled.</P>
<P>See also the <CODE>
<A HREF="#option-inline-stdfuncs">--inline-stdfuncs</A></CODE>
command line option.</P>
<P>The <CODE>#pragma</CODE> understands the push and pop parameters as explained above.</P>


<H2><A NAME="pragma-local-strings"></A> <A NAME="ss7.9">7.9</A> <A HREF="#toc7.9"><CODE>#pragma local-strings ([push,] on|off)</CODE></A>
</H2>


<P>When "on", emit string literals to the data segment when they're encountered
in the source. The default ("off") is to keep string literals until end of
assembly, merge read only literals if possible, and then output the literals
into the data or rodata segment that is active at that point.</P>
<P>Using this <CODE>#pragma</CODE> it is possible to control the behaviour from within
the source. When <CODE>#pragma local-strings</CODE> is active, string literals are
output immediately, which means that they go into the currently active data
or rodata segment, but cannot be merged. When inactive, string literals are
remembered and output as a whole when translation is finished.</P>


<H2><A NAME="pragma-optimize"></A> <A NAME="ss7.10">7.10</A> <A HREF="#toc7.10"><CODE>#pragma optimize ([push,] on|off)</CODE></A>
</H2>


<P>Switch optimization on or off. If the argument is "off", optimization is
disabled, otherwise it is enabled. Please note that this pragma only effects
whole functions. The setting in effect when the function is encountered will
determine if the generated code is optimized or not.</P>
<P>Optimization and code generation is also controlled by the 
<A HREF="#pragma-codesize">codesize pragma</A>.</P>
<P>The default is "off", but may be changed with the <CODE>
<A HREF="#option-O">-O</A></CODE> compiler option.</P>
<P>The <CODE>#pragma</CODE> understands the push and pop parameters as explained above.</P>


<H2><A NAME="pragma-rodata-name"></A> <A NAME="ss7.11">7.11</A> <A HREF="#toc7.11"><CODE>#pragma rodata-name ([push,] &lt;name&gt;)</CODE></A>
</H2>


<P>This pragma changes the name used for the RODATA segment (the RODATA
segment is used to store readonly data). The argument is a string
enclosed in double quotes.</P>
<P>Note: The default linker configuration file does only map the standard
segments. If you use other segments, you have to create a new linker
configuration file.</P>
<P>The <CODE>#pragma</CODE> understands the push and pop parameters as explained above.</P>
<P>Example:
<BLOCKQUOTE><CODE>
<PRE>
        #pragma rodata-name ("MyRODATA")
  
</PRE>
</CODE></BLOCKQUOTE>
</P>


<H2><A NAME="pragma-regvaraddr"></A> <A NAME="ss7.12">7.12</A> <A HREF="#toc7.12"><CODE>#pragma regvaraddr ([push,] on|off)</CODE></A>
</H2>


<P>The compiler does not allow to take the address of register variables.
The regvaraddr pragma changes this. Taking the address of a register
variable is allowed after using this pragma with "on" as argument.
Using "off" as an argument switches back to the default behaviour.</P>
<P>Beware: The C standard does not allow taking the address of a variable
declared as register. So your programs become non-portable if you use
this pragma. In addition, your program may not work. This is usually the
case if a subroutine is called with the address of a register variable,
and this subroutine (or a subroutine called from there) uses
register variables. So be careful with this #pragma.</P>
<P>The <CODE>#pragma</CODE> understands the push and pop parameters as explained above.</P>
<P>Example:
<BLOCKQUOTE><CODE>
<PRE>
        #pragma regvaraddr(on)  /* Allow taking the address
                                 * of register variables
                                 */
  
</PRE>
</CODE></BLOCKQUOTE>
</P>


<H2><A NAME="pragma-register-vars"></A> <A NAME="ss7.13">7.13</A> <A HREF="#toc7.13"><CODE>#pragma register-vars ([push,] on|off)</CODE></A>
</H2>


<P>Enables or disables use of register variables. If register variables are
disabled (the default), the <CODE>register</CODE> keyword is ignored. Register
variables are explained in more detail in 
<A HREF="#register-vars">a separate   chapter</A>.</P>
<P>The <CODE>#pragma</CODE> understands the push and pop parameters as explained above.</P>


<H2><A NAME="pragma-signed-chars"></A> <A NAME="ss7.14">7.14</A> <A HREF="#toc7.14"><CODE>#pragma signed-chars ([push,] on|off)</CODE></A>
</H2>


<P>Changes the signedness of the default character type. If the argument is
"on", default characters are signed, otherwise characters are unsigned. The
compiler default is to make characters unsigned since this creates a lot
better code. This default may be overridden by the <CODE>
<A HREF="#option-signed-chars">--signed-chars</A></CODE> command line option.</P>
<P>The <CODE>#pragma</CODE> understands the push and pop parameters as explained above.</P>


<H2><A NAME="pragma-static-locals"></A> <A NAME="ss7.15">7.15</A> <A HREF="#toc7.15"><CODE>#pragma static-locals ([push,] on|off)</CODE></A>
</H2>


<P>Use variables in the bss segment instead of variables on the stack. This
pragma changes the default set by the compiler option <CODE>
<A HREF="#option-static-locals">--static-locals</A></CODE>. If the argument is "on",
local variables are allocated in the BSS segment, leading to shorter and in
most cases faster, but non-reentrant code.</P>
<P>The <CODE>#pragma</CODE> understands the push and pop parameters as explained above.</P>


<H2><A NAME="pragma-warn"></A> <A NAME="ss7.16">7.16</A> <A HREF="#toc7.16"><CODE>#pragma warn (name, [push,] on|off)</CODE></A>
</H2>


<P>Switch compiler warnings on or off. "name" is the name of a warning (see the
<CODE>
<A HREF="#option-W">-W</A></CODE> compiler option for a list). The name is
followed either by "pop", which restores the last pushed state, or by "on" or
"off", optionally preceeded by "push" to push the current state before
changing it.</P>
<P>Example:
<BLOCKQUOTE><CODE>
<PRE>
        /* Don't warn about the unused parameter in function func */
        #pragma warn (unused-param, push, off)
        static int func (int unused)
        {
            return 0;
        }
        #pragma warn (unused-param, pop)
  
</PRE>
</CODE></BLOCKQUOTE>
</P>


<H2><A NAME="pragma-writable-strings"></A> <A NAME="ss7.17">7.17</A> <A HREF="#toc7.17"><CODE>#pragma writable-strings ([push,] on|off)</CODE></A>
</H2>


<P>Changes the storage location of string literals. For historical reasons,
the C standard defines that string literals are of type "char[]", but
writing to such a literal causes undefined behaviour. Most compilers
(including cc65) place string literals in the read-only data segment, which
may cause problems with old C code that writes to string literals.</P>
<P>Using this pragma (or the corresponding command line option <CODE>
<A HREF="#option-writable-strings">--writable-strings</A></CODE>) causes the
literals to be placed in the data segment so they can be written to without
worry.</P>
<P>The <CODE>#pragma</CODE> understands the push and pop parameters as explained above.</P>


<H2><A NAME="ss7.18">7.18</A> <A HREF="#toc7.18"><CODE>#pragma zpsym (&lt;name&gt;)</CODE></A>
</H2>


<P>Tell the compiler that the -- previously as external declared -- symbol with
the given name is a zero page symbol (usually from an assembler file).
The compiler will create a matching import declaration for the assembler.</P>
<P>Example:
<BLOCKQUOTE><CODE>
<PRE>
        extern int foo;
        #pragma zpsym ("foo");  /* foo is in the zeropage */
  
</PRE>
</CODE></BLOCKQUOTE>
</P>



<H2><A NAME="register-vars"></A> <A NAME="s8">8.</A> <A HREF="#toc8">Register variables</A></H2>


<P>The runtime for all supported platforms has 6 bytes of zero page space
available for register variables (this could be increased, but I think it's a
good value). So you can declare register variables up to a total size of 6 per
function. The compiler will allocate register space on a "first come, first
served" base and convert any <CODE>register</CODE> declarations that exceed the
available register space silently to <CODE>auto</CODE>. Parameters can also be
declared as <CODE>register</CODE>, this will in fact give slightly shorter code than
using a register variable.</P>
<P>Since a function must save the current values of the registers on entry and
restore them on exit, there is an overhead associated with register variables,
and this overhead is quite high (about 20 bytes per variable). This means that
just declaring anything as <CODE>register</CODE> is not a good idea.</P>
<P>The best use for register variables are pointers, especially those that point
to structures. The magic number here is about 3 uses of a struct field: If the
function contains this number or even more, the generated code will be usually
shorter and faster when using a register variable for the struct pointer. The
reason for this is that the register variable can in many cases be used as a
pointer directly. Having a pointer in an auto variable means that this pointer
must first be copied into a zero page location, before it can be dereferenced.</P>
<P>Second best use for register variables are counters. However, there is not
much difference in the code generated for counters, so you will need at least
100 operations on this variable (for example in a loop) to make it worth the
trouble. The only savings you get here are by the use of a zero page variable
instead of one on the stack or in the data segment.</P>
<P>Register variables must be explicitly enabled, either by using <CODE>
<A HREF="#option-O">-Or</A></CODE> or <CODE>
<A HREF="#option-register-vars">--register-vars</A></CODE> on the command line or by use of <CODE>
<A HREF="#pragma-register-vars">#pragma register-vars</A></CODE>. Register variables
are only accepted on function top level, register variables declared in
interior blocks are silently converted to <CODE>auto</CODE>. With register variables
disabled, all variables declared as <CODE>register</CODE> are actually auto variables.</P>
<P>Please take care when using register variables: While they are helpful and can
lead to a tremendous speedup when used correctly, improper usage will cause
bloated code and a slowdown.</P>



<H2><A NAME="inline-asm"></A> <A NAME="s9">9.</A> <A HREF="#toc9">Inline assembler</A></H2>


<P>The compiler allows to insert assembler statements into the output file. The
syntax is</P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
        asm [optional volatile] (&lt;string literal&gt;[, optional parameters]) ;
</PRE>
</CODE></BLOCKQUOTE>

or
<BLOCKQUOTE><CODE>
<PRE>
        __asm__ [optional volatile] (&lt;string literal&gt;[, optional parameters]) ;
</PRE>
</CODE></BLOCKQUOTE>
</P>

<P>The first form is in the user namespace; and, is disabled by <CODE>
<A HREF="#option--standard">--standard</A></CODE> if the argument is not <CODE>cc65</CODE>.</P>
<P>The <CODE>asm</CODE> statement can be used only inside a function.  Please note that
the result of an inline assembler expression is always of type <CODE>void</CODE>.</P>
<P>The contents of the string literal are preparsed by the compiler; and, inserted
into the generated assembly output, so that it can be processed further by
the backend -- and, especially the optimizer. For that reason, the compiler does
allow only regular 6502 opcodes to be used with the inline assembler. Pseudo
instructions (like <CODE>.import</CODE>, <CODE>.byte</CODE>, and so on) are <EM>not</EM> allowed,
even if the ca65 assembler (which is used to translate the generated assembler
code) would accept them. The built-in inline assembler is not a replacement for
the full-blown macro assembler which comes with the compiler.</P>
<P>Note: Inline assembler statements are subject to all optimizations done by the
compiler. There currently is no way to protect an inline assembler statement
-- alone -- from being moved or removed completely by the optimizer. If in
doubt, check the generated assembler output; or, disable optimizations (for
that function).</P>
<P>As a shortcut, you can put the <CODE>volatile</CODE> qualifier in your <CODE>asm</CODE>
statements.  It will disable optimization for the functions in which those
<CODE>asm volatile</CODE> statements sit.  The effect is the same as though you put
<CODE>#pragma optimize(push, off)</CODE> above those functions, and <CODE>#pragma
optimize(pop)</CODE> below those functions.</P>
<P>The string literal may contain format specifiers from the following list. For
each format specifier, an argument is expected which is inserted instead of
the format specifier, before passing the assembly code line to the backend.</P>
<P>
<UL>
<LI><CODE>%b</CODE> - Numerical 8-bit value</LI>
<LI><CODE>%w</CODE> - Numerical 16-bit value</LI>
<LI><CODE>%l</CODE> - Numerical 32-bit value</LI>
<LI><CODE>%v</CODE> - Assembler name of a global variable or function</LI>
<LI><CODE>%o</CODE> - Stack offset of a local variable</LI>
<LI><CODE>%g</CODE> - Assembler name of a C label</LI>
<LI><CODE>%s</CODE> - The argument is converted to a string</LI>
<LI><CODE>%%</CODE> - The % sign itself</LI>
</UL>
</P>

<P>Using those format specifiers, you can access C <CODE>#defines</CODE>, variables, or
similar stuff from the inline assembler. For example, to load the value of
a C <CODE>#define</CODE> into the Y index register, one would use</P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
        #define OFFS  23
        __asm__ ("ldy #%b", OFFS);
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>Or, to access a struct member of a static variable:</P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
        typedef struct {
            unsigned char x;
            unsigned char y;
            unsigned char color;
        } pixel_t;
        static pixel_t pixel;
        __asm__ ("ldy #%b", offsetof(pixel_t, color));
        __asm__ ("lda %v,y", pixel);
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>The next example shows how to use global variables to exchange data between C
and assembler; and, how to handle assembler jumps:</P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
        static unsigned char globalSubA, globalSubB, globalSubResult;

        /* return a-b, return 255 if b>a */
        unsigned char sub (unsigned char a, unsigned char b)
        {
            globalSubA = a;
            globalSubB = b;
            __asm__ ("sec");
            __asm__ ("lda %v", globalSubA);
            __asm__ ("sbc %v", globalSubB);
            __asm__ ("bcs %g", jumpSubNoError);
            __asm__ ("lda #$FF");
        jumpSubNoError:
            __asm__ ("sta %v", globalSubResult);
            return globalSubResult;
        }
</PRE>
</CODE></BLOCKQUOTE>
</P>

<P>Arrays also can be accessed:</P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
        static const unsigned char globalSquareTable[] = {
            0, 1, 4, 9, 16, 25, 36, 49, 64, 81,
            100, 121, 144, 169, 196, 225
        };
        static unsigned char globalSquareA, globalSquareResult;

        /* return a*a for a&lt;16, else 255 */
        unsigned char square (unsigned char a)
        {
            if (a > 15) {
                return 255;
            }
            globalSquareA = a;
            __asm__ ("ldx %v", globalSquareA);
            __asm__ ("lda %v,x", globalSquareTable);
            __asm__ ("sta %v", globalSquareResult);
            return globalSquareResult;
        }
</PRE>
</CODE></BLOCKQUOTE>
</P>

<P>Note: Do not embed the assembler labels that are used as names of global
variables or functions into your <CODE>asm</CODE> statements. Code such as this:</P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
        int foo;
        int bar (void) { return 1; }
        ...
        __asm__ ("lda _foo");           /* DON'T DO THAT! */
        ...
        __asm__ ("jsr _bar");           /* DON'T DO THAT EITHER! */
</PRE>
</CODE></BLOCKQUOTE>
</P>

<P>might stop working if the way that the compiler generates those names is changed in
a future version. Instead, use the format specifiers from the table above:</P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
        __asm__ ("lda %v", foo);        /* OK */
        ...
        __asm__ ("jsr %v", bar);        /* OK */
</PRE>
</CODE></BLOCKQUOTE>
</P>




<H2><A NAME="s10">10.</A> <A HREF="#toc10">Implementation-defined behavior</A></H2>


<P>This section describes the behavior of cc65 when the standard describes the
behavior as implementation-defined.</P>
<P>(to be done)</P>

<H2><A NAME="s11">11.</A> <A HREF="#toc11">Copyright</A></H2>


<P>This is the original compiler copyright:</P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
--------------------------------------------------------------------------
  -*- Mode: Text -*-

     This is the copyright notice for RA65, LINK65, LIBR65, and other
  Atari 8-bit programs.  Said programs are Copyright 1989, by John R.
  Dunning.  All rights reserved, with the following exceptions:

      Anyone may copy or redistribute these programs, provided that:

  1:  You don't charge anything for the copy.  It is permissable to
      charge a nominal fee for media, etc.

  2:  All source code and documentation for the programs is made
      available as part of the distribution.

  3:  This copyright notice is preserved verbatim, and included in
      the distribution.

      You are allowed to modify these programs, and redistribute the
  modified versions, provided that the modifications are clearly noted.

      There is NO WARRANTY with this software, it comes as is, and is
  distributed in the hope that it may be useful.

      This copyright notice applies to any program which contains
  this text, or the refers to this file.

      This copyright notice is based on the one published by the Free
  Software Foundation, sometimes known as the GNU project.  The idea
  is the same as theirs, ie the software is free, and is intended to
  stay that way.  Everybody has the right to copy, modify, and re-
  distribute this software.  Nobody has the right to prevent anyone
  else from copying, modifying or redistributing it.

--------------------------------------------------------------------------
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>Small parts of the compiler (parts of the preprocessor and main parser) are
still covered by this copyright. The main portion is covered by the usual
cc65 license, which reads:</P>
<P>This software is provided 'as-is', without any expressed or implied
warranty.  In no event will the authors be held liable for any damages
arising from the use of this software.</P>
<P>Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:</P>
<P>
<OL>
<LI>  The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.</LI>
<LI>  Altered source versions must be plainly marked as such, and must not
be misrepresented as being the original software.</LI>
<LI>  This notice may not be removed or altered from any source
distribution.</LI>
</OL>
</P>

</BODY>
</HTML>