Brief idea of Machine & Assembly Languages


It is very difficult for the user to write his program directly in machine code. 2t is more common to write the program in Assembly language and the translate the AL program into machine language either by hand coding or using an assembly program. (Program from notes)


Assembly language program are usually written in a standard form so that they can be translated to machine language by an assembly to machine language by an assembler program (may be self on cross assembler).


In general, the assembly language statements have four sectors in general known as fields.




1) Label field: The first field is the label field. A label is a symbol used to represent an address that is not specified known on it is a name to be field is usually ended with a colon.


2) Mnemonic field: This field contains the mnemonic for the instruction to be performed sometimes mnemonics are referred to as operation codes or opcode. It may consist of pseudo mnemonics.


3) Operand field: Operand field consists of operand and operands either constants or variables with reference to the instruction in the mnemonic field it may be any register, data, or address on which the instruction is to be performed. Repenting upon the absent, may contain one operand or two operands separated by a comma. A
comma is required between register initials or between register initial and a data byte.


4) Comment field: A very important part of an any ALP in the comment field. For most assemblers the comment field is started with a semicolon. Comments do not become part of the machine program. They are written for the reference of the user. If you write a program  without comment and set it aside for 6 months it may be very default
for you to understand the program again when you back to it.

It may even that someone else must have written it. Comments should be written to explain in detail what each instruction or group of instruction is doing. Comments should not just describe the mnemonic, but also the function of the instruction in the particular routine.

For best result, write comments as if you trying to explain the program to someone who initially knows nothing about the program’s purpose. In addition to the comments of a program or subroutine should start with a series of comments describing what the program is supposed to do. The staring comments should also include a list of parameter, registers and memory location used.



To assemble a program automatically the assembler needs information in the form of assembler direct that controls the assembly. E.g. the assembler must be told at what address to start assembling the program. These assembler directives are command placed in the program by the designer that provides information to the assembler. They do not become part of the final program as the microprocessor nor did they translate into executed code. Therefore, they are also known as pseudo instruction on false instructions.


Each assembler has its own unique pseudo instruction written in assembly language format



The origin (ORG) instruction tells the assembler the address of the memory location for the next instruction or data byte should be assembled ORG entered at the beginning of a program. When different parts of a program (e.g. subroutines) are to be placed in different areas of memory, an ORG pseudo instruction is used before each part of the program to specify the starting location for assembly of that part of the program. The origin instruction has the following form.


ORG expression

Where expression evaluation to a 16 bit address is ORG is followed by an address if no origin pseudo instruction appears before the first instruction in the program, assembly will begin, by default, at memory location 0000H.

E.g. ORG 0100H tells the assembler start assembling the immediately following program at 0100 in memory



When an assembler scans the program to be assembled it must know, where the program ends it cannot defined on a halt instruction for their because some program don’t contain a halt as the last instruction and other don’t contain a halt at all, an application program used, e.g., in process monitoring on control might run continuously and therefore not contain a halt instruction. Thus, an end assembly, END directive must be the last instruction. The directive has a form.



The END statement explicitly indicates the end of the program to the assembler. If no END statement is given, then the assembler just keeps on running through all the memory. The ORG and END assembler direction in effected from the program to be assembled.


ORG 0000H [Assembly language instruction] END

When there is more than one ORG assembler directive, then the assembly of group of instruction start at the location specified by the origin assemble directive that proceeds. e.g.

ORG 0000H

This block of instruction is assembled starting at location 0000H


ORG 0100 H

At location 0100h [AL instruction]





Symbolic names, which appear in assembly language programs as labels, instructions mnemonics and operands are translated to binary values by the assembles. As discussed in hand- assembly the labels are assembler’s location counter when entertained on the first pass of the assembly. Instruction mnemonics have predefined values that the assembler obtains from a table that is part of the assembler.


A symbolic operand can be a register name, an address or a data constant. Register names have predefined values, all addresses correspond to labels in The program and their values are defined. Data constants, on the other hand, are defined by the designer using an equate instruction EQU defines symbolic used in the program. Equate assembler directives usually appear as a group at the beginning of a program and have the form.


Name EQU expression.

‘NAME’ stands for the symbolic name, the assemble evaluates the expression and equates the symbolic name to it by placing the name in its symbol table along with the value of the expression. Therefore, whenever the name appears in the program, it is replaced by the value the expression in the equate pseudo


 COUNT EQU 0100 H 

Note the symbolic name is not followed by a adan and is not a label even though it appears in the label field. The symbolic name in are equate statement cannot be used in another nor can it be used as the label of another instruction. That is, the name in an equate directive cannot be redefined. If its value is changed, the equate assemble directive must be changed and the program reassembled


4) SET: SET is simi8lar to EQU assemble directive this directive also assigns a value to the name associated it. However, the same symbol can be redefined by another SET statement late in the program. Thus, mere that one SET instructio0ns can have the same name the SET assembles directive has the form. Name set expression.


5). DS: Another pheudo instructions, the define storage, reserves or allocates read/write memory locations for storage of temporary data. The first of the locations allocated can be referred to by an optional symbolic label. The define storage instruction has the form Opt label: DS expression.

A number of bytes of memory equal to the value of the expression are reserved. However, no assumptions can be made above the initial values of the data in these reserves the assembler does not initialize the contents of these locations in anyway. (e.g. BUFFER: DS 96 tells the assembler to reserve 96 memory locations for storage when it assembles the program the address of the first location is BU*FFER. (Buffer to BUFFER +96-1) such a buffer is usually written and read sequentially using reg indirect addressing.

2f has a symbolic name is used with the DS pseudo instructions, it has the value of the address of the first reserved to establish two byte storage registers in C/N memory with the names TEMP 1 & TEMP 2,the instruction is written.
TEMP 1: DS 1
TEMP 2: DS 2


During the first pass, the assembler assigns the values of its location counter to TEMP 1& TEMP 2,respectively and thus as address is associated with each Label. Instructions in the program can read a write these locations using memory reference instructions such as


A memory buffer is a collection of consecutive memory locations also used to store data temporarily.

6). DB: When a table of foxed data values is required, memory must also be allocated. However, unlike the DS, each memory l0ocations must have a defined value that is assembled into it. The pseudo instructions for this is define, DB. Opt name: DB list ‘List’ refers either to one or more arithmetic or logic expressions that evaluate to 8 bit data quantities or to strings of character enclosed in quotes that the assembler replaces with their equivalent ASCII
representations. Assembled bytes of data are stored in successive memory location until the list is DB 07A H stores 7A H in meaning location right after the preceding instruction. E.g. DB ‘JO’‘MA’ stores 4A,4F,48 & 4E in the four successive memory locations to represent the string of ASC II characters.


7) DW: Define war instruction is similar to define byte pseudo0 instruction.
Opt name: DW list The only difference between the DB & DW is that expression in this define ward list is evaluated to 16-bit quantity and stored as 2-bytes.2f is stored with the low order bytesi9n the lower memory locations and
the high order byte in the next higher one .this is consistent with the convention for storing 16- bit quantities in 8085 A systems.


Sometimes it is required that same set of instructions are to be repeated again & again. One way to simplify the problem is the care of subroutine. The other way is the use of macros. The assemblers which have the capability to process macro instructions are called macro assemblers. The assemblers are designed such that the programmer need to write set of instruction once and then refer it many times as desired.


A macro instruction is a single instruction that the macro assemble replaces with a group of instruction whenever it applies in an assembly language program. The macro instruction and the instruction that replace it are defined by the system design only once in the program. Macros are useful when a small group of instruction must be repeated several times in a program, with only minor or no changes in each repetition.


The use of macro in ALP entails three groups:
1) The macro definition
2) The macro reference
3) The macro expansion.


The macro definition defines the group of instruction equivalent reference is the use of the macro instruction as an instruction in the program. A macro expansion is the replacement of the instruction defined be its equivalent
The first two steps are caused out by the system designer and the third by the macro assembler.


The macro definition has the following format:




‘Name’ stands for the name of the macro that appears in the label field of the macro definition. A list of dummy parameters may be specified as List, and, if so, these parameters also appear in the macro body. The macro body is the sequence of assembly language instructions the replace the macro reference into program when assembled. The macro definition produces no object code (hexadecimal number); it simply indicates to the assembler what instructions are represented by the macro name.

Try Now – Microprocessors MCQs