Académique Documents
Professionnel Documents
Culture Documents
Outline
Numeric Literals Character or String constant Name Field Operation Field Operands(s) Field Comment Field Labels for Variables Code Labels
Irvine: Assembly Language for Intel-Based Computers (1999)
Statements
Names
Numeric Literals
5.5
-5.5 26.0E+05
+35d
Contd..
32q
1011b 35d
; octal
; binary ; decimal (default)
COUNT = 25
ROWS = 10
tablePos = ROWS * 5
Constant Expression
Examples:
4 * 20
-3 * 4 / 6 ROWS - 3 COUNT MOD 5 ; (ROWS is a constant)
Statements
Syntax:
name operation operand(s) comments name and comment are optional Number of operands depend on the instruction One statement per line Each statement is either:
Instruction (translated into machine code) Assembler Directive (instructs the assembler to perform some specific task such as allocating memory space for a variable or creating a procedure) At least one blank or tab character must separate the field.
Statement Example
mnemonic Operands Comment
Label
; Code
Here: mov ax,count ; store count into ax
Label Operation
Irvine: Assembly Language for Intel-Based Computers (1999)
Contd..
Name Field
The assembler translates names into memory addresses. Names can be 1 to 31 character long and may consist of letter, digit or special characters. If period is used, it must be first character. Embedded blanks are not allowed. May not begin with a digit. Not case sensitive
10
Contd..
Symbolic opcode translated into ML opcode In an assembler directive, the operation field represents Pseudo-opcode Pseudo-op is not translated into ML opcode, it only tells assembler to do something. Example: PROC psuedo-op is used to create a procedure
11
Contd..
Operand Field
An instruction may have zero, one or more operands. In two-operand instruction, first operand is destination, second operand is source. For an assembler directive, operand field represents more information about the directive Optional Marked by semicolon in the beginning Ignored by assembler Good practice
Comments Field
12
(hello.asm)
; This program displays Hello, world! .model small .stack 100h comment line memory model
halts program
General Register
Memory Location Memory Location
Memory Location
General Register Memory Location
YES
YES NO
General Register
General Register General Register
General Register
Memory Location Constant
YES
YES YES
Memory Location
Memory Location Memory Location
General Register
Memory Location Constant
YES
NO YES
References
Chapter 3, Ytha Yu and Charles Marut, Assembly Language Programming and Organization of IBM PC Chapter 3, Assembly Language for Intel Based-Computers
20