You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Assembly language serves many purposes, such as improving program speed, reducing memory needs, and controlling hardware. You can use the inline assembler to embed assembly-language instructions directly in your C and C++ source programs without extra assembly and link steps. The inline assembler is built into the compiler, so you don't need a separate assembler such as the Microsoft Macro Assembler (MASM).
12
12
13
13
> [!NOTE]
14
-
> Programs with inline assembler code are not fully portable to other hardware platforms. If you are designing for portability, avoid using inline assembler.
14
+
> Programs with inline assembler code are not fully portable to other hardware platforms. If you are designing for portability, avoid using inline assembler.
15
15
16
16
Inline assembly is not supported on the ARM and x64 processors. The following topics explain how to use the Visual C/C++ inline assembler with x86 processors:
Copy file name to clipboardExpand all lines: docs/assembler/inline/using-and-preserving-registers-in-inline-assembly.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ You should preserve other registers you use (such as DS, SS, SP, BP, and flags r
21
21
Some SSE types require eight-byte stack alignment, forcing the compiler to emit dynamic stack-alignment code. To be able to access both the local variables and the function parameters after the alignment, the compiler maintains two frame pointers. If the compiler performs frame pointer omission (FPO), it will use EBP and ESP. If the compiler does not perform FPO, it will use EBX and EBP. To ensure code runs correctly, do not modify EBX in asm code if the function requires dynamic stack alignment as it could modify the frame pointer. Either move the eight-byte aligned types out of the function, or avoid using EBX.
22
22
23
23
> [!NOTE]
24
-
> If your inline assembly code changes the direction flag using the STD or CLD instructions, you must restore the flag to its original value.
24
+
> If your inline assembly code changes the direction flag using the STD or CLD instructions, you must restore the flag to its original value.
This page contains a BNF description of the MASM grammar. It is provided as a supplement to the reference topics and is not guaranteed to be complete. Please consult the reference topics for full information on keywords, parameters, operations and so on.
@@ -818,7 +817,7 @@ The BNF grammar allows recursive definitions. For example, the grammar uses qual
Copy file name to clipboardExpand all lines: docs/atl-mfc-shared/basic-cstring-operations.md
+5-5
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ This topic explains the following basic [CString](../atl-mfc-shared/reference/cs
26
26
27
27
Note: `CString` is a native class. For a string class that is for use in a C++/CLI managed project, use `System.String`.
28
28
29
-
## <aname="_core_creating_cstring_objects_from_standard_c_literal_strings"></a> Creating CString Objects from Standard C Literal Strings
29
+
## <aname="_core_creating_cstring_objects_from_standard_c_literal_strings"></a> Creating CString Objects from Standard C Literal Strings
30
30
31
31
You can assign C-style literal strings to a `CString` just as you can assign one `CString` object to another.
32
32
@@ -43,19 +43,19 @@ You can assign C-style literal strings to a `CString` just as you can assign one
43
43
> [!NOTE]
44
44
> To write your application so that it can be compiled for Unicode or for ANSI, code literal strings by using the _T macro. For more information, see [Unicode and Multibyte Character Set (MBCS) Support](../atl-mfc-shared/unicode-and-multibyte-character-set-mbcs-support.md).
45
45
46
-
## <aname="_core_accessing_individual_characters_in_a_cstring"></a> Accessing Individual Characters in a CString
46
+
## <aname="_core_accessing_individual_characters_in_a_cstring"></a> Accessing Individual Characters in a CString
47
47
48
48
You can access individual characters in a `CString` object by using the `GetAt` and `SetAt` methods. You can also use the array element, or subscript, operator ( [] ) instead of `GetAt` to get individual characters. (This resembles accessing array elements by index, as in standard C-style strings.) Index values for `CString` characters are zero-based.
49
49
50
-
## <aname="_core_concatenating_two_cstring_objects"></a> Concatenating Two CString Objects
50
+
## <aname="_core_concatenating_two_cstring_objects"></a> Concatenating Two CString Objects
51
51
52
52
To concatenate two `CString` objects, use the concatenation operators (+ or +=), as follows.
At least one argument to the concatenation operators (+ or +=) must be a `CString` object, but you can use a constant character string (for example, `"big"`) or a **char** (for example, 'x') for the other argument.
The `Compare` method and the == operator for `CString` are equivalent. `Compare`, **operator==**, and `CompareNoCase` are MBCS and Unicode aware; `CompareNoCase` is also case-insensitive. The `Collate` method of `CString` is locale-sensitive and is often slower than `Compare`. Use `Collate` only where you must abide by the sorting rules as specified by the current locale.
61
61
@@ -71,7 +71,7 @@ The `CStringT` class template defines the relational operators (<, \<=, >=, >, =
For information about converting CString objects to other string types, see [How to: Convert Between Various String Types](../text/how-to-convert-between-various-string-types.md).
This article explains how to pass [CString](../atl-mfc-shared/reference/cstringt-class.md) objects to functions and how to return `CString` objects from functions.
When you define a class interface, you must determine the argument-passing convention for your member functions. There are some standard rules for passing and returning `CString` objects. If you follow the rules described in [Strings as Function Inputs](#_core_strings_as_function_inputs) and [Strings as Function Outputs](#_core_strings_as_function_outputs), you will have efficient, correct code.
14
14
15
-
## <aname="_core_strings_as_function_inputs"></a> Strings as Function Inputs
15
+
## <aname="_core_strings_as_function_inputs"></a> Strings as Function Inputs
16
16
17
17
The most efficient and secure way to use a `CString` object in called functions is to pass a `CString` object to the function. Despite the name, a `CString` object does not store a string internally as a C-style string that has a null terminator. Instead, a `CString` object keeps careful track of the number of characters it has. Having `CString` provide a LPCTSTR pointer to a null-terminated string is a small amount of work that can become significant if your code has to do it constantly. The result is temporary because any change to the `CString` contents invalidates old copies of the LPCTSTR pointer.
18
18
19
19
It does make sense in some cases to provide a C-style string. For example, there can be a situation where a called function is written in C and does not support objects. In this case, coerce the `CString` parameter to LPCTSTR, and the function will get a C-style null-terminated string. You can also go the other direction and create a `CString` object by using the `CString` constructor that accepts a C-style string parameter.
20
20
21
21
If the string contents are to be changed by a function, declare the parameter as a nonconstant `CString` reference (`CString&`).
22
22
23
-
## <aname="_core_strings_as_function_outputs"></a> Strings as Function Outputs
23
+
## <aname="_core_strings_as_function_outputs"></a> Strings as Function Outputs
24
24
25
25
Typically you can return `CString` objects from functions because `CString` objects follow value semantics like primitive types. To return a read-only string, use a constant `CString` reference (`const CString&`). The following example illustrates the use of `CString` parameters and return types:
## <aname="_core_using_cstring_as_a_c.2d.style_null.2d.terminated_string"></a> Using CString as a C-Style Null-Terminated String
25
+
## <aname="_core_using_cstring_as_a_c.2d.style_null.2d.terminated_string"></a> Using CString as a C-Style Null-Terminated String
26
26
27
27
To use a `CString` object as a C-style string, cast the object to LPCTSTR. In the following example, the `CString` returns a pointer to a read-only C-style null-terminated string. The `strcpy` function puts a copy of the C-style string in the variable `myString`.
28
28
@@ -41,13 +41,13 @@ Sometimes you may require a copy of `CString` data to modify directly. Use the m
41
41
> [!NOTE]
42
42
> The third argument to `strcpy_s` (or the Unicode/MBCS-portable `_tcscpy_s`) is either a `const wchar_t*` (Unicode) or a `const char*` (ANSI). The example above passes a `CString` for this argument. The C++ compiler automatically applies the conversion function defined for the `CString` class that converts a `CString` to an `LPCTSTR`. The ability to define casting operations from one type to another is one of the most useful features of C++.
43
43
44
-
## <a name="_core_working_with_standard_run.2d.time_library_string_functions"></a> Working with Standard Run-Time Library String Functions
44
+
## <a name="_core_working_with_standard_run.2d.time_library_string_functions"></a> Working with Standard Run-Time Library String Functions
45
45
46
46
You should be able to find a `CString` method to perform any string operation for which you might consider using the standard C run-time library string functions such as `strcmp` (or the Unicode/MBCS-portable `_tcscmp`).
47
47
48
48
If you must use the C run-time string functions, you can use the techniques described in _core_using_cstring_as_a_c.2d.style_null.2d.terminated_string. You can copy the `CString` object to an equivalent C-style string buffer, perform your operations on the buffer, and then assign the resulting C-style string back to a `CString` object.
In most situations, you should use `CString` member functions to modify the contents of a `CString` object or to convert the `CString` to a C-style character string.
53
53
@@ -63,15 +63,15 @@ The `GetBuffer` and `ReleaseBuffer` methods offer access to the internal charact
63
63
64
64
1. Call `ReleaseBuffer` for the `CString` object to update all the internal `CString` state information, for example, the length of the string. After you modify the contents of a `CString` object directly, you must call `ReleaseBuffer` before you call any other `CString` member functions.
65
65
66
-
## <a name="_core_using_cstring_objects_with_variable_argument_functions"></a> Using CString Objects with Variable Argument Functions
66
+
## <a name="_core_using_cstring_objects_with_variable_argument_functions"></a> Using CString Objects with Variable Argument Functions
67
67
68
68
Some C functions take a variable number of arguments. A notable example is `printf_s`. Because of the way this kind of function is declared, the compiler cannot be sure of the type of the arguments and cannot determine which conversion operation to perform on each argument. Therefore, it is essential that you use an explicit type cast when passing a `CString` object to a function that takes a variable number of arguments.
69
69
70
70
To use a `CString` object in a variable argument function, explicitly cast the `CString` to an LPCTSTR string, as shown in the following example.
For most functions that need a string argument, it is best to specify the formal parameter in the function prototype as a `const` pointer to a character (`LPCTSTR`) instead of a `CString`. When a formal parameter is specified as a `const` pointer to a character, you can pass either a pointer to a TCHAR array, a literal string [`"hi there"`], or a `CString` object. The `CString` object will be automatically converted to an LPCTSTR. Any place you can use an LPCTSTR, you can also use a `CString` object.
Copy file name to clipboardExpand all lines: docs/atl-mfc-shared/date-type.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -47,7 +47,7 @@ The following points should be noted when working with these date and time forma
47
47
|2 January 1900, midnight|3.00|
48
48
49
49
> [!CAUTION]
50
-
> Note that because 6:00 AM is always represented by a fractional value 0.25 regardless of whether the integer representing the day is positive (after December 30, 1899) or negative (before December 30, 1899), a simple floating point comparison would erroneously sort any DATE representing 6:00 AM on a day earlier than 12/30/1899 as *later* than a DATE representing 7:00 AM on that same day.
50
+
> Note that because 6:00 AM is always represented by a fractional value 0.25 regardless of whether the integer representing the day is positive (after December 30, 1899) or negative (before December 30, 1899), a simple floating point comparison would erroneously sort any DATE representing 6:00 AM on a day earlier than 12/30/1899 as *later* than a DATE representing 7:00 AM on that same day.
51
51
52
52
More information on issues related to the DATE and `COleDateTime` types can be found under [COleDateTime Class](../atl-mfc-shared/reference/coledatetime-class.md) and [Date and Time: Automation Support](../atl-mfc-shared/date-and-time-automation-support.md).
0 commit comments