Computer Organization and
Assembly Language
Lecture 3 – Assembly Language
Fundamentals
Basic Elements of Assembly Language
An assembly language program is composed of :
• Constants
• Expressions
• Literals
• Reserved Words
• Mnemonics
• Identifiers
• Directives
• Instructions
• Comments
Integer Constants
• Integer constants can be written in decimal,
hexadecimal, octal or binary, by adding a radix (or
number base) suffix to the end .
• Radix Suffices:
– d
decimal (the default)
– h
hexadecimal
– q or o
octal
– b
binary
Examples of Integer Constants
•
26
Decimal
•
1Ah
Hexadecimal
•
1101b
Binary
•
36q
Octal
•
2Bh
Hexadecimal
•
42Q
Octal
•
36D
Decimal
•
47d
Decimal
Integer Expressions
• An integer expressions is a mathematical
expressions involving integer values and integer
operators.
•
The expressions must be one that can be stored in
32 bits (or less).
•
The precedence:
– ( )
Expressions in Parentheses
– +, -
Unary Plus and minus
– *, /, Mod
Multiply, Divide, Modulus
– +, -
Add, Subtract
Examples of Integer Expressions
(4 + 2) * 6
12 – 1 MOD 5
-5 + 2
1
4 + 5 * 2
20
-3 + 4 * 6 – 1
-35
- (3 + 4) * (6 – 1)
3
16 / 5
Value
Expression
Real Number Constants
• There are two types of real number constants:
– Decimal reals, which contain a sign followed
by a number with decimal fraction and an
exponent:
[sign] integer.[integer][exponent]
Examples:
2.
+3.0 -44.2E+05 26.E5
– Encoded reals, which are represented exactly
as they are stored:
3F80000r
Characters Constants
• A character constant is a single character
enclosed in single or double quotation
marks.
• The assembler converts it to the equivalent
value in the binary code ASCII:
‘A’
“d”
String Constants
• A string constant is a string of characters
enclosed in single or double quotation
marks:
‘ABC’
“x”
“Goodnight, Gracie”
‘4096’
“This isn’t a test”
‘Say “Goodnight, ” Gracie’
Reserved Words
• Reserved words have a special meaning to the
assembler and cannot be used for anything other
than their specified purpose.
• They include:
– Instruction mnemonics
– Directives
– Op