Chapter 3 - Assembly Language Fundamentals

Data-Defining Pseudo-Operations

A data segment contains static data described by a sequence of data defining assembler pseudo-ops. These pseudo-ops provide information such as:

  1. Symbolic names associated with specific locations within the data segment
  2. The size associated with the particular data being defined
  3. Initial value(s) to be placed in a specific location within the data segment
  4. Symbolic names to be associated with hard coded constant values

Variables are defined using one of the following assembler pseudo-ops:
  1. BYTE - unsigned integer 8-bits
  2. SBYTE - signed integer 8-bits
  3. WORD - unsigned integer 16-bits
  4. SWORD - signed integer 16-bits
  5. DWORD - unsigned integer 32-bits
  6. SDWORD - signed integer 32-bits
  7. FWORD - Far pointer 48-bits
  8. REAL4 - IEEE 754 short real 32-bits
  9. REAL8 - IEEE 754 long real 64-bits
  10. REAL10 - IEEE 754 extended real 80-bits
There are many other data defining pseudo-ops but we will concentrate on these for the time being.

The general form for the above pseudo-ops is:

[<name>] pseudoop <constant-list> [<comment>] where

<name> - is the symbolic name associated with the memory location
pseudoop - is one of the MASM defined pseudo-ops
<constant-list> - is a list of constants separated by commas
[<comment>] - is a comment preceded by a semicolon

Note: The brackets signify optional

Let's look specifically at: [<name>] BYTE <byte-constant-list>

Example: max byte 7

A byte constant is one of the following:

  1. binary byte constant - is a signed/unsigned binary string of up to 8 binary digits followed by the letter B or b.
  2. octal byte constant - similar except followed by O,o,Q,q and lies in the range of 0 to 377.
  3. hex byte constant - similar except followed by H or h and the first character must be a digit 0 to 9 so the hex value FA would be written as 0FAH. Why precede the hex constant by a digit 0 to 9? The range is 00 to FF.
  4. decimal byte constant - similar except followed by D or d and the range is 0 to 255.
  5. string - a string of characters is enclosed in single or double quotes in which each character is an ASCII byte.
  6. ? - a question mark signifies that a byte of storage is to be allocated but the value is unspecified.

Note1: A symbolic name is associated with the first byte of the constant list.

Note2: A minus sign in front of a constant signifies to the assembler to take the two's complement of the binary representation of the number.

P#1: Translate all of the following to HEX:

.data
bvalues	byte 12,011b,1011b,'A'
	sbyte 0fah,073q,-12,-0ffh


SYMBOLIC NAME	BYTE OFFSET	HEX CONTENTS
-------------   -----------     ------------	

The WORD pseudo-op works similarly to the BYTE except that remember a word is stored in memory with bytes reversed (low byte, high byte).

P#2: Translate all of the following to HEX:

.data
wvalues	SWORD ?,-377Q,012ABH
minus1	SWORD -1


SYMBOLIC NAME   BYTE OFFSET     HEX CONTENTS
-------------   -----------     ------------

The duplicate clause can be used for a constant list that contains repetition. The general form is:

<repeat-count> DUP (<constant-list>)

where the <constant-list> is to be duplicated <repeat-count> times in succession. Duplicate clauses can be nested.

As examples, 6 DUP(0) implies 0,0,0,0,0,0 and 3 DUP(3 DUP(0),1) implies 0,0,0,1,0,0,0,1,0,0,0,1

P#3: Translate the following to HEX:


.data
prompt	sbyte  'A'
n	sword  ?
arry	sword  5 dup(0,1)
flag	sbyte  -2
ans	sword  -17q
data	ends

SYMBOLIC NAME   BYTE OFFSET     HEX CONTENTS
-------------   -----------     ------------

The final topic of discussion revolves around constants. There are two kinds of constant definitions: (1) EQU and (2) .CONST.

EQU - this pseudo-op assigns a symbolic name to a constant value. This symbolic name can then be used within the assembly language program. This symbolic name is more meaningful and just a constant value and thus improves the readability of the program.

Example:  false equ 0
	  true equ 1

A symbolic constant is only known during the assembly process, i.e. the assembler changes all occurrences of the symbol to the actual value during translation.


©Douglas J. Ryan/ryandj@pacificu.edu