This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:multiasm:papc:chapter_6_12 [2025/11/16 15:44] – [Constants] ktokarz | en:multiasm:papc:chapter_6_12 [2026/02/27 02:10] (current) – [Statements] jtokarz | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== MASM basics | + | ====== MASM Basics |
| An assembler, understood as software that translates assembler source code into machine code, can be implemented in various ways. While the processor' | An assembler, understood as software that translates assembler source code into machine code, can be implemented in various ways. While the processor' | ||
| ===== Alphabet ===== | ===== Alphabet ===== | ||
| Line 198: | Line 198: | ||
| <code asm> | <code asm> | ||
| int_const1 EQU 5 ; no suffix by default decimal value | int_const1 EQU 5 ; no suffix by default decimal value | ||
| - | int_const_dec = 7 ; finished with " | + | int_const_dec = 7 ; finished with " |
| + | ; by default without suffix | ||
| int_const_binary = 100100101b | int_const_binary = 100100101b | ||
| int_const_octal = 372o ; finished with " | int_const_octal = 372o ; finished with " | ||
| int_const_hex = 0FFA4h | int_const_hex = 0FFA4h | ||
| - | int_const_expr = const_dec | + | int_const_expr = int_const_dec |
| </ | </ | ||
| Floating-point numeric constants can be defined with the **EQU** directive only. The number can be expressed in decimal or scientific notation. | Floating-point numeric constants can be defined with the **EQU** directive only. The number can be expressed in decimal or scientific notation. | ||
| Line 209: | Line 210: | ||
| real_const2 EQU 6.28e2 | real_const2 EQU 6.28e2 | ||
| </ | </ | ||
| - | Text string constants can be defined with **EQU** or **TEXTEQU** directives. Text constants assigned with the **EQU** directive can be redefined later in the program. The **TEXEQU** is considered a text macro and is described in the section about macros. | + | Text string constants can be defined with **EQU** or **TEXTEQU** directives. Text constants assigned with the **EQU** or **TEXTEQU** directive can be redefined later in the program. The **TEXTEQU** is considered a text macro and is described in the section about macros. |
| <code asm> | <code asm> | ||
| text_const1 EQU 'Hello World!' | text_const1 EQU 'Hello World!' | ||
| text_const2 EQU "Hello World!" | text_const2 EQU "Hello World!" | ||
| </ | </ | ||
| - | |||
| - | Integer constants: | ||
| - | binary, 1b, 0101B, -10y, 111111Y | ||
| - | octal, 34o, -746O, 2167q, 0Q | ||
| - | decimal, 39, 12d, 1200D, -90t, 56T | ||
| - | hex, 0h, 14A6h, 0FE3H | ||
| - | .RADIX base directive: | ||
| - | (.RADIX 16) | ||
| - | Floating point constants: | ||
| - | decimal notation, 1.0, 3.1415, -0.5 | ||
| - | exponent notation, 1e5, 1.56e-2, -15.7e+12 | ||
| - | |||
| - | String is an array of characters. | ||
| - | ‘Hello world’ | ||
| - | ”123*x=??? | ||
| - | Equal notations: | ||
| - | mov BH,’A’ | ||
| - | mov BH,”A” | ||
| - | mov BH,41h | ||
| Line 261: | Line 243: | ||
| All fields in a statement are optional. A statement can be composed of a label only (ended with a colon), an operation only (if it doesn' | All fields in a statement are optional. A statement can be composed of a label only (ended with a colon), an operation only (if it doesn' | ||
| <code asm> | <code asm> | ||
| - | ; name ; operation ; operands ; comment | + | ; name ; operation ; operands ; comment |
| - | cns_y EQU | + | cns_y |
| + | ; value 134 | ||
| - | .DATA ; operation only - directive to start data section | + | |
| - | var_x DB 123 ; definition of a variable named var_x with init value 123 | + | var_x |
| + | ; value 123 | ||
| - | .CODE ; operation only - directive to start code section | + | |
| - | begin: | + | begin: |
| - | | + | mov rax, rbx ; operation and corresponding operands |
| - | | + | ; comment only statement |
| - | | + | END ; operation only - end of the source file |
| </ | </ | ||