ASSEMBLER DIRECTIVES


An assembler directive is a message to the assembler that tells the assembler something it needs to know in order to carry out the assembly process.Some useful directive.

SYMBOL DEFINITION

The assembler automatically assigns values to symbols that appear as instruction labels. This value is the current setting of the location counter when the instruction is assembled.

You may define other symbols and assign them values by using the EQU and SET directives. Symbols defined using EQU can not be redefined during assembly; those defined by SET can be assigned new values by subsequent SET directive.The name required in the label field of an EQU or SET directive must not be terminated with a colon(:).

EQU Directive :

EQU assigns the value of 'expression' to the name specified in the label field.

   Label   Mnemonic   Operand

   name   EQU   expression

The required name in the label field may not be terminated with a colon. This name cannot be redefined by a subsequent EQU or SET directive. The EQU expression cannot contain any external symbol.

For example, The following EQU directive enters the name ONES into the symbol table and assigns the binary value 11111111 to it:

   ONES   EQU   FFH

The value assigned by the EQU directive can be recalled in subsequent source lines by referring to its assigned name.

SET Directive :

SET assigns the value of 'expression' to the name specified in the label field.

   Label   Mnemonic   Operand

   name   SET   expression

The assembler enters the value of 'expression' into the symbol table. Whenever 'name' is encountered subsequently in the assembly, the assembler substitutes its value from the symbol table. This value remains unchanged until altered by a subsequent SET directive.

The function of the SET directive is identical to EQU except that 'name' can appear in multiple SET directives in the same program. Therefore, you can alter the value assigned to 'name' throughout the assembly. For Example,

   Label   Mnemonic   Operand

   ONES   SET   05H

                ADI   ONES

   ONES   SET   10H

                ADI   ONES

DATA DEFINITION

The DB (define byte) and DW (define word) directives enable you to define data to be stored in your program. Data can be specified in the form of 8-bit or 16-bit values, or as a string of text characters.

DB Directive :

The DB directive stores the specified data in consecutive memory locations starting with the current setting of the program counter.

   Label   Mnemonic   Operand

   optional:   DB   expression(s) or string(s)

The operand field of the DB directive can contain a list of expressions and/or text strings. The list can contain up to eight total items. list items must be separated by commas. Because of limited workspace, the assembler may not be able to handle a total of eight items when the list includes a number of complex expressions. If you ever have this problem, it is easily solved simply use two or more directives to shorten the list.

Expressions must evaluate to 1-byte (8-bit) numbers in the range -256 through 255. Text strings may comprise a maximum of 128 ASCII characters enclosed in quotes.

If the optional label is present, it is assigned the starting value of the program counter, and thus references the first byte stored by the DB directive. Therefore, the label STR in the following examples refers to the letter T of the string TIME.

   Label   Mnemonic   Operand

   STR:   DB   'TIME'

   GEEK:   DB   034H

DW Directive :

The DW directive stores each 16-bit value from the expression list as an address. The values are stored starting at the curren setting of the program counter.

   Label   Mnemonic   Operand

   optional:   DW   expression list

The least significant eight bits of the first value in the expression list are stored at the current setting of the program counter, the most significant eight bits are stored at the next higher location. This process is repeated for each item in the expression list.

Expressions Evaluate to 1-word (16-bit) numbers, typically addresses. If an expression evaluates to a single byte, it is assumed to be the low order byte of a 16-bit word where the high order byte is all zeros.

List items must be separated by commas. The list can contain up to eight total items. Because of limited workspace, the assembler may not be able to handle eight complex expressions. If you ever have this problem, simply use two or more DW directives to shorten the list.

The reversed order for storing the high and low order bytes is the typical format for addresses stored in memory. Thus, the DW directive is commonly used for storing address constants.

For example, Assume that ONES and GEEK are labels defined else where in the program. ONES addresses memory location 20B5H. GEEK addresses memory location 3B54H.

   Label   Mnemonic   Operand

   ADDR1:   DW   ONES

   ADDR2:   DW   GEEK

   STR:   DW   'A','AB'

ASSEMBLER TERMINATION

END Directive :

The END directive identifies the end of the source program and terminates each pass of the assembler.

   Label   Mnemonic   Operand

   optional:   END   expression

Only one END statement may appear in a source program, and it must be the last source statement. If the optioml expression is present, its value is used as the starting address for program execution. If no expression is given, the assembler assumes zero as the starting address.

LOCATION COUNTER CONTROL

ORG Directive :

The origin directive tells the assembler where to load instructions and data into memory. It changes the program counter to the value specified by the expression in the operand field. Subsequent statements are assembled into memory locations starting with the new program/location counter value. If no ORG directive is encountered in a source program, the program counter is initialized to zero.

Assembler uses an internal variable called LC (Location Counter) to store current offset address of the statement being processed. When it encounters a variable declaration statement, it puts the value of LC in its symbol table as variable’s address.

The bottom line is that we should use "ORG" directive when DS (Data Segment) register is not pointing to the first variable in Data segment (when program has separate Code and Data segment) or first instruction (when program has only one segment for both Code and Data)

Instruction set

The instruction set is a set of instructions that can be executed by the computer. The computer programming is done using these instructions. Any problem to be solved on the computer is to be written in the form of a program.Let us take a look at the programming of 8085 Microprocessor.

  1. Control Instruction
  2. Logical Instruction
  3. Branching Instruction
  4. Arithmetic Instruction
  5. Data Transfer Instruction

For academic purpose you can use Jubin Mitra 8085-simulator. it is opensource and It's helps in get started easily with example codes, and to learn the architecture without even having the actual hardware. you can get it by given below link -

https://github.com/8085simulator/8085simulator/raw/master/dist/8085Compiler.jar

ASSEMBLY LANGUAGE PROGRAMMING

The programming of the problem is generally written in assembly language. The assembly language is written in mnemonics. The mnemonics are the initials or short form of the English word of the operation to be performed by the instruction.

Assembly language statements are written in standard format as given below:

   Label   Mnemonic   Operand   Comment

Label A label is a symbol or group of symbols used to represent an address of the location which is not specifically known at the time of program is written. The label can be one to six characters, the first character of which must be a letter. Following are the acceptable labels. NEXT, BACK, DELAY, A2 etc.
Mnemonic Short form of the operation to be performed.
Operand Operand is the data on which the operation is performed. It can be a data, memory address, register or port address.
Comment The comment statement is started with the semicolon. It gives the idea of the program to the user. The comments are not the part of the machine language program.

The program written in assembly language can be converted to machine language by hand. For writing the program in machine language, the starting address, where the program is to be stored should be known. Now the op code of the instruction is to be written in first location (starting address) and in the consecutive memory locations data /address of the operand is written. While storing the address in the memory locations, lower byte of the address is stored first then the upper byte.

ADDRESSING MODES

There are various techniques to specify the data for instruction. These techniques are called addressing modes.

Direct Addressing :

In this mode of addressing, the address of the operand is given in the instruction itself. For example,

LDA 2100H

OUT 03H

Register Addressing :

In this mode of addressing, the operands are in registers. For example,

MOV A , B

ADD C

Immediate Addressing :

In immediate addressing mode, the operand in specified in the instruction itself. For example,

MVI B, 08 H

ANI 07 H

Implied Addressing :

There are certain instructions which operate on the contents of the accumulator. Such instructions do not require the address of the operand, since the operand is implied in the instruction itself. So this type of addressing mode is called as Implied Addressing.

CMA

RAL