MP-MC R16 - Unit-2
MP-MC R16 - Unit-2
www.Jntufastupdates.com 1
- DOCUMENTATION: you should document the program. E.g. each page of the document
contains page number and name of the program, heading block containing the abstract about
the program, comments should be added wherever necessary.
These types of instructions are used to transfer data from source operand to destination operand.
All the store, load, move, exchange, input and output operations belong to this category.
b) Arithmetic and Logical Instructions:
All the instructions performing arithmetic, logical, increment, decrement, compare and scan
instructions belong to this category.
c) Branch Instructions:
These instructions transfer control of execution to the specified address. All the call, jump,
interrupt and return instructions belong to this category.
d) Loop Instructions:
The LOOP, LOOPNZ and LOOPZ instructions belong to this category. These are useful to
implement different loop structures.
e) Machine control Instructions:
These instructions control the machine status. NOP, HLT, WAIT and LOCK instructions belongs to
this category.
www.Jntufastupdates.com 2
f) Flag Manipulation Instructions:
All instructions which directly affect the flag register belong to this category. The instructions
CLD, STD, CLI, STI etc. belong to this category.
g) Shift and Rotate Instructions:
These instructions involve the bitwise shifting or rotation in either direction with or without a
count in CX.
h) String Instructions:
These instructions involve string manipulation operations like load, scan, compare, store etc. These
instructions are only to be operated upon the string.
Ex: - PUSH AX
PUSH DS
PUSH [5000H]
www.Jntufastupdates.com 3
Fig: Push data to Stack memory
www.Jntufastupdates.com 4
XLAT: Translate byte using look-up table
Ex: - MOV BX, OFFSET TABLE
XLAT 3
(AL) ← 5
5
(BX)
AL [BX+AL]
Base of table
Simple input and output port transfer Instructions:
IN:
Copy a byte or word from specified port to accumulator.
Ex: - IN AL,03H
IN AX, DX
OUT:
Copy a byte or word from accumulator specified port.
Ex: - OUT 03H, AL
OUT DX, AX
LEA:
Load effective address of operand in specified register.
[reg] offset portion of address in DS
Ex: - LEA reg, offset
LDS:
Load DS register and other specified register from memory.
[reg] [mem]
[DS] [mem + 2]
Ex: - LDS reg, mem
LES:
Load ES register and other specified register from memory.
[reg] [mem]
[ES] [mem + 2]
Ex: - LES reg, mem
www.Jntufastupdates.com 5
Flag transfer instructions:
LAHF:
Load (copy to) AH with the low byte the flag register.
[AH] [Flags low byte]
Ex: - LAHF
SAHF:
Store (copy) AH register to low byte of flag register.
[Flags low byte] ← [AH]
Ex: - SAHF
PUSHF:
Copy flag register to top of stack.
[SP] ← [SP] – 2
[[SP]] ← [Flags]
Ex: - PUSHF
POPF:
Copy word at top of stack to flag register.
[Flags] ← [[SP]]
[SP] ← [SP] + 2
Ex: - POPF
b) Arithmetic Instructions:
The 8086 provides many arithmetic operations: addition, subtraction, negation, multiplication and
comparing two values.
ADD:
The add instruction adds the contents of the source operand to the destination operand.
Ex: - ADD AX, 0100H
ADD AX, BX
ADD AX, [SI]
ADD AX, [5000H]
ADD [5000H], 0100H
ADD 0100H
www.Jntufastupdates.com 6
ADC: Add with Carry
This instruction performs the same operation as ADD instruction, but adds the carry flag to the result.
Ex: - ADC 0100H
ADC AX, BX
ADC AX, [SI]
ADC AX, [5000]
ADC [5000], 0100H
SUB: Subtract
The subtract instruction subtracts the source operand from the destination operand and the result is left in
the destination operand.
Ex: - SUB AX, 0100H
SUB AX, BX
SUB AX, [5000H]
SUB [5000H], 0100H
SBB: Subtract with Borrow
The subtract with borrow instruction subtracts the source operand and the borrow flag (CF) which may
reflect the result of the previous calculations, from the destination operand
Ex: - SBB AX, 0100H
SBB AX, BX
SBB AX, [5000H]
SBB [5000H], 0100H
INC: Increment
This instruction increases the contents of the specified Register or memory location by 1. Immediate data
cannot be operand of this instruction.
Ex: - INC AX
INC [BX]
INC [5000H]
DEC: Decrement
The decrement instruction subtracts 1 from the contents of the specified register or memory location.
Ex: - DEC AX
DEC [5000H]
www.Jntufastupdates.com 7
NEG: Negate
The negate instruction forms 2’s complement of the specified destination in the instruction. The
destination can be a register or a memory location. This instruction can be implemented by inverting each
bit and adding 1 to it.
Ex: - NEG AL
AL = 0011 0101 35H Replace number in AL with its 2’s complement
AL = 1100 1011 = CBH
CMP: Compare
This instruction compares the source operand, which may be a register or an immediate data or a memory
location, with a destination operand that may be a register or a memory location
Ex: - CMP BX, 0100H
CMP AX, 0100H
CMP [5000H], 0100H
CMP BX, [SI]
CMP BX, CX
MUL: Unsigned Multiplication Byte or Word
This instruction multiplies an unsigned byte or word by the contents of AL.
Ex: - MUL BH; (AX) ← (AL) x (BH)
MUL CX; (DX) (AX) ← (AX) x (CX)
MUL WORD PTR [SI]; (DX) (AX) ← (AX) x ([SI])
IMUL: Signed Multiplication
This instruction multiplies a signed byte in source operand by a signed byte in AL or a signed word in
source operand by a signed word in AX.
Ex: - IMUL BH
IMUL CX
IMUL [SI]
CBW: Convert Signed Byte to Word
This instruction copies the sign of a byte in AL to all the bits in AH. AH is then said to be sign extension
of AL.
Ex: - CBW
AX= 0000 0000 1001 1000 Convert signed byte in AL signed word in AX.
Result in AX = 1111 1111 1001 1000
CWD: Convert Signed Word to Double Word
This instruction copies the sign of a byte in AL to all the bits in AH. AH is then said to be sign extension
of AL.
www.Jntufastupdates.com 8
Ex: - CWD
Convert signed word in AX to signed double word in DX: AX
DX= 1111 1111 1111 1111
Result in AX = 1111 0000 1100 0001
DIV: Unsigned division
This instruction is used to divide an unsigned word by a byte or to divide an unsigned double word by a
word.
Ex: - DIV CL ; Word in AX / byte in CL
; Quotient in AL, remainder in AH
DIV CX ; Double word in DX and AX / word in CX, and Quotient in AX, remainder in DX
AAA: ASCII Adjust After Addition
The AAA instruction is executed after an ADD instruction that adds two ASCII coded operand to give a
byte of result in AL. The AAA instruction converts the resulting contents of AL to a unpacked decimal
digits.
AAA operation:
1) In AL If rightmost nibble is >9 (ie) A to F or Auxiliary Flag=1
ADD 6 to rightmost nibble
2) Clear left nibble form AL.
3) In AH ADD 1
4) Set Carry and Auxiliary Carry
Ex: - ADD CL, DL ; [CL] = 34H = ASCII for 4
; [DL] = 38H = ASCII for 8
; Result [CL] = 6CH
AAA ; [AL] =02, unpacked BCD for 2
; [AH] =01, unpacked BCD for 1
AAS: ASCII Adjust AL after Subtraction
This instruction corrects the result in AL register after subtracting two unpacked ASCII operands. The
result is in unpacked decimal format. The procedure is similar to AAA instruction except for the
subtraction of 06 from AL.
AAS operation:
1) AAS checks the rightmost nibble in AL If rightmost nibble is >9 (ie) A to F Or
Auxiliary Flag=1, Then Subtract 6 from rightmost nibble
2) Clear left nibble in AL.
3) Subtracts 1 from AH
www.Jntufastupdates.com 9
4) Set Carry and Auxiliary Carry
Ex: - MOV AL, 34H
SUB AL, 38H ; AX=00FC
AAS ; AX= FF06 ten’s complement i.e -4 (Borrow one from AH)
OR AL, 30H ; AL=34
AAM: ASCII Adjust after Multiplication
This instruction, after execution, converts the product available In AL into unpacked BCD format.
AAM performs the following operations
1) Divides AL value by 10 (0AH)
2) Stores Quotient in AH
3) Store Remainder in AL
Ex: - MOV AL, 04 ; AL = 04
MOV BL, 09 ; BL = 09
MUL BL ; AX = AL*BL ; AX=0024H
AAM ; AH = 03H, AL=06H
AAD: ASCII Adjust before Division
This instruction converts two unpacked BCD digits in AH and AL to the equivalent binary number in AL.
This adjustment must be made before dividing the two unpacked BCD digits in AX by an unpacked BCD
byte. In the instruction sequence, this instruction appears Before DIV instruction.
Operations done by AAD instruction
1) AAD multiplies the AH by 10(0Ah).
2) Then adds the product to AL and clears the AH
Ex: - AX 05 08
AAD result in AL 00 3A 58D = 3A H in AL
The result of AAD execution will give the hexadecimal number 3A in AL and 00 in AH. Where 3A is the
hexadecimal equivalent of 58 (decimal).
DAA: Decimal Adjust Accumulator
This instruction is used to convert the result of the addition of two packed BCD numbers to a valid BCD
number. The result has to be only in AL.
Ex: - AL = 53H, CL = 29H
ADD AL, CL ; AL ← (AL) + (CL)
; AL ← 53 + 29
; AL ← 7C
DAA ; AL ← 7C + 06 (as C > 9)
; AL 82
www.Jntufastupdates.com 10
DAS: Decimal Adjust after Subtraction
This instruction converts the result of the subtraction of two packed BCD numbers to a valid BCD
number. The subtraction has to be in AL only.
Ex: - AL = 75H, BH = 46H
SUB AL, BH ; AL ← 2 FH = (AL) - (BH)
; AF = 1
DAS ; AL ← 29 (as F>9, F - 6 = 9)
Logical Instructions:
AND: Logical AND
This instruction bit by bit ANDs the source operand that may be an immediate register or a memory
location to the destination operand that may a register or a memory location. The result is stored in the
destination operand.
Ex: - AND AX, 0008H
AND AX, BX
OR: Logical OR
This instruction bit by bit ORs the source operand that may be an immediate, register or a memory
location to the destination operand that may a register or a memory location. The result is stored in the
destination operand.
Ex: - OR AX, 0008H
OR AX, BX
NOT: Logical Invert
This instruction complements the contents of an operand register or a memory location, bit by bit.
Ex: - NOT AX
NOT [5000H]
XOR: Logical Exclusive OR
This instruction bit by bit XORs the source operand that may be an immediate, register or a memory
location to the destination operand that may a register or a memory location. The result is stored in the
destination operand.
Ex: - XOR AX, 0098H
XOR AX, BX
TEST: Logical Compare Instruction
The TEST instruction performs a bit by bit logical AND operation on the two operands. The result of this
AND ing operation is not available for further use, but flags are affected.
www.Jntufastupdates.com 11
Ex: - TEST AX, BX
TEST [0500], 06H
c) Branch Instructions:
Branch Instructions transfers the flow of execution of the program to a new address specified in the
instruction directly or indirectly. When this type of instruction is executed, the CS and IP registers get
loaded with new values of CS and IP corresponding to the location to be transferred.
The Branch Instructions are classified into two types
i. Unconditional Branch Instructions.
ii. Conditional Branch Instructions.
Unconditional Branch Instructions:
In Unconditional control transfer instructions, the execution control is transferred to the specified
location independent of any status or condition. The CS and IP are unconditionally modified to the new
CS and IP.
CALL: Unconditional Call
This instruction is used to call a Subroutine (Procedure) from a main program. Address of procedure may
be specified directly or indirectly.
There are two types of procedure depending upon whether it is available in the same segment or in another
segment.
i. Near CALL i.e., ±32K displacement.
ii. Far CALL i.e., anywhere outside the segment.
On execution this instruction stores the incremented IP & CS onto the stack and loads the CS & IP
registers with segment and offset addresses of the procedure to be called.
RET: Return from the Procedure.
At the end of the procedure, the RET instruction must be executed. When it is executed, the previously
stored content of IP and CS along with Flags are retrieved into the CS, IP and Flag registers from the stack
and execution of the main program continues further.
INT N: Interrupt Type N.
In the interrupt structure of 8086, 256 interrupts are defined corresponding to the types from 00H to FFH.
When INT N instruction is executed, the type byte N is multiplied by 4 and the contents of IP and CS of
the interrupt service routine will be taken from memory block in 0000 segment.
INTO: Interrupt on Overflow
This instruction is executed, when the overflow flag OF is set. This is equivalent to a Type 4 Interrupt
instruction.
www.Jntufastupdates.com 12
JMP: Unconditional Jump
This instruction unconditionally transfers the control of execution to the specified address using an 8-bit or
16-bit displacement. No Flags are affected by this instruction.
IRET: Return from ISR
When it is executed, the values of IP, CS and Flags are retrieved from the stack to continue the execution
of the main program.
d) LOOP Instructions:
LOOP Unconditionally
This instruction executes the part of the program from the Label or address specified in the instruction up
to the LOOP instruction CX number of times. At each iteration, CX is decremented automatically and
JUMP IF NOT ZERO structure.
Ex: - MOV CX, 0004H
MOV BX, 7526H
Label 1: MOV AX, CODE
OR BX, AX
LOOP Label 1
Conditional Branch Instructions:
When this instruction is executed, execution control is transferred to the address specified
relatively in the instruction, provided the condition implicit in the opcode is satisfied. Otherwise execution
continues sequentially.
JZ/JE Label
Transfer execution control to address ‘Label’, if ZF=1.
JNZ/JNE Label
Transfer execution control to address ‘Label’, if ZF=0
JS Label
Transfer execution control to address ‘Label’, if SF=1.
JNS Label
Transfer execution control to address ‘Label’, if SF=0.
JO Label
Transfer execution control to address ‘Label’, if OF=1.
JNO Label
Transfer execution control to address ‘Label’, if OF=0.
JNP Label
Transfer execution control to address ‘Label’, if PF=0.
www.Jntufastupdates.com 13
JP Label
Transfer execution control to address ‘Label’, if PF=1.
JB Label
Transfer execution control to address ‘Label’, if CF=1.
JNB Label
Transfer execution control to address ‘Label’, if CF=0.
JCXZ Label
Transfer execution control to address ‘Label’, if CX=0
Conditional LOOP
LOOPZ / LOOPE Label
Loop through a sequence of instructions from label while ZF=1 and CX=0.
www.Jntufastupdates.com 15
Ex: - SAR BL, 1
MOV CL, 04H
SAR DX, CL
ROL Instruction: ROL destination, count
This instruction rotates all bits in a specified byte or word to the left some number of bit positions. MSB is
placed as a new LSB and a new CF.
www.Jntufastupdates.com 16
RCR Instruction: RCR destination, count
This instruction rotates all bits in a specified byte or word some number of bit positions to the right along
with the carry flag. LSB is placed as a new carry and previous carry is place as new MSB.
www.Jntufastupdates.com 17
MOVSB / MOVSW: Move String Byte or String Word
Suppose a string of bytes stored in a set of consecutive memory locations is to be moved to another
set of destination locations. The starting byte of source string is located in the memory location whose
address may be computed using SI (Source Index) and DS (Data Segment) contents.
The starting address of the destination locations where this string has to be relocated is given by DI
(Destination Index) and ES (Extra Segment) contents.
Ex: - Block move program using the move string instruction
MOV AX, DATA SEG ADDR
MOV DS, AX
MOV ES, AX
MOV SI, BLK 1 ADDR
MOV DI, BLK 2 ADDR
MOV CK, N
CLD ; DF=0
NEXT: MOV SB
LOOP NEXT
HLT
CMPSB/SW: Compare String Byte or String Word
- The CMPS instruction can be used to compare two strings of byte or words. The length of the string
must be stored in the register CX. If both the byte or word strings are equal, zero Flag is set.
- The REP instruction Prefix is used to repeat the operation till CX (counter) becomes zero or the
condition specified by the REP Prefix is False.
www.Jntufastupdates.com 18
SCANSB/SW: Scan String Byte or String Word
This instruction scans a string of bytes or words for an operand byte or word specified in the
register AL or AX. The String is pointed to by ES: DI register pair. The length of the string s stored in CX.
The DF controls the mode for scanning of the string. Whenever a match to the specified operand is
found in the string, execution stops and the zero Flag is set. If no match is found, the zero flag is reset.
LODSB/SW: Load String Byte or String Word
The LODS instruction loads the AL / AX register by the content of a string pointed to by DS: SI
register pair. The SI is modified automatically depending upon DF, If it is a byte transfer (LODSB), the SI
is modified by one and if it is a word transfer (LODSW), the SI is modified by two. No other Flags are
affected by this instruction.
STOSB/SW: Store String Byte or String Word
- The STOS instruction Stores the AL / AX register contents to a location in the string pointer by ES: DI
register pair. The DI is modified accordingly; No Flags are affected by this instruction.
- The direction Flag controls the String instruction execution, the source index SI and Destination Index
DI are modified after each iteration automatically.
- If DF=1, then the execution follows auto-decrement mode, SI and DI are decremented automatically
after each iteration.
- If DF=0, then the execution follows auto-increment mode. In this mode, SI and DI are incremented
automatically after each iteration.
Ex:- Clearing a block of memory with a STOSB operation.
MOV AX, 0
MOV DS, AX
MOV ES, AX
MOV DI, A000
MOV CX, OF
CLD
AGAIN: STOSB
LOOPNE AGAIN
NEXT: Clear A000 to A00F to 00H
www.Jntufastupdates.com 19
Addressing Modes of 8086:
The default segment for the addressing modes using BP and SP is SS. For all other addressing
modes, the default segments are DS or ES.
Addressing mode indicates a way of locating data or operands.
Different addressing modes of 8086:
1. Immediate:
In this addressing mode, immediate data is a part of instruction, and appears in the form of
successive byte or bytes.
Ex: - MOV AX, 0050H
Here 0050H is the immediate data and it is moved to register AX. The immediate data may be 8-bit or 16-
bit in size.
2. Direct:
In the direct addressing mode, a 16-bit address (offset) is directly specified in the instruction as a
part of it.
Ex: - MOV AX, [1000H]
Here data resides in a memory location in the data segment, whose effective address is
10H DS 1000H
3. Register:
In register addressing mode, the data is stored in a register and it is referred using the particular
register. All the registers except IP may be used in this mode.
Ex: - MOV AX, BX
4. Register Indirect:
In this addressing mode, the address of the memory location which contains data or operand is
determined in an indirect way using offset registers. The offset address of data is in either BX or SI or DI
register. The default segment register is either DS or ES.
Ex: - MOV AX, BX
The data is present in a memory location in DS whose offset is in BX. The effective address is
10H DS BX
5. Indexed:
In this addressing mode offset of the operand is stored in one of the index register. DS and ES are
the default segments for index registers SI and DI respectively
Ex: - MOV AX, SI
7. Based Indexed:
In this addressing mode the effective address of the data is formed by adding the content of a base
register (any one of BX or BP) to the content of an index register (any one of SI or DI). The default
segment register may be ES or DS.
Ex: - MOV AX, BX SI
www.Jntufastupdates.com 21
Assembler Directives and Operators:
The main advantage of machine language programming is that the memory control is directly in
the hands of the programmer, so that, he may be able to manage the memory of the system more
efficiently. On the other hand, the disadvantages are more prominent. The programming, coding and
resource management techniques are tedious. The programmer has to take care of these functions hence
the chances of human errors are more. The programs are difficult to understand unless one has a thorough
technical knowledge of the processor architecture and instruction set.
The assembly language programming is simpler as compared to the machine language
programming. The instruction mnemonics are directly written in the assembly language programs. The
programs are now more readable to users than the machine language programs. The main improvement in
assembly language over machine language is that the address values and the constants can be identified by
labels. If the labels are suggestive, then certainly the program will become more understandable, and each
time the programmer will not have to remember the different constants and the addresses at which they are
stored, throughout the programs. The labels may help to identify the addresses and constants. Due to this
facility, the tedious byte handling and manipulations are got rid of. Similarly, now different logical
segments and routines may be assigned with the labels rather than the different addresses. The memory
control feature of machine language programming is left unchanged by providing storage define facilities
in assembly language programming. The documentation facility which was not possible with machine
language programming is now available in assembly language.
An assembler is a program used to convert an assembly language program into the equivalent
machine code modules which may further be converted to executable codes. The assembler decides the
address of each label and substitutes the values for each of the constants and variables. It then forms the
machine code for the mnemonics and data in the assembly language program. While doing these things,
the assembler may find out syntax errors. The logical errors or other programming errors are not found out
by the assembler. For completing all these tasks, an assembler needs some hints from the programmer, i.e.
the required storage for a particular constant or variable, logical names of the segments, types of the
different routines and modules, end of file, etc. These, types of hints are given to the assembler using
some predefined alphabetical strings called assembler directives. Assembler directives help the assembler
to correctly understand the assembly language programs to prepare the codes.
Another type of hint which helps the assembler to assign a particular constant with a label or
initialize particular memory locations or labels with constants is called an operator. Rather, the operators
perform the arithmetic and logical tasks unlike directives that just direct the assembler to correctly
interpret the program to code it appropriately. The following directives are commonly used in the
assembly language programming practice using Microsoft Macro Assembler (MASM) or Turbo
Assembler (TASM).
www.Jntufastupdates.com 22
DIRECTIVES:
DB: Define Byte
The DB directive is used to reserve byte or bytes of memory locations in the available memory.
Example:
LIST DB 0lH, 02H, 03H, 04H
This statement directs the assembler to reserve four memory locations for a list named LIST and initialize
them with the above specified four values.
www.Jntufastupdates.com 23
ASSUME: Assume Logical Segment Name
The ASSUME directive is used to inform the assembler, the names of the logical segments to be assumed
for different segments used in the program.
ASSUME CS: CODE, DS: DATA, SS: STACK
END: END of Program
The END directive marks the end of an assembly language program.
The EVEN directive updates the location counter to the next even address if the current location
counter contents are not even, and assigns the following routine or variable or constant to that address.
www.Jntufastupdates.com 24
Ex: - EVEN
PROCEDURE ROOT
.
.
.
ROOT ENDP
EQU: Equate
The directive EQU is used to assign a label with a value or a symbol. The use of this directive is
just to reduce the recurrence of the numerical values or constants in a program code.
Ex: -
LABEL EQU 0500H
ADDITION EQU ADD
MODULEl ENDS
MODULE2 SEGMENT
MODULE2 ENDS
www.Jntufastupdates.com 25
GROUP: Group the Related segment
The directive is used to form logical groups of segments with similar purpose or type. This
directive is used to inform the assembler to form a logical group of the following segment names.
Ex: - PROGRAM GROUP CODE, DATA, STACK
ORG: Origin
The ORG directive directs the assembler to start the memory allotment for the particular segment,
block or code from the declared address in the ORG statement while starting the assembly process for a
module, the assembler initializes a location counter to keep track of the allotted addresses for the module.
If the ORG statement is not written in the program, the location counter is initialized to 0000.
PROC: Procedure
The PROC directive marks the start of a named procedure in the statement. Also, the types NEAR
or FAR specify the type of the procedure, i.e whether it is to be called by the main program located within
64K of physical memory or not.
Ex: - RESULT PROC NEAR
www.Jntufastupdates.com 26
OPERATORS:
OFFSET: Offset of a Label
When the assembler comes across the OFFSET operator along with a label, it first computes the
16-bit displacement (also called as offset interchangeably) of the particular label, and replaces the string
'OFFSET LABEL' by the computed displacement. This operator is used with arrays, strings, lables and
procedures to decide their offsets in their default segments.
Ex: - DATA SEGMENT
LIST DB 10H
DATA ENDS
CODE SEGMENT
MOV SI, OFFSET LIST
CODE ENDS
PTR: Pointer
The pointer operator is used to declare the type of a label, variable or memory operand. The
operator PTR is prefixed by either BYTE or WORD.
If the prefix is BYTE, then the particular label, variable or memory operand is treated as an 8-bit
quantity, while if WORD is the prefix, then it is treated as a 16- bit quantity.
Ex: - MOV AL, BYTE PTR [SI] ; Moves content of memory location addressed by SI (8-bit) to AL
INC BYTE PTR [BX] ; Increments byte contents of memory location addressed by BX
MOV BX, WORD PTR [2000H] ; Moves 16-bit content of memory location 2000H to BX, i.e.
[2000H] to BL [2001 H] to BH
INC WORD PTR [3000H] ; Increments word contents of memory location 3000H
considering contents of 3000H (lower byte) and 3001 H
(higher byte) as a 16-bit number
SEG: Segment of a Label
The SEG operator is used to decide the segment address of the label, variable, or procedure and
substitutes the segment base address in place of ‘SEG label’.
Ex: - MOV AX, SEG ARRAY ; This statement moves the segment address
MOV DS, AX ; of ARRAY in which it is appearing, to register AX and then to DS.
SHORT
The SHORT operator indicates to the assembler that only one byte is required to code the
displacement for a jump (i.e. displacement is within -128 to +127 bytes from the address of the byte next
to the jump opcode).
Ex: - JMP SHORT LABEL
www.Jntufastupdates.com 27
www.Jntufastupdates.com 28
www.Jntufastupdates.com 29
www.Jntufastupdates.com 30
www.Jntufastupdates.com 31
www.Jntufastupdates.com 32
www.Jntufastupdates.com 33
www.Jntufastupdates.com 34
www.Jntufastupdates.com 35
www.Jntufastupdates.com 36
www.Jntufastupdates.com 37
www.Jntufastupdates.com 38
www.Jntufastupdates.com 39
www.Jntufastupdates.com 40
www.Jntufastupdates.com 41
www.Jntufastupdates.com 42
www.Jntufastupdates.com 43
www.Jntufastupdates.com 44
www.Jntufastupdates.com 45
www.Jntufastupdates.com 46
www.Jntufastupdates.com 47
www.Jntufastupdates.com 48
www.Jntufastupdates.com 49
www.Jntufastupdates.com 50
www.Jntufastupdates.com 51
www.Jntufastupdates.com 52
www.Jntufastupdates.com 53
www.Jntufastupdates.com 54
Assembly Language Program Development Tools:
1. Editor
- An editor is a program which allows you to create a file containing the assembly
language statements for your program.
Example: PC-Write, Wordstar.
- As you type in your program, the editor stores the ASCII codes for the letters and
numbers in successive RAM locations.
- When you have typed in your entire program, you then save the file on the hard disk.
This file is called source file and the extension is .asm.
2. Assembler
An assembler program is used to translate the assembly language mnemonics for
instructions to corresponding binary codes. When you run the assembler, it reads the
source file of your program from the disk where you have saved it after editing.
On the first pass through the source program, the assembler determines the displacement
of named data items, the offset of labels, etc. and puts this information in a symbol table.
On the second pass through the source program, the assembler produces the binary code
for each instruction and inserts the offsets, etc. that it calculated during the first pass.
- The assembler generates 2 files on the floppy disk or hard disk. The first file is called
object file (.obj).
- The second file generated by assembler is called the assembler list file and is given
extension (.lst).
3. Linker
- A linker is a program used to join several object files into one large object file.
- The linker produces a link file which contains the binary codes for all the combined
modules.
- The linker also produces a link map file which contains the address information about the
linked files (.exe).
4. Locator
A locator is a program used to assign the specific address of where the segments of object
code are to be loaded into memory.
A locator program called EXE2BIN comes with the IBM PC Disk Operating System
(DOS). EXE2BIN converts a .exe file to a .bin file which has physical addresses.
www.Jntufastupdates.com 55
5. Debugger
- A debugger is a program which allows you to load your object code program into system
memory, execute the program and troubleshoot or debug it.
- The debugger allows you to look at the contents of registers and memory locations after
your program runs.
- It allows you to change the contents of registers and memory locations and re-run the
program.
- Some debuggers allow you to stop execution after each instruction so that you can check
or alter after each register contents.
- A debugger also allows you to set a breakpoint at any point in your program. If you insert
a breakpoint at any point in your program, the debugger will run the program up to the
instruction where you put the breakpoint and then stop the execution.
6. Emulator
- An emulator is a mixture of hardware and software.
- It is used to test and debug the hardware and software of an external system, such as the
prototype of a microprocessor based instrument. Part of the hardware of an emulator is a
multi wire cable which connects the host system to the system being developed.
www.Jntufastupdates.com 56