Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:multiasm:papc:chapter_6_12 [2025/11/16 12:48] – [Data definition directives] ktokarzen:multiasm:papc:chapter_6_12 [2025/11/17 08:33] (current) – [Constants] ktokarz
Line 193: Line 193:
  
 ===== Constants ===== ===== Constants =====
 +Constants in an assembler program define the name for the value that can't be changed during normal program execution. It is the assembly-time assignment of the value and its name. Although their name suggests that their value can't be altered, it is true at the program run-time. Some forms of constants can be modified during assembly time. Usually, constants are used to self-document the code, parameterise the assembly process, and perform assembly-time calculations.
 +The constants can be integer, floating-point numeric, or text strings.\\
 +Integer numeric constants can be defined with the data assignment directives, **EQU** or the equal sign **=**. The difference is that a numeric constant defined with the EQU directive can’t be modified later in the program, while a constant created with the equal sign can be redefined many times in the program. Numeric constants can be expressed as binary, octal, decimal or hexadecimal values. They can also be a result of an expression calculated during assembly time. It is possible to use a previously defined constant in such an expression.
 +<code asm>
 +int_const1 EQU 5                ; no suffix by default decimal value
 +int_const_dec = 7               ; finished with "d", "D", "t", "T", or by default without suffix
 +int_const_binary = 100100101b   ; finished with "b", "B", "y", or "Y"
 +int_const_octal = 372o          ; finished with "o", "O", "q", or "Q"
 +int_const_hex = 0FFA4h          ; finished with "h", or "H"
 +int_const_expr = int_const_dec * 5
 +</code> 
 +Floating-point numeric constants can be defined with the **EQU** directive only. The number can be expressed in decimal or scientific notation.
 +<code asm> 
 +real_const1 EQU 3.1415          ; decimal
 +real_const2 EQU 6.28e2          ; scientific
 +</code>
 +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 **TEXEQU** is considered a text macro and is described in the section about macros.
 +<code asm>
 +text_const1 EQU 'Hello World!'
 +text_const2 EQU "Hello World!"
 +</code>
 +
 +
 ===== Conditional assembly directives ===== ===== Conditional assembly directives =====
  
en/multiasm/papc/chapter_6_12.1763297304.txt.gz · Last modified: 2025/11/16 12:48 by ktokarz
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0