Skip to content

Commit 1347a2f

Browse files
Version 4.3.1
1 parent e34945f commit 1347a2f

File tree

164 files changed

+2283
-679
lines changed

Some content is hidden

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

164 files changed

+2283
-679
lines changed

Docs/CommandLineOptions.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,15 @@ If any defined sections are not used, do not emit a warning.
312312
// do not warn if "zp" is never used
313313
```
314314

315+
**`--Wregister-as-identifier`**
316+
317+
Warn when a constant, label, or variable shares the same name as a CPU register.
318+
319+
```
320+
.cpu "z80"
321+
ix = 0
322+
```
323+
315324
**`--Wsimplify-call-return`**
316325

317326
If a return instruction immediately follows a call instruction, warn that the two instructions can be combined into a single jump instruction.

Docs/CommodoreControlCodes.md

Lines changed: 837 additions & 0 deletions
Large diffs are not rendered by default.

Docs/Expressions.md

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,14 @@ The `.unamp` directive will delete the custom encoding for the codepoint or rang
229229

230230
The assembler can be directed to encode string literals explicitly regardless of the active encoding, according to their prefix:
231231

232-
| Prefix | Encoding | Example |
233-
|--------|----------|------------------------------------|
234-
| None | Current | `"HI" // by default 48 49` |
235-
| `u8` | UTF-8 | `u8"HI" // 48 49` |
236-
| `u` | UTF-16 | `u"HI" // 48 00 49 00` |
237-
| `U` | UTF-32 | `U"HI" // 48 00 00 00 49 00 00 00` |
232+
| Prefix | Encoding | Example |
233+
|--------|--------------------------|------------------------------------|
234+
| None | Current | `"HI" // by default 48 49` |
235+
| `p` | PETSCII | `p"HI" // c8 c9` |
236+
| `s` | Commodore screen codes | `s"HI" // 08 09` |
237+
| `u8` | UTF-8 | `u8"HI" // 48 49` |
238+
| `u` | UTF-16 | `u"HI" // 48 00 49 00` |
239+
| `U` | UTF-32 | `U"HI" // 48 00 00 00 49 00 00 00` |
238240

239241
#### Escape sequences
240242

@@ -278,6 +280,36 @@ In the above example, the expression can be transformed with format specifiers:
278280
.string $"Start address: ${START:X4}" // Becomes "Start address: $C000"
279281
```
280282

283+
To represent a curly brace within the string itself, add an extra brace (`{` for left or `}` for right):
284+
285+
.string $"{{HI}}" // Becomes "{HI}"
286+
287+
#### Commodore Control Codes
288+
289+
For PETSCII and screen code encodings, the assembler also recognizes control codes found in program listings of various Commodore references and related magazines, such as [Compute's Gazette](https://archive.org/details/computes.gazette/Compute_Gazette_Issue_01_1983_Jul/):
290+
291+
```
292+
.string p"{CLR}{HOME}" // > 93 13
293+
.encoding "cbmscreen"
294+
.string "{SPACE}{UP ARROW}" // > 20 1e
295+
```
296+
297+
If the string is an interpolated string, care must be taken in adding control codes since in interpolated strings curly braces mark the boundaries of interpolated expressions:
298+
299+
```
300+
.encoding "petscii"
301+
.string $"{CLR}{HOME}{3+2}"
302+
```
303+
304+
The above would give an error (or an unexpected result if `CLR` and `HOME` are labels). To fix that simply escape the braces themselves:
305+
306+
```
307+
.encoding "petscii"
308+
.string $"{{CLR}}{{HOME}}{3+2}" // > 93 13 35
309+
```
310+
311+
See [here](/Docs/CommodoreControlCodes.md) for a full listing of all valid control codes for these two encodings.
312+
281313
#### Char Methods
282314

283315
| Method name | Purpose | Example |

Docs/SymbolsAndScopes.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ Like standard labels, anonymous labels can be used in expressions as well:
4040
lda (-) + 2,x // read second from offset from backward reference.
4141
```
4242

43-
# Constants and Variables
43+
## Constants and Variables
4444

45-
## Constants
45+
### Constants
4646

4747
Constants are symbols that, like labels, make it convenient to represent addresses or values referenced from other parts of code.
4848

@@ -57,7 +57,7 @@ CHRIN .equ $ffcf
5757

5858
Constants can be forward referenced, and can only be assigned once--as they are constant, their values cannot be changed.
5959

60-
## Variables
60+
### Variables
6161

6262
Variables are symbols assigned to values that can be changed as often as needed. The assignment `:=` operator can declares a new variable or re-assign the contents of an existing variable to a new value.
6363

@@ -279,7 +279,7 @@ label nop
279279

280280
# Symbols and Reserved Words
281281

282-
User-defined symbols cannot share with mnemonics and registers of the current target CPU, unless their case does not match and the assembler is set to case-sensitive. For instance, in 6502 mode all of the 56 6502 mnemonics and `a`, `x`, and `y` are reserved and cannot be used for label or constant names.
282+
User-defined symbols cannot share the same name as mnemonics of the current target CPU, unless their case does not match and the assembler is set to case-sensitive. For instance, in 6502 mode all of the 56 6502 mnemonics are reserved and cannot be used for label or constant names.
283283

284284
```
285285
lda nop // this would error "lda" cannot be used as a label
@@ -288,6 +288,16 @@ lda nop // this would error "lda" cannot be used as a label
288288
Lda nop // no error
289289
```
290290

291+
Symbols can share names with registers, but the presence of a register in an operand for a CPU instruction might cause an unexpected compilation result or even an error. To avoid this you would need to refactor the operand expression.
292+
293+
```
294+
a = 3
295+
asl a // The assembler interprets 'a' not as an address but as
296+
// the accumulator register
297+
298+
asl a+0 // The assembler interprets 'a' as a constant (the address 3)
299+
```
300+
291301
## Other Topics
292302

293303
* [Getting Started](/Docs/GettingStarted.md)

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2017-2023 informedcitizenry <[email protected]>
3+
Copyright (c) 2017-2024 informedcitizenry <[email protected]>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 6502.Net, A .Net-Based Cross-Assembler for Several 8-Bit Microprocessors.
22

3-
Version 4.2.2
3+
Version 4.3.1
44

55
## Overview
66

Sixty502DotNet.Shared/CodeGen/Architecture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//-----------------------------------------------------------------------------
2-
// Copyright (c) 2017-2023 informedcitizenry <[email protected]>
2+
// Copyright (c) 2017-2024 informedcitizenry <[email protected]>
33
//
44
// Licensed under the MIT license. See LICENSE for full license information.
55
//

Sixty502DotNet.Shared/CodeGen/CodeAnalysisContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//-----------------------------------------------------------------------------
2-
// Copyright (c) 2017-2023 informedcitizenry <[email protected]>
2+
// Copyright (c) 2017-2024 informedcitizenry <[email protected]>
33
//
44
// Licensed under the MIT license. See LICENSE for full license information.
55
//

Sixty502DotNet.Shared/CodeGen/CodeOutput.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//-----------------------------------------------------------------------------
2-
// Copyright (c) 2017-2023 informedcitizenry <[email protected]>
2+
// Copyright (c) 2017-2024 informedcitizenry <[email protected]>
33
//
44
// Licensed under the MIT license. See LICENSE for full license information.
55
//

Sixty502DotNet.Shared/CodeGen/Encoders/CpuEncoderBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
//-----------------------------------------------------------------------------
2-
// Copyright (c) 2017-2023 informedcitizenry <[email protected]>
2+
// Copyright (c) 2017-2024 informedcitizenry <[email protected]>
33
//
44
// Licensed under the MIT license. See LICENSE for full license information.
55
//
66
//-----------------------------------------------------------------------------
7-
7+
88
using System.Text;
99

1010
namespace Sixty502DotNet.Shared;

0 commit comments

Comments
 (0)