Skip to content

Repo sync for protected CLA branch #3886

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 74 additions & 32 deletions docs/assembler/arm/arm-assembler-command-line-reference.md
Original file line number Diff line number Diff line change
@@ -1,78 +1,120 @@
---
title: "ARM Assembler command-line reference"
description: "Reference guide to the Microsoft ARM assembler command-line options."
ms.date: "02/09/2020"
ms.date: 05/09/2022
ms.assetid: f7b89478-1ab5-4995-8cde-a805f0462c45
---
# ARM Assembler command-line reference

This article provides command-line information about the Microsoft ARM assembler, **armasm**. **armasm** assembles ARMv7 Thumb assembly language into the Microsoft implementation of the Common Object File Format (COFF). The linker can link COFF code objects produced by both the ARM assembler and the C compiler. It can link either together with object libraries created by the librarian.
The Microsoft ARM assemblers, **armasm** and **armasm64**, support several command-line options. By default, **armasm** assembles ARMv7 Thumb assembly language into the Microsoft implementation of the Common Object File Format (COFF). The **armasm64** assembler creates COFF object code for ARM64 and ARM64EC targets. The linker can link COFF code objects produced by both the ARM assembler and the C/C++ compiler. It can link either together with object libraries created by the librarian.

## Syntax

> **`armasm`** [*options*] *source_file* *object_file*\
> **`armasm`** [*options*] **`-o`** *object_file* *source_file*
> **`armasm`** [*options*] *source_file*

> **`armasm64`** [*options*] *source_file* *object_file*\
> **`armasm64`** [*options*] *source_file*

### Parameters

*options*\
A combination of zero or more of the following options:

- **`-16`**\
Available only in **armasm**. Assemble source as 16-bit Thumb instructions. This option is the default.

- **`-32`**\
Available only in **armasm**. Assemble source as 32-bit ARM instructions.

- **`-coff_thumb2_only`**\
Available only in **armasm**. Allow only Thumb-2 code.

- **`-errorReport:`** *option*\
This option is deprecated. In Windows Vista and later, error reporting is controlled by [Windows Error Reporting (WER)](/windows/win32/wer/windows-error-reporting) settings.

- **`-errors`** *filename*\
Redirect error and warning messages to *filename*.
**`-e`** *filename*\
Redirect error and warning messages to *filename*. By default, these messages are sent to `stdout`.

- **`-i`** *dir*[**`;`**<em>dir</em>]\
Add the specified directories to the include search path.
- **`-funcOverride:`** *function_name*\
Available only in **armasm64**. Emit function overriding support for *function_name*.

- **`-predefine`** *directive*\
Specify a SETA, SETL, or SETS directive to predefine a symbol.\
Example: `armasm.exe -predefine "COUNT SETA 150" source.asm`\
For more information, see the [ARM Compiler armasm Reference Guide](https://developer.arm.com/documentation/dui0802/latest/).
- **`-g`**\
Generate debugging information.

- **`-nowarn`**\
Disable all warning messages.
- **`-gh:SHA1`**\
Use the SHA-1 cryptographic hash algorithm to generate a checksum of each source file in debug info. Overrides **`-gh:SHA256`**.

- **`-ignore`** *warning*\
Disable the specified warning. For possible values, see the section about warnings.
- **`-gh:SHA256`**\
Use the SHA-256 cryptographic hash algorithm to generate a checksum of each source file in debug info. This option is on by default in Visual Studio 2022 version 17.0 and later.

- **`-guard:ehcont`**[**`-`**]\
Generate a sorted list of the relative virtual addresses (RVA) of all the valid exception handling continuation targets for a binary. It's used at runtime for `NtContinue` and `SetThreadContext` instruction pointer validation. By default, **`-guard:ehcont`** is off and must be explicitly enabled. To explicitly disable this option, use **`-guard:ehcont-`**. This option is available in Visual Studio 2019 version 16.7 and later. The feature is supported for 64-bit processes on a 64-bit OS.

- **`-help`**\
Print the command-line help message.
**`-h`**\
Print the command-line help message.

- **`-i`** *dir*[**`;`** *dir*]\
Add one or more specified directories to the include search path. Separate directories by using a semi-colon (`;`).

- **`-ignore`** *warning_number*\
Disable the specified warning number. For possible values, see [ARM Assembler diagnostic messages](arm-assembler-diagnostic-messages.md).

- **`-list`** *list_file*\
Create a detailed listing of the generated assembly language to *list_file*. The *list_file* parameter is optional. If it's omitted, the assembler appends *`.lst`* to the base name of *source_file* to create the listing file.

- **`-machine`** *machine*\
Specify the machine type to set in the PE header. Possible values for *machine* are:\
**ARM**—Sets the machine type to IMAGE_FILE_MACHINE_ARMNT. This option is the default.\
**THUMB**—Sets the machine type to IMAGE_FILE_MACHINE_THUMB.
Specify the machine type to set in the PE header. In **armasm**, possible values for *machine* are:
- **ARM**—Sets the machine type to `IMAGE_FILE_MACHINE_ARMNT`. This option is the default.
- **THUMB**—Sets the machine type to `IMAGE_FILE_MACHINE_THUMB`.

- **`-oldit`**\
Generate ARMv7-style IT blocks. By default, ARMv8-compatible IT blocks are generated.
In **armasm64**, possible values are:
- **ARM64**—Sets the machine type to `IMAGE_FILE_MACHINE_ARM64`. This option is the default.
- **ARM64EC**—Sets the machine type to `IMAGE_FILE_MACHINE_ARM64EC`.

- **`-via`** *filename*\
Read additional command-line arguments from *filename*.
- **`-noesc`**\
**`-noe`**\
Ignore C-style escaped special characters, such as `\n` or `\t`.

- **`-16`**\
Assemble source as 16-bit Thumb instructions. This option is the default.
- **`-nologo`**\
Suppress the copyright banner.

- **`-32`**\
Assemble source as 32-bit ARM instructions.
- **`-nowarn`**\
**`-now`**\
Disable all warning messages.

- **`-g`**\
Generate debugging information.
- **`-o`** *object_file*\
Specify the name of the object (output) file. The **`-o`** option is optional; you can instead specify an object file name as the last element of the command line.

- **`-errorReport:`** *option*\
This option is deprecated. Starting in Windows Vista, error reporting is controlled by [Windows Error Reporting (WER)](/windows/win32/wer/windows-error-reporting) settings.
- **`-oldit`**\
Available only in **armasm**. Generate ARMv7-style IT blocks. By default, ARMv8-compatible IT blocks are generated.

- **`-predefine`** *directive*\
**`-pd`** *directive*\
Specify a SETA, SETL, or SETS directive to predefine a symbol.\
Example: `armasm.exe -predefine "COUNT SETA 150" source.asm`\
For more information, see the [ARM Compiler armasm Reference Guide](https://developer.arm.com/documentation/dui0802/latest/).

- **`-sourcelink:`** *sourcelink_filename*\
*sourcelink_filename* specifies a JSON-formatted configuration file that contains a simple mapping of local file paths to URLs for source files to display in the debugger. For more information on the format of this file, see [Source Link JSON Schema](https://github.com/dotnet/designs/blob/master/accepted/2020/diagnostics/source-link.md#source-link-json-schema). Source Link is a language- and source-control agnostic system for providing source debugging for binaries. Source Link is supported for native binaries starting in Visual Studio 2017 version 15.8. For an overview of Source Link, see [Source Link](https://github.com/dotnet/designs/blob/master/accepted/2020/diagnostics/source-link.md). For information on how to use Source Link in your projects, and how to generate the SourceLink file as part of your project, see [Using Source Link](https://github.com/dotnet/sourcelink#using-source-link-in-c-projects).

- **`-via`** *filename*\
Read extra command-line arguments from *filename*.

*source_file*\
The name of the source file.

*object_file*\
The name of the object (output) file.
The last element of the command line can specify the name of the object (output) file. If it's omitted, and no **`-o`** option is specified, the assembler appends *`.obj`* to the base name of *source_file* to create the object file.

## Remarks

The following example demonstrates how to use armasm in a typical scenario. First, use armasm to build an assembly language source (.asm) file to an object (.obj) file. Then, use the CL command-line C compiler to compile a source (.c) file, and also specify the linker option to link the ARM object file.

```cmd
armasm myasmcode.asm -o myasmcode.obj
armasm -o myasmcode.obj myasmcode.asm
cl myccode.c /link myasmcode.obj
```

Expand Down
28 changes: 14 additions & 14 deletions docs/assembler/arm/arm-assembler-diagnostic-messages.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
---
description: "Learn more about: ARM Assembler diagnostic messages"
title: "ARM Assembler diagnostic messages"
ms.date: "08/30/2018"
ms.date: 05/09/2022
f1_keywords: ["A2193", "A2196", "A2202", "A2513", "A2557", "A4228", "A4508", "A4509"]
helpviewer_keywords: ["A2193", "A2196", "A2202", "A2513", "A2557", "A4228", "A4508", "A4509"]
ms.assetid: 52b38267-6023-4bdc-a0ef-863362f48eec
---
# ARM Assembler diagnostic messages

The Microsoft ARM assembler (*armasm*) emits diagnostic warnings and errors when it encounters them. This article describes the most commonly-encountered messages.
The Microsoft ARM assemblers, **armasm** and **armasm64**, emit diagnostic warnings and errors when they encounter them. This article describes the most commonly encountered messages.

## Syntax

> <em>filename</em>**(**<em>line-number</em>**) :** \[**error**|**warning**] **A**<em>number</em>**:** *message*
> *filename* **(** *line-number* **) :** \[**error**|**warning**] **A** *number* **:** *message*

## Diagnostic messages - Errors

> A2193: this instruction generates unpredictable behavior

The ARM architecture cannot guarantee what happens when this instruction is executed. For details about the well-defined forms of this instruction, consult the [ARM Architecture Reference Manual](https://go.microsoft.com/fwlink/p/?linkid=246464).
The ARM architecture can't guarantee what happens when this instruction is executed. For details about the well-defined forms of this instruction, consult the [ARM Architecture Reference Manual](https://go.microsoft.com/fwlink/p/?linkid=246464).

```asm
ADD r0, r8, pc ; A2193: this instruction generates unpredictable behavior
```

> A2196: instruction cannot be encoded in 16 bits

The specified instruction cannot be encoded as a 16-bit Thumb instruction. Specify a 32-bit instruction, or rearrange code to bring the target label into the range of a 16-bit instruction.
The specified instruction can't be encoded as a 16-bit Thumb instruction. Specify a 32-bit instruction, or rearrange code to bring the target label into the range of a 16-bit instruction.

The assembler may attempt to encode a branch in 16 bits and fail with this error, even though a 32-bit branch is encodable. You can solve this problem by using the `.W` specifier to explicitly mark the branch as 32-bit.

```asm
ADD.N r0, r1, r2 ; A2196: instruction cannot be encoded in 16 bits
ADD.N r0, r1, r2 ; A2196: instruction can't be encoded in 16 bits

B.W label ; OK
B.N label ; A2196: instruction cannot be encoded in 16 bits
B.N label ; A2196: instruction can't be encoded in 16 bits
SPACE 10000
label
```

> A2202: Pre-UAL instruction syntax not allowed in THUMB region

Thumb code must use the Unified Assembler Language (UAL) syntax. The old syntax is no longer accepted
Thumb code must use the Unified Assembler Language (UAL) syntax. The old syntax is no longer accepted

```asm
ADDEQS r0, r1 ; A2202: Pre-UAL instruction syntax not allowed in THUMB region
Expand All @@ -50,7 +50,7 @@ Thumb code must use the Unified Assembler Language (UAL) syntax. The old syntax

> A2513: Rotation must be even

In ARM mode, there is an alternate syntax for specifying constants. Instead of writing `#<const>`, you can write `#<byte>,#<rot>`, which represents the constant value that is obtained by rotating the value `<byte>` right by `<rot>`. When you use this syntax, you must make the value of `<rot>` even.
In ARM mode, there's an alternate syntax for specifying constants. Instead of writing `#<const>`, you can write `#<byte>,#<rot>`, which represents the constant value that's obtained by rotating the value `<byte>` right by `<rot>`. When you use this syntax, you must make the value of `<rot>` even.

```asm
MOV r0, #4, #2 ; OK
Expand All @@ -59,7 +59,7 @@ In ARM mode, there is an alternate syntax for specifying constants. Instead of

> A2557: Incorrect number of bytes to write back

On the NEON structure load and store instructions (`VLDn`, `VSTn`), there is an alternate syntax for specifying writeback to the base register. Instead of putting an exclamation point (!) after the address, you can specify an immediate value that indicates the offset to be added to the base register. If you use this syntax, you must specify the exact number of bytes that were loaded or stored by the instruction.
On the NEON structure load and store instructions (`VLDn`, `VSTn`), there's an alternate syntax for specifying writeback to the base register. Instead of putting an exclamation point (!) after the address, you can specify an immediate value that indicates the offset to be added to the base register. If you use this syntax, you must specify the exact number of bytes that were loaded or stored by the instruction.

```asm
VLD1.8 {d0-d3}, [r0]! ; OK
Expand All @@ -71,9 +71,9 @@ On the NEON structure load and store instructions (`VLDn`, `VSTn`), there is an

> A4228: Alignment value exceeds AREA alignment; alignment not guaranteed

The alignment that is specified in an `ALIGN` directive is greater than the alignment of the enclosing `AREA`. As a result, the assembler cannot guarantee that the `ALIGN` directive will be honored.
The alignment that's specified in an `ALIGN` directive is greater than the alignment of the enclosing `AREA`. As a result, the assembler can't guarantee that the `ALIGN` directive will be honored.

To fix this, you can specify on the `AREA` directive an `ALIGN` attribute that is equal to or greater than the desired alignment.
To fix this warning, you can specify on the `AREA` directive an `ALIGN` attribute that's equal to or greater than the desired alignment.

```asm
AREA |.myarea1|
Expand All @@ -85,7 +85,7 @@ ALIGN 8 ; OK

> A4508: Use of this rotated constant is deprecated

In ARM mode, there is an alternate syntax for specifying constants. Instead of writing `#<const>`, you can write `#<byte>,#<rot>`, which represents the constant value that is obtained by rotating the value `<byte>` right by `<rot>`. In some contexts, ARM has deprecated the use of these rotated constants. In these cases, use the basic `#<const>` syntax instead.
In ARM mode, there's an alternate syntax for specifying constants. Instead of writing `#<const>`, you can write `#<byte>,#<rot>`, which represents the constant value that's obtained by rotating the value `<byte>` right by `<rot>`. In some contexts, ARM has deprecated the use of these rotated constants. In these cases, use the basic `#<const>` syntax instead.

```asm
ANDS r0, r0, #1 ; OK
Expand All @@ -96,7 +96,7 @@ In ARM mode, there is an alternate syntax for specifying constants. Instead of

This form of conditional instruction has been deprecated by ARM in the ARMv8 architecture. We recommend that you change the code to use conditional branches. To see which conditional instructions are still supported, consult the [ARM Architecture Reference Manual](https://go.microsoft.com/fwlink/p/?linkid=246464).

This warning is not emitted when the **-oldit** command-line switch is used.
This warning isn't emitted when the **`-oldit`** command-line switch is used.

```asm
ADDEQ r0, r1, r8 ; A4509: This form of conditional instruction is deprecated
Expand Down
18 changes: 9 additions & 9 deletions docs/assembler/arm/arm-assembler-reference.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
---
description: "Learn more about: ARM Assembler Reference"
title: "ARM Assembler Reference"
ms.date: "08/28/2017"
description: "Learn more about: ARM Assembler reference"
title: "ARM Assembler reference"
ms.date: 05/09/2022
ms.assetid: f8a076cc-9627-4328-a34a-9c44f7a3aab1
---
# ARM Assembler Reference
# ARM Assembler reference

The articles in this section of the documentation provide reference material for the Microsoft ARM assembler (armasm) and related tools.
The articles in this section of the documentation provide reference material for the Microsoft ARM assembler (**armasm** or **armasm64**) and related tools.

## Related Articles
## Related articles

|Title|Description|
|-----------|-----------------|
|[ARM Assembler Command-Line Reference](../../assembler/arm/arm-assembler-command-line-reference.md)|Describes the armasm command-line options.|
|[ARM Assembler Diagnostic Messages](../../assembler/arm/arm-assembler-diagnostic-messages.md)|Describes commonly seen armasm warning and error messages.|
|[ARM Assembler Directives](../../assembler/arm/arm-assembler-directives.md)|Describes the ARM directives that are different in armasm.|
|[ARM Assembler command-line reference](../../assembler/arm/arm-assembler-command-line-reference.md)|Describes the Microsoft armasm and armasm64 command-line options.|
|[ARM Assembler diagnostic messages](../../assembler/arm/arm-assembler-diagnostic-messages.md)|Describes commonly seen armasm and armasm64 warning and error messages.|
|[ARM Assembler directives](../../assembler/arm/arm-assembler-directives.md)|Describes the ARM directives that are different in Microsoft armasm and armasm64.|
|[ARM Architecture Reference Manual](https://developer.arm.com/search#q=ARM%20Architecture%20Reference%20Manual) on the ARM Developer website.|Choose the relevant manual for your ARM architecture. Each contains reference sections about ARM, Thumb, NEON, and VFP, and additional information about the ARM assembly language.|
|[ARM Compiler armasm User Guide](https://developer.arm.com/search#q=ARM%20Compiler%20armasm%20User%20Guide) on the ARM Developer website.|Choose a recent version to find up-to-date information about the ARM assembly language.|

Expand Down
Loading