8086 Addressing Modes & Instructions
8086 Addressing Modes & Instructions
MODULE 2
Addressing modes and Instructions
Addressing Modes of 8086 o Flag manipulation & Processor control
instructions.
Instruction set
Assembler Directives and operators.
o Data copy /transfer instructions
o Arithmetic instructions Assembly Language Programming
with 8086.
o Logical instructions
o String manipulation instructions
o Branch instructions
CST 307 : Microprocessors &
• Unconditional and conditional branch
Microcontrollers instruction
Addressing Modes 5
Addressing Modes 6
Control Transfer Instructions
Addressing mode indicates a way of locating data or operands. 1. Immediate Depend upon whether the destination location is within
Addressing modes describe the types of operands and the way they are accessed for the same segment or in a different one
2. Direct
executing an instruction.
Intersegment mode- Destination location lies in a different segment.
According to the flow of instruction execution, the instructions may be categorised as
3. Register
Intra-segment mode-Destination location lies in the same segment
o Sequential control flow instructions :After execution, transfer control to the next instruction 4. Register Indirect
9. Intra-segment Direct Mode
appearing immediately after it (in the sequence) in the program.
5. Indexed
-For example, the arithmetic, logical, data transfer and processor control instructions are sequential control flow 10. Intra-segment Indirect Mode
instructions. 6. Register Relative
11. Intersegment Direct
o Control transfer instructions: Transfer control to some predefined address or the address somehow
specified in the instruction, after their execution.
7. Based Indexed
12. Intersegment Indirect
-For example, INT, CALL, RET and JMP instructions fall under this category. 8. Relative Based Indexed
Instruction Format 7
1. Immediate 8
2. Operation Source
Opcode Operand
o In the above example 0005H and 06H are the immediate data.
Opcode
2. Direct 9
3. Register 10
o Here, data is present in a memory location in DS whose offset address is in BX. o The effective address, in this case, is computed as 10H*DS+[SI].
o The effective address of the data is given as 10H*DS+[BX]. o The content of address 10H*DS+[DI] will be transferred into register CX.
6. Register Relative 13
7. Based Indexed 14
The effective address of data is formed, by adding content of a base register (any
The data is available at an effective address formed by adding an 8-bit or
one of BX or BP) to the content of an index register (any one of SI or DI).
16-bit displacement with the content of any one of the registers BX, BP, SI
o The default segment register may be ES or DS.
and DI in the default (either DS or ES) segment.
The effective address is formed by adding an 8 or 16-bit displacement with the sum of
The addressing modes depend upon whether the destination location is within the same
contents of any one of the base registers (BX or BP) and any one of the index registers, in a
segment or in a different one.
default segment.
Also depends upon the method of passing the destination address to the processor.
The second instruction adds content of BP with memory location of which offset is given by
adding 50H of content of BX and SI. The result is stored in the memory location
The address to which the control is to be transferred lies in the same segment in which the
control transfer instruction lies and appears directly in the instruction as an immediate
The displacement to which the control is to be transferred, is in the same
displacement value. segment in which the control transfer instruction lies, but it is passed to the
instruction indirectly.
The displacement is computed relative to the content of the instruction pointer IP.
The effective address to which the control will be transferred is given by the sum of current The branch address is found as the content of a register or a memory location.
content of IP and 8 or 16 bit displacement. This addressing mode may be used in unconditional branch instructions
o if the signed displacement (d) is of 8 bits (i.e. —128 < d < + 127), we term it as short jump and
o if the signed displacement is of 16 bits (i.e. —32768 < d < + 32767), it is termed as long jump.
o Assume current IP content is 5000H
o Jump to EA stored in BX
LABEL lies within -128 to +127 from the current IP content .
i.e. JMP [ BX+5000H ]
o Thus SHORT LABEL is 8-bit signed displacement
11. Intersegment Direct 19
12. Intersegment Indirect 20
The address to which the control is to be transferred is in a different The address to which the control is to be transferred lies in a different segment and it
is passed to the instruction indirectly
segment.
o i.e. contents of a memory block containing 4 bytes -- IP(LSB), IP(MSB), CS(LSB) and CS(MSB)
This addressing mode provides a means of branching from one code sequentially.
segment to another code segment. The starting address of the memory block may be referred using any of the
addressing modes, except immediate mode.
o Here, the CS and IP of the destination address are specified directly in the
instruction.
o Jump to an address in the other segment specified at effective address 2000H in DS, that
points to the memory block as said above
o Jump to effective address 2000H in segment 5000H o IP(LSB), IP(MSB), CS(LSB) and CS(MSB) sequentially
[SI]-3000H [SS]-2000H
[DI]-4000H [IP]-7000H
[BP]-5000H Register relative: MOV AX, 5000 [BX]
• To load the segment registers with immediate data, one will have to load any general purpose
MOV DS, 5000H; Not permitted (invalid)
register with the data and then it will have to be moved to that particular segment register.
MOV AX, 5000H
• Both the source and destination operands cannot be memory locations (except for string
instructions) MOV DS, AX Alternative (Valid)
Data Copy/Transfer Instructions 31
PUSH 32
2. PUSH: Push to Stack
SS : SP points to the stack top and
This instruction pushes the contents of the specified register/memory location on AH, AL contains data to be pushed.
to the stack. The sequence of operation as below:
o Push operation decrements SP by 2 and then stores the two byte contents of the operand o Current stack top is already occupied
onto the stack so decrement SP by one then store
• The higher byte is pushed first (Higher Address )and then the lower byte ( Lower Address). AH into the address pointed to by SP.
o Further decrement SP by one and
Examples store AL into the location pointed to
by SP.
PUSH AX • Thus SP is decremented by 2 and AH—
AL contents are stored in stack
PUSH DS memory
• Contents of SP points to a new stack
PUSH [5000H]; top.
• Content of location 5000H and 5001H in DS are pushed onto the stack
3. POP: Pop from Stack 16-bit contents of current stack top are poped into the specified operand as follows.
Loads the specified register/memory location with the contents of the memory location of 1. Contents of stack top memory location is stored in AL and SP is incremented by one
which the address is formed using the current stack segment and stack pointer.
2. Further contents of memory location pointed to by SP are copied to AH and SP is again incremented by 1
The stack pointer is incremented by 2.
3. Effectively SP is incremented by 2 and points to next stack top.
o The POP instruction serves exactly opposite to the PUSH instruction.
Examples
POP AX
POP DS
POP [5000H];
Data Copy/Transfer Instructions 35
Data Copy/Transfer Instructions 36
4. XCHG: Exchange
5. IN: Input the Port
Exchanges the contents of the specified source and destination operands
• May be registers or one of them may be a memory location.
For reading an input port.
o Exchange of contents of two memory locations is not permitted.
o The address of the input port specified in the instruction directly or indirectly.
Examples Examples
XCHG [5000H] , AX IN AL , 03H --Reads data from an 8-bit port whose address is 03H and stores it in AL
• Exchanges data between AX and a memory location [5000H] in the data segment. IN AX, DX --Reads data from a 16-bit port whose address is in DX and stores it in AX
XCHG BX , AX o MOV DX,0800H --The 16-bit address is taken in DX
• Exchanges data between AX and BX. o IN AX, DX --Read the content of the port in AX
Copies a word from memory locations into the register specified in the instruction.
11. PUSHF: Push Flags to Stack
Then copies a word from the next memory locations into the DS(ES) register.
o Pushes the flag register on to the stack
Useful for pointing to SI(DI) and DS(ES) in string operation.
• first the upper byte and then the lower byte is pushed on to it.
Example
o LDS BX, 5000H 12. POPF: Pop Flags from Stack
o LES BX, 5000H o The pop flags instruction loads the flag register (2 bytes) memory location addressed by SP and SS.
Arithmetic Instructions 43
Arithmetic Instructions 44
ADD: Add
Examples ADC: Add with Carry
Adds an immediate data or contents of a memory
location specified in the instruction or a register (source) o ADD AX, 0100H Immediate Same operation as ADD instruction, but adds the carry flag bit to the result
to the contents of another register (destination) or o ADD AX, BX Register • carry flag bit may be set as a result of the previous calculations
memory location. o ADD AX, [SI] Register indirect o All the condition code flags are affected by this instruction.
o Both the source and destination operands cannot be o ADD AX, [5000H] Direct
Example
memory operands. o ADD [5000H], 0100H Immediate
o ADC 0100H Immediate (AX implicit)
• Memory to memory addition is not possible. o ADD 0100H Destination AX
(implicit) o ADC AX, BX Register
o Contents of the segment registers cannot be added using
this instruction. o ADC AX, [SI] Register indirect
o All the condition code flags are affected, depending upon o ADC AX, [5000H] Direct
the result. o ADC [5000H], 0100H Immediate
Arithmetic Instructions 45
Arithmetic Instructions 46
SUB: Subtract
INC: Increment / DEC: Decrement
Subtracts the source operand (a register, memory location or immediate data) from
Increases/ Decreases the contents of the specified register or memory the destination operand (a register or a memory location) and the result is left in the
location by 1 [Data±1] destination operand.
o All the condition code flags are affected except the carry flag CF. o Source and destination operands both must not be memory operands.
o Immediate data cannot be operand of this instruction. o All the condition code flags are affected by this instruction
Examples Examples
o SUB AX, 0100H Immediate [destination AX]
o SUB AX, BX Register
o SUB AX, [5000H] Direct
o SUB [5000H], 0100 Immediate
Arithmetic Instructions 47
Arithmetic Instructions 48
SBB: Subtract with Borrow CMP: Compare
Subtracts the source operand and the borrow flag (CF) which may reflect the result of the Compares the source operand (a register or an immediate data or a memory location), with a destination
previous calculations, from the destination operand. operand (may be a register or a memory location)
o Subtraction with borrow, here means subtracting 1 from the subtraction obtained by SUB, if carry o For comparison, it subtracts the source operand from the destination operand but does not store the result anywhere.
(borrow) flag is set. o The flags are affected depending upon the result of the subtraction.
• If both of the operands are equal, zero flag is set.
o The result is stored in the destination operand.
• If the source operand is greater than the destination operand, carry flag is set
o All the flags are affected (Condition code) by this instruction.
• If the source operand is less than the destination operand , carry flag is reset.
Examples The examples of this instruction are as follows:
o SBB AX, 0100H Immediate [destination AX] o CMP AX, 0100H Immediate
o SBB AX, BX Register o CMP [5000H], 0100H Direct
o SBB AX, [5000H] Direct o CMP BX, [SI] Register indirect
o SBB [5000H], 0100 Immediate o CMP BX, CX Register
Arithmetic Instructions 49
Arithmetic Instructions 50
Multiplies an unsigned byte or word (from a general purpose registers or memory Multiplies a signed byte or word in source operand by a signed byte in AL or AX.
locations) by the contents of AL or AX. o In case of 32-bit results, the higher order word (MSW) is stored in DX and the lower order word
o The most significant word of the result is stored in DX (LSW) is stored in AX.
o The least significant word of the result is stored in AX. o The AF, PF, SF, and ZF flags are undefined after IMUL.
o All the flags are modified depending upon the result. o If AH and DX contain parts of 16 and 32-bit result respectively,
• CF and OF both will be set.
o Immediate operand is not allowed in this instruction.
o The AL and AX are the implicit operands in case of 8 bits and 16 bits multiplications respectively.
o If the most significant byte or word of the result is ‘0’
• CF and OF both will be set.
o The unused higher bits of the result are filled by sign bit and CF, AF are cleared.
Arithmetic Instructions 51
Arithmetic Instructions 52
DIV: Unsigned Division NEG: Negate
It divides an unsigned word or double word by a 16-bit or 8-bit operand. The negate instruction forms 2’s complement of the specified destination in
The dividend must be in AX for 16-bit operation and divisor may be specified using any one of the the instruction.
addressing modes except immediate.
For obtaining 2’s complement, it subtracts the contents of destination from zero.
o The result will be in AL (quotient) while AH will contain the remainder.
o If the result is too big to fit in AL, type 0 (divide by zero) interrupt is generated. The result is stored back in the destination operand which may be a register or a
In case of a double word dividend (32-bit)- The higher word in DX and lower word in AX. memory location.
o The quotient and the remainder, in this case, will be in AX and DX respectively. If OF is set, it indicates that the operation could not be completed successfully.
This instruction does not affect any flag.
This instruction affects all the condition code flags.
IDIV: Signed Division
Same operation as the DIV instruction, but with signed operands and signed Results
Arithmetic Instructions 53
Arithmetic Instructions 54
Arithmetic Instructions 55
Arithmetic Instructions 56
DAS: Decimal Adjust after Subtraction AAA: ASCII Adjust After Addition
Performed after an addition of two ASCII coded operands to give a byte of result in AL.
This instruction converts the result of subtraction of two packed BCD numbers to a valid BCD
o Converts the resulting contents of AL to unpacked decimal digits.
number.
When lower 4 bits of AL is checked for a valid BCD number in the range 0 to 9
o The subtraction has to be in AL only. If it is between 0 to 9 and AF is zero
If the lower nibble of AL is greater than 9 o AAA sets the 4 high order bits of AL to 0 [The AH must be cleared before addition]
o The OF is undefined after DAS. o The AH is modified as sum of previous contents (usually 00) and the carry from the adjustment
This instruction does not give exact ASCII codes of the sum, but they can be obtained by adding 3030H to AX.
Arithmetic Instructions 57
Arithmetic Instructions 58
AAM : ASCII Adjust after Multiplication
AAS: ASCII Adjust AL after Subtraction
After execution, converts the product available in AL into unpacked BCD format.
AAS instruction corrects the result in AL register after subtracting two unpacked ASCII operands.
Follows a multiplication instruction that multiplies two unpacked BCD operands
o The result is in unpacked decimal format.
o higher nibbles of the multiplication operands should be 0.
If the lower 4 bits of AL register are greater than 9 or if the AF flag is 1 o The multiplication of such operands is carried out using MUL instruction.
o AL is decremented by 6 and AH register is decremented by 1 o Result of multiplication is available in AX.
o CF and AF are set to 1.
Logical Instructions 61
Logical Instructions 62
AND: logical AND
These type of instructions are used for carrying out the bit by bit This instruction bit by bit ANDs the source operand to the destination operand
o Source may be an immediate, a register or a memory location
shift, rotate, or basic logical operations.
o Destination may be a register or a memory location.
All the condition code flags are affected depending upon the • At least one of the operands should be a register or a memory operand.
Logical Instructions 65
Logical Instructions 66
o The result of this AND ing operation is not available for further use
• But flags (OF, CF, SF, ZF and PF) are affected.
o If it is a word string operation, the index registers are updated by two. o There are two more options of the REP instruction.
o The counter in both the cases, is decremented by one. • The first is REPE/ REPZ, i.e. repeat operation while equal/zero.
• The second is REPNE/REPNZ for repeating the operation while not equal/not zero.
o After each comparison the index registers are updated depending upon DF
and the counter is decremented
String Manipulation Instructions 73
String Manipulation Instructions 74
o The length of the string is stored in CX and The DF controls the mode for scanning
o When a match is found in the string, execution stops and the zero flag is set.
• If no match is found, the zero flag is reset.
o DI modified after each iteration automatically. o Conditional Control Transfer (Branch) Instructions
o DF controls the direction of operation • Control is transferred to the specified location if a particular flag satisfies the condition in the
previous result.
Unconditional Branch Instructions 81
Unconditional Branch Instructions 82
o No flags are affected by this instruction • If not, the execution continues sequentially.
(a) Flag manipulation instructions The DF and IF controls the processor operation by interrupt responses and
• directly modify some of the flags of 8086 auto-increment or auto-decrement modes.
o Also be called machine or processor control instructions.
(b) Machine control instructions
The other flags can be modified using POPF and SAHF instructions,
• control the bus usage and execution.
o Data transfer instructions
Flag Manipulation & Process Control Instructions 95
Assembler Directives and Operators 98
Machine Language
HLT Processor enters the halt state.
o The instruction mnemonics are directly written in ALP.
o To pull out of the halt state are to reset the processor or to interrupt it.
NOP Processor does not perform any operation till 4 clock cycles o The address values and constants can be identified by labels
ESC frees the bus for an external master (coprocessor or peripheral devices.) More understandable Easy to handle and manipulate data
LOCK prefix may appear with another instruction
o Documentation facility (which was not possible with machine language
o Used in case of programming for multiprocessor systems.
o Bus access is not allowed for another master till the other instruction is executed programming)
WAIT Holds the operation of processor with the current status till TEST# pin goes low.
Assembler 99
Assembler Directive 10
0
An assembler is a program used to convert an assembly language program (ALP) into the For completing all the tasks, an assembler needs to know
equivalent machine code modules which may further be converted to executable codes.
o Required storage for a particular constant or a variable
ALP ML Hex Code
Assembler
(Assembly Language Program) (Machine Language) (Executable Program)
o Logical names of the segments
• The logical errors or other programming errors are not found out by the assembler.
give these types of hints to the assembler
• They help the assembler to understand the programs to prepare the codes.
Operator 10
1
Assembler Directives and Operators 10
2
DB: Define Byte
Operator is another type of hint that helps assembler
To reserve byte or bytes of memory locations in the available memory, While preparing the EXE file.
o To assign a particular constant with a label or o Directs the assembler to allocate the specified no. of memory bytes to the said data type (constant, variable,
string, etc. ),
o Initialise particular memory locations or Examples
o labels with constants . RANKS DB 01H, 02H, 03H, 04H
o Directs the assembler to reserve 4 memory locations for a list named RANKS
o Initialise them with the above specified 4 values
Operators perform the arithmetic and logical tasks unlike
MESSAGE DB ’GOOD MORNING'
Assembler Directives (that just direct the assembler to correctly o Reserve the no. of bytes of memory equal to the number of characters in the string named MESSAGE
o Initialise those locations by the ASCII equivalent of these characters.
interpret the program to code it appropriately).
VALUE DB 50H
o Reserve 50H memory bytes and leave them uninitialized for the variable named VALUE.
Used to inform the assemble, the names of the logical segments to be assumed for Marks the end of an assembly language program.
different segments used in the program. o When the assembler comes across this END directive, it ignores the source lines available later on.
o Each segment is given a name. CODE for code segment, DATA for data segment etc.
o END statement should be the last statement in the file and should not appear in between.
o The ASSUME statement is a must at the starting of each assembly language program
without which a message ‘CODE/DATA EMITTED WITHOUT SEG MENT’ may be issued by an assembler. ENDP: END of Procedure
Example The ENDP directive is used to indicate the end of a procedure (subroutine).
ASSUME CS : CODE o The Procedure name (label) may appear as a prefix with the directive ENDP.
o Directs the assembler that the machine codes are available in a segment named CODE
ENDS: END of Segment
o Segment CODE consider as a source segment for the machine codes of the program
ASSUME DS : DATA Marks the end of a logical segment.
o indicates to the assembler that the data items related to the program, are available in a logical segment o The names appear with the ENDS directive as prefixes.
named DATA
o Segment DATA consider as a default data segment for each memory operation, related to the data o Any statement after ENDS will be neglected from the segment.
EXTRN: External and PUBLIC: Public GROUP: Group the Related Segments
EXTRN informs the assembler that the names, procedures and labels declared after this Used to form logical groups of segments with similar purpose or type.
directive have already been defined in some other assembly language modules. Used to inform the assembler to form a logical group of the following segment names.
o While in the other module, where the names, procedures and labels actually appear, they must be The assembler passes an information to the linker/loader to form the code such that the group
declared public, using the PUBLIC directive. declared segments or operands must lie within a 64Kbyte memory segment.
The statement of declaration EXTRN must be accompanied by the SEGMENT and ENDS o Thus all such segments and labels can be addressed using the same segment base.
directives of the MODULE 1, before it is called in MOBULE 2. PROGRAM GROUP CODE, DATA, STACK
o Thus the MODULE 1 and MODULE 2 must have the following declarations. o The above statement directs the loader/linker to prepare an EXE file such that CODE, DATA and STACK
segment must lie within a 64kbyte memory segment that is named as PROGRAM.
o Now, for the ASSUME statement, one can use the label PROGRAM rather than CODE, DATA and STACK as
shown.
o With a single declaration statement, a number of variables can be declared local, as shown.
o After reserving 50H locations for DATAS, the next location will be assigned a label DATA-LAST and its type will LOCAL a, b, DATA, ARRAY, ROUTINE
be byte and far.
Assembler Directives and Operators 11
3
Assembler Directives and Operators 11
4
ORG : Origin
NAME: logical Name of a Module
Directs the assembler to start the memory allotment for the particular segment, block or
The NAME directive is used to assign a name to an assembly language program module.
code from the declared address in the ORG statement.
o The names may point out the functions of the different modules and hence may help in the documentation.
o ORG 200H will start the code from 0200H instead of 0000H (default) in code segment
OFFSET: Offset of a label
• Code for different modules and segments can be located in the available memory.
Used to decide the offsets of arrays, strings, labels and procedures in their default segments
PROC: Procedure
o OFFSET operator with a label, computes the 16-bit displacement (offset) of the particular label, and replaces
the string ‘OFFSET LABEL’ by the computed displacement. Marks the start of a named procedure, as well as its type (NEAR or FAR) in the statement.
o Commonly used in indirect, indexed, based indexed addressing types to refer to the memory indirectly. o RESULT PROC NEAR marks start of a routine RESULT located in the same segment of memory.
• FAR directive is used for the procedures to be called in different segments of memory.
Indicates that only one byte is required to code the displacement for a jump. Indicates the assembler that the label following FAR PTR is not available within the same segment
o 2 bytes offset followed by 2 bytes segment address to address it-32 bit address
o Otherwise, the assembler may reserve two bytes for the displacement.
JMP SHORT LABEL
Directs the assembler to decide the data type of the specified label and replaces the ‘TYPE’ Indicates that the label following NEAR PTR is in the same segment
label by data type. o 2 byte offset to address it- 16 bit address.
o For word type variable, the data type is 2, for double word type, it is 4, and for byte type, it is 1. If a label is not preceded by NEAR PTR or FAR PTR, then it is by default considered a NEAR PTR label
MOV AX, TYPE STRING moves the value 0002H in AX, if STRING is a word array
4. Move a byte string, 16-bytes long, from the offset 0200H to 12 4. Move a byte string, 16-bytes long, from the offset 0200H to 12
5 6
0300H in the segment 7000H. 0300H in the segment 7000H.
--Alternative Method using LOOP instruction--
4. Move a byte string, 16-bytes long, from the offset 0200H to 12 5. Find out the largest number from an unordered array of sixteen 8-bit 12
7 8
0300H in the segment 7000H. numbers stored sequentially in the memory locations starting at offset
0500H in the segment 2000H.
--Alternative Method using String instructions--
12
9
Disadvantages of machine level programming 13
0
The programs are not understood by everyone and the results are
The programming in assembly language is not so complicated as in machine language because the
A program called ‘assembler’ is used to convert the mnemonics of
function of coding is performed by an assembler.
instructions along with the data into their equivalent object code The chances of error being committed are less because the mnemonics are used instead of numerical
modules. opcodes. It is easier to enter an assembly language program.
In assembly language programming, the mnemonics are directly used Advanced assemblers provide facilities like macros, lists, etc. making the task of programming much easier.
Assemblers 13
3
13
4
Assembler is a program that converts an assembly input file (source file) to an object
file that can further be converted into machine codes (executable file) using a linker.
The recent versions of the assembler are designed with many facilities like macro-
assemblers, numerical processor assemblers, procedures, functions and so on. Programming with an
There are a number of assemblers available like MASM, TASM and DOS assembler.
Assembler
MASM (Microsoft Macro Assembler) is one of the popular assemblers used along
with a LINK program (to structure the codes generated by MASM in the form of an executable file).
MASM reads the source program as its input and provides an object file.
The LINK accepts the object file produced by MASM as input and produces an EXE file
1. Write a program for addition of two numbers 13
5
1. Write a program for addition of two numbers 13
6
--Alternative Method--
2. Write a program for the addition of a series of 8-bit 13 2. Write a program for the addition of a series of 8-bit numbers. The series 13
7 8
contains 100(numbers).
numbers. The series contains 100(numbers).
3. A program to find out the largest number from a given unordered array 13 3. A program to find out the largest number from a given unordered array 14
9 0
of 8-bit numbers, stored in the locations starting from a known address. of 8-bit numbers, stored in the locations starting from a known address.
4. A program to find out the largest number from a given unordered array 14 5. A program to find out the number of even and odd numbers from a 14
1 2
of words, stored in the locations starting from a known address. given series of 16-bit hexadecimal numbers.
6. Write a program to find out the number of positive numbers and 14 7. Write a program to move a string of data words from offset 2000H to 14
3 4
negative numbers from a given series of signed numbers. offset 3000H the length of the string is 0FH.
7. Write a program to move a string of data words from offset 2000H to 14 8. Write an assembly language program to arrange a given series of 14
5 6
offset 3000H the length of the string is 0FH. hexadecimal bytes in ascending order.
--Alternative method-- Out of different sorting algorithms, bubble sorting logic is used
here.
8. Write an assembly language program to arrange a given series of 14 8. Write an assembly language program to arrange a given series 14
7 8
hexadecimal bytes in ascending order. of hexadecimal bytes in ascending order.
Procedure of bubble sorting logic.
First number of the series is compared with the second one.
If the first number is greater than second, exchange their positions in the series otherwise leave the positions unchanged.
Then, compare the second number in the recent form of the series with third
Repeat the exchange part that you have carried out for the first and the second number, and for all the remaining numbers
of the series.
9. Write a program to perform a one byte BCD addition 14 9. Write a program to perform a one byte BCD addition 15
9 0
10. Write a program that performs addition, subtraction, multiplication and division of 15 11. Write a program to find out whether a given byte is in the string or not. 15
the given operands. Perform BCD operation for addition and subtraction 1 2
If it is in the string, find out the number of times the given byte repeated
in the string.
12. Decide whether the parity of a given number is even or odd. If parity is 15 13. Write a program for the addition of two 3 x 3 matrices. The matrices 15
3 4
even set DL to 00; else, set DL to 01. The given number may be a multibyte are stored in the form of lists (row wise). Store the result of addition in the
number third list.
13. Write a program for the addition of two 3 x 3 matrices. The matrices are stored in 15 14. Write a program to find out the product of two matrices. 15
the form of lists (row wise). Store the result of addition in the third list. 5 6
Store the result in the third matrix. The matrices are specified as
in the previous Program
14. Write a program to find out the product of two matrices. Store the 15 14. Write a program to find out the product of two matrices. Store the result in the 15
7 third matrix. The matrices are specified as in the previous Program 8
result in the third matrix. The matrices are specified as in the previous
Program
15. Write a program to convert a 16 bit binary number into equivalent BCD 15 16. Write a program to convert a BCD number into an equivalent binary 16
9 0
number number.
17. Write a program to convert an 8 bit binary number into equivalent gray 16 17. Write a program to convert an 8 bit binary number into equivalent gray 16
1 2
code. code.
18. Find square root of a two digit number. Assume that the number is a 16 16
3 4
perfect square.
Passing Parameter to Procedures- Parameter Declared Global 16 Passing Parameter to Procedures- Storing Parameters in GPR 17
9 0
Passing Parameter to Procedures- Storing Parameters in Memory 17 Passing Parameter to Procedures- Using Stack 17
1 2