PROWAREtech

articles » current » assembly » x86 » tutorial » page-02

Intel IA-32 Assembly Tutorial - A Guide to the Basics of x86 Assembly - Page 02

More on the EFLAGS Register - Protected Mode - Language Elements (Reserved Words, Number Constants, Character Constants, String Constants, Identifiers).

EFLAGS has binary flags that either control the CPU operation or reflect the outcome of a CPU operation. Some machine instructions test and manipulate the processor flags. When the result of an unsigned arithmetic operation is too large to fit into the destination, the CF (Carry Flag) is set. When the result of a signed arithmetic operation is too wide to fit into the destination, the OF (Overflow Flag) is set. When the result of an arithmetic or logical operation creates a negative result, the SF (Sign Flag) is set. When the result of an arithmetic or logical operation creates result of zero, the ZF (Zero Flag) is set. The Auxiliary Carry flag is set when an arithmetic operation causes a carry from bit 3 to bit 4 in an 8-bit operand. The Parity flag sums the number of bits that are set in a number determining whether the sum is odd or even.

Protected Mode

Windows NT/2000/XP/Vista/7/8/8.1/10 run in protected mode. The segment registers (CS, DS, SS, ES, FS, GS) point to segment descriptor tables that the operating system uses to define the locations of individual program segments. A typical protected mode program has three segments: code, data and stack.

  • CS refers to the descriptor table for the code segment
  • DS refers to the descriptor table for the data segment
  • SS refers to the descriptor table for the stack segment

The Assembly Language Elements

Reserved Words

Reserved words can be:

  • Instruction mnemonics like MOV, ADD, SUB, MUL, DIV.
  • Directives which tell MASM how to assemble programs.
  • Attributes which provide size and usage information for variables and operands: BYTE, WORD, DWORD
  • Operators used in constant expressions
  • Predefined symbols such as @data which return constant integer values at assembly time.

Number Constants

hexadecimal9A3hh radix
binary010010bb radix
binary11010yy radix
decimal1390 
decimal2788dd radix
decimal2788tt radix
octal323oo radix
octal42qq radix

Character Constants

'A'
"W"

String Constants

'ABCDEFGHIJKLMNOPQRSTUVWXYZ',0
"Hello, World!",0
'90786',0
"Gracie's world",0
'The dog said "Woof!"',0

Notice that each string has a zero sentinal to terminate it.

Identifiers

An identifier is a programmer-created name. It may identify a constant, variable, procedure or code label. When creating identifiers, these rules apply:

  • They are not case sensitive.
  • Cannot be greater than 247 characters.
  • The first character must be a letter, underscore (_), @, or $. Following characters may have numbers.
  • Cannot be the same as a reserved word.

Directive Examples

  • DATA directive: .data (where global variables are defined)
  • CODE directive: .code
  • PROC directive: name_of_procedure PROC
<<<[Page 2 of 15]>>>

This site uses cookies. Cookies are simple text files stored on the user's computer. They are used for adding features and security to this site. Read the privacy policy.
CLOSE