Professional Documents
Culture Documents
ASSEMBLY LANGUAGE
12/12/2020 1
Assembly Language Syntax
• An assembly language program consists of statements.
12/12/2020 2
RULES
Only one statement is written per line
instruction
translated into machine code
assembler directive
instructs the assembler to perform some specific task
12/12/2020 3
Operation Field
For an instruction
12/12/2020 4
Operation Field
For an assembler directive
12/12/2020 5
Comment Field
• A semicolon marks the beginning of a comment
12/12/2020 6
Key rules for the use of comments
12/12/2020 7
Comment Field
Examples of good and bad Comments
12/12/2020 8
Numbers
• Binary number is written as a bit string followed by the letter `b`.
• Hex number is written as a string of hex digits followed by the letter `h`.
• Hex number must begin with a decimal digit (to differentiate between ABCH – a variable name
or hex number ABC)
12/12/2020 9
Numbers
Examples:
number type
1010 decimal
1010B binary
-2134D decimal
ABFFH illegal
0ABFFH hex
1BHH illegal
1BFFH hex
1,23 illegal
12/12/2020 10
Characters
• Characters and character segments must be enclosed in single or double quotes;
‘A' , “hello“.
12/12/2020 11
Variables
Declaring Integer Variables:
12/12/2020 12
Variables
Allocating Memory for Integer Variables:
• When an integer variable is declared, the assembler allocates memory space for
the variable. The variable name becomes a reference to the memory space
allocated to that variable.
12/12/2020 13
Syntax
12/12/2020 14
Variables
Pseudo-op type size range
• DB unsigned 1 byte 0 to 255.
signed 1 byte -128 to +127.
• DW unsigned 2 bytes 0 to 65,535.
signed 2 bytes -32,768 to +32,767.
• DD unsigned 4 bytes 0 to 4,294,967,295 (4 Mbytes).
signed 4 bytes -2,147,483,648 to +2,147,483,647.
• DQ 8-byte integer 4 consecutive words
• DT 10-byte integer 10 consecutive bytes
12/12/2020 15