Computer Organization with Assembly

Topics: Source code, Executable, Data type Pages: 14 (2591 words) Published: June 6, 2013
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 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
16 / 5 - (3 + 4) * (6 – 1) -3 + 4 * 6 – 1 4 + 5 * 2 -5 + 2 12 – 1 MOD 5 (4 + 2) * 6

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]

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 – Operators in constant expressions – Predefined symbols such as @data which return constant values at assembly time.

• Identifiers are names that the programmer chooses to represent variables, constants, procedures or labels. • Identifiers: – can have 1 to 247 characters – are not case-sensitive – begin with a letter , underscore, @ or $ and can also contain digits after the first character. – cannot be reserved words

Examples of Identifiers
var1 _main @@myfile Count xVal open_file _12345 $first MAX

• Directives are commands for the assembler, telling it how to assemble the program. • Directives have a syntax similar to assembly language but do not correspond to Intel processor instructions. • Directives are also case-insensitive: • Examples .data .code name PROC

• An instruction in Assembly language consists of a name (or label), an instruction mnemonic, operands and a comment • The general form is: [name] [mnemonic] [operands] [; comment] • Statements are free-form; i.e, they can be written in any column with any number of spaces between in each operand as long as they are on one line and do not pass column 128.

• Labels are identifiers that serve as place markers within the program for either code or data. • These are replaces in the machine-language version of the program with numeric addresses. • We use them because they are more readable: mov ax, [9020] vs. mov ax, MyVariable

Code Labels
• Code labels mark a particular point within the program’s code. • Code labels appear at the beginning and are immediately followed by a colon: target: mov ax, bx … … jmp target

Data Labels
• Labels that appear in the operand field of an instruction: mov first, ax

• Data labels must first be declared in the data section of the program: first BYTE 10

Instruction Mnemonics
• Instruction mnemonics are...
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • Computer Organization Essay
  • Computer Organization Essay
  • Computer Organization Essay
  • Computer Organization Essay
  • Computer Architecture and Organization Essay
  • computer Essay
  • Problems in the Computer Assembly Division Essay
  • “Problems in the Computer Assembly Division” Essay

Become a StudyMode Member

Sign Up - It's Free