Arch - Basics - Assembly

Assembler Directives

Reference:

Assembler directives supply data to the program and control the assembly process. Directives are commands that are part of the assmbler syntax but are not related to the processor ISA. Assembler directives enable you to do the following:

  • Assemble code and data into specified sections
  • Reserve space in memory for uninitialized variables
  • Control the appearance of listings
  • Initialize memory
  • Assemble conditional blocks
  • Define global variables
  • Specify libraries from which the assembler can obtain macros
  • Examine symbolic debugging information

Assembler directives have names that begins with a period (.). The rest of the name is letters, ususally in lower case.

More directives

Call Frame Directives

Refrence: CFI (Call Frame Information) directives

  • .cfi_personality encoding [, exp]
  • .cfi_signal_frame
.set symbol, expression
.macro

.macro and .endm together defines a macro, which generates assembly code blocks.

Example:

.macro  sum from=0, to=5
.long   \from
.if     \to-\from
  sum     "(\from+1)",\to
.endif
.endm

will generate

.long   0
.long   1
.long   2
.long   3
.long   4
.long   5

Machine dependent directives

Machine Dependent directives for MIPS.

Example: MSP430: Directives that define sections

Reference: TI - MSP430 - Assembler Directives

MSP430 is a mixed-signal microcontroller, built around a 16-bit RISC CPU.

  • .bss directive reserves space in the .bss section for uninitialized variables.
  • .data directive identifies portions of code in the .data section. The .data section usually contains initialized data.
  • .intvec directive creates an interrupt vector entry that points to an interrupt routine name.
  • .retain directive can be used to indicate that the current of specified section must be included in the linked output. Thus even if no other sections included in the link reference the current or specified section, it is still included in the link.
  • .retainrefs directive can be used to force sections that refer to the specified section. This is useful in the case of interrupt vectors. How is it usefull ???
  • .sect directive defines an initialized named section and associates subsequent code or data with that section. A section defined with .sect can contain code or data.
  • .text directive identifies portions of code in the .text section. The .text section usually contains executable code.
  • .usect directive reserves space in an uninitialized named section. The .usect directive is similar to the .bss directive, but it allows you to reserve space separately from the .bss section.
Created Aug 30, 2019 // Last Updated Jul 19, 2020

If you could revise
the fundmental principles of
computer system design
to improve security...

... what would you change?