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 1Ah 1101b 36q 2Bh 42Q 36D 47d Decimal Hexadecimal Binary Octal Hexadecimal Octal Decimal 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:
– – – – () +, *, /, Mod +, Expressions in Parentheses Unary Plus and minus Multiply, Divide, Modulus Add, Subtract
• •
Examples of Integer Expressions
Expression
16 / 5 - (3 + 4) * (6 – 1) -3 + 4 * 6 – 1 4 + 5 * 2 -5 + 2 12 – 1 MOD 5 (4 + 2) * 6
Value
3 -35 20 1
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