Program Sections

Section

Description

data section

  • used for declaring initialized data or constants
  • data does not change in runtime

the syntax for declaring a data section

section.data

bss section

  • used for declaring variables

the syntax for declaring a bss section

section.bss

text section

  • used for keeping the actual code

the syntax for declaring a text section

section.text
	global _start
_start:

this section must begin with the declaration global _start, which tells the kernel where the program execution begins

Statement Types

Statement Type

Description

instruction

  • simply tell the processor what to do
  • each instruction consists of an opcode

assembler directive

or

pseudo-op

  • tells the assembler about the various aspects of the assembly process
  • are non-executable and do not generate machine language instructions

macro

  • simply a text substitution

Syntax of a Statement

[label]	mnemonic	[operands]	[;comment]

some examples of typical statements

INC COUNT		; Increment the memory variable COUNT

MOV TOTAL, 48	; Transfer the value 48 in the memory variable TOTAL

ADD AH, BH		; Add the content of the BH register into the AH register

AND MASK1, 128	; Perform AND operation on the variable MASK1 and 128

ADD MARKS, 10	; Add 10 to the variable MARKS

MOV AL, 10 		; Transfer the value 10 to the AL register