Sunteți pe pagina 1din 99

--------------------------------------------------------------------------------------------------------------------------------------

EX.NO: 1 ADDITION AND SUBTRACTION OF 8-BIT DATA


--------------------------------------------------------------------------------------------------------------------------------------

Aim: To write an assembly language code to add 2 signed or unsigned numbers using
immediate addressing mode .

Algorithm:
Step-1:Move operand 1 to accumulator .
Step-2:Add operand 2 with accumulator data and store the result in accumulator .
Procedure:
1. Reset the system using RES button .
2. To enter the program into memory location, Press NEXT and enter memory location
address of the instruction .
3. Enter hex values of the program .
4. Press NEXT to go to the next memory location .
5. Enter Hex value .
6. Enter hex values into memory location by pressing NEXT button till the end of the
program .
7. Press RES button .
8. For the execution of the program , Make use of GO command, give starting address of the
program. Press EXEC button with the help of EXAM REGISTER button and SUBSTITUTE(SUB)
button, the content of memory location in which result is stored can be examined .

PROGRAM:
MVI A, Op 1
ADI Op 2
STA 4200
RST 1

Result: Program to add 2 signed or numbers using immediate addressing mode executed
successfully
Unsigned : Input 1: Op1 = 20 ; Op2 = 24
Output 1: 44
Input 2: Op1 = 32 ; Op2 = 25
Output 2: 57
Signed : Input 1: Op1= FA(-6) ; Op2 = FB(-5)
Output = F5 (-11)
Input 2 : Op1 = FC (-4) ; Op2 = FE(-2)
Output 2 : FA(-6)
Aim: To write an assembly language code to add 2 signed or unsigned numbers using
register addressing mode .

Algorithm:
Step-1:Move operand 1 to accumulator .
Step-2:Move operand 2 to register B .
Step-3:Add contents of register B with accumulator content and store the result in
accumulator .

Procedure:
1. Reset the system using RES button .
2. To enter the program into memory location, Press NEXT and enter memory location
address of the instruction .
3. Enter hex values of the program .
4. Press NEXT to go to the next memory location .
5. Enter Hex value .
6. Enter hex values into memory location by pressing NEXT button till the end of the
program .
7. Press RES button .
8. For the execution of the program , Make use of GO command, give starting address of the
program. Press EXEC button with the help of EXAM REGISTER button and SUBSTITUTE(SUB)
button, the content of memory location in which result is stored can be examined .

PROGRAM:
MVI A, Op1
MVI B, Op2
ADD B
STA 4200
RST 1

Result: Program to add 2 signed or unsigned numbers using register addressing mode
executed successfully
Unsigned : Input 1: Op1 = 25 ; Op2 = 35
Output 1: 5A
Input 2: Op1 = 27 ; Op2 = 37
Output 2: 5E
Signed : Input 1: Op1= FF(-23) ; Op2 = CA(-36)
Output = A7 (-59)
Input 2 : Op1 = FC (-4) ; Op2 = FE(-2)
Output 2 : FA(-6)
Aim: To write an assembly language code to add 2 signed or unsigned numbers using
memory addressing mode .

Algorithm:
Step-1: Store 2 operands in 2 consecutive memory locations .
Step-2: Make HL pair point to memory location the contain operand 1 .
Step-3: Move Op 1 to accumulator from memory location .
Step-4: Increment HL pair so that it points to memory location that contains Op2 .
Step-5: Add contents of memory pointed by HL pair with accumulator content and store
the result in accumulator .

Procedure:
1. Reset the system using RES button .
2. To enter the program into memory location, Press NEXT and enter memory location
address of the instruction .
3. Enter hex values of the program .
4. Press NEXT to go to the next memory location .
5. Enter Hex value .
6. Enter hex values into memory location by pressing NEXT button till the end of the
program .
7. Press RES button .
8. For the execution of the program , Make use of GO command, give starting address of the
program. Press EXEC button with the help of EXAM REGISTER button and SUBSTITUTE(SUB)
button, the content of memory location in which result is stored can be examined .

PROGRAM:
LXI H,4200
MOV A,M
INX H
ADD M
STA 4202
RST 1
Result: Program to add 2 signed or unsigned number using memory addressing mode
executed successfully .
Unsigned : Input 1: Op1 = 23 ; Op2 = 36
Output 1: 59
Input 2: Op1 = 19 ; Op2 = 18
Output 2: 31
Signed : Input 1: Op1= AA(-56) ; Op2 = CA(-36)
Output = -92
Input 2 : Op1 = FC (-4) ; Op2 = FE(-2)
Output 2 : FA(-6)
Aim: To write an assembly language code to subtract 2 signed or unsigned numbers using
immediate addressing mode .

Algorithm:
Step-1:Move operand 1 to accumulator .
Step-2:Subtract operand 2 with accumulator data and store the result in accumulator .
Procedure:
1. Reset the system using RES button .
2. To enter the program into memory location, Press NEXT and enter memory location
address of the instruction .
3. Enter hex values of the program .
4. Press NEXT to go to the next memory location .
5. Enter Hex value .
6. Enter hex values into memory location by pressing NEXT button till the end of the
program .
7. Press RES button .
8. For the execution of the program , Make use of GO command, give starting address of the
program. Press EXEC button with the help of EXAM REGISTER button and SUBSTITUTE(SUB)
button, the content of memory location in which result is stored can be examined .

PROGRAM:
MVI A, Op 1
SUI Op 2
STA 4200
RST 1

Result: Program to subtract 2 signed or unsigned number using immediate addressing


mode executed successfully .
Unsigned : Input 1: Op1 = 36 ; Op2 = 23
Output 1: 13
Input 2: Op1 = 63 ; Op2 = 54
Output 2: F
Aim: To write an assembly language code to subtract 2 signed or unsigned numbers using
register addressing mode .

Algorithm:
Step-1:Move operand 1 to accumulator .
Step-2:Move operand 2 to register B .
Step-3:Subtract contents of register B with accumulator content and store the result in
accumulator .

Procedure:
1. Reset the system using RES button .
2. To enter the program into memory location, Press NEXT and enter memory location
address of the instruction .
3. Enter hex values of the program .
4. Press NEXT to go to the next memory location .
5. Enter Hex value .
6. Enter hex values into memory location by pressing NEXT button till the end of the
program .
7. Press RES button .
8. For the execution of the program , Make use of GO command, give starting address of the
program. Press EXEC button with the help of EXAM REGISTER button and SUBSTITUTE(SUB)
button, the content of memory location in which result is stored can be examined .

PROGRAM:
MVI A, Op1
MVI B, Op2
SUB B
STA 4200
RST 1

Result: Program to subtract 2 signed or unsigned number using register addressing mode
executed successfully .
Unsigned : Input 1: Op1 = 95 ; Op2 = 19
Output 1: 7C
Input 2: Op1 = 76 ; Op2 = 19
Output 2: 35
Aim: To write an assembly language code to subtract 2 signed or unsigned numbers using
memory addressing mode .

Algorithm:
Step-1: Store 2 operands in 2 consecutive memory locations .
Step-2: Make HL pair point to memory location the contain Op 1 .
Step-3: Move Op 1 to accumulator from memory location .
Step-4: Increment HL pair so that it points to memory location that contains Op2 .
Step-5: Subtract contents of memory pointed by HL pair with accumulator content and
store the result in accumulator .

Procedure:
1. Reset the system using RES button .
2. To enter the program into memory location, Press NEXT and enter memory location
address of the instruction .
3. Enter hex values of the program .
4. Press NEXT to go to the next memory location .
5. Enter Hex value .
6. Enter hex values into memory location by pressing NEXT button till the end of the
program .
7. Press RES button .
8. For the execution of the program , Make use of GO command, give starting address of the
program. Press EXEC button with the help of EXAM REGISTER button and SUBSTITUTE(SUB)
button, the content of memory location in which result is stored can be examined .

PROGRAM:
LXI H,4200
MOV A,M
INX H
SUB M
STA 4202
RST 1
Result: Program to subtract 2 signed or unsigned numbers using memory addressing mode
executed successfully .
Unsigned : Input 1: Op1 = AB ; Op2 = 07
Output 1: A4
Input 2: Op1 = FE ; Op2 = EB
Output 2: 13
--------------------------------------------------------------------------------------------------------------------------------------

EX.NO: 2 TRANSFERRING BLOCK OF DATA


--------------------------------------------------------------------------------------------------------------------------------------

Aim: Write an assembly language code to transfer block of data from one memory location
to another location .

Algorithm:
Step-1: Make a register pair acts as a points to source memory .
Step-2: Make another pair to acts as a pointer to destination memory location .
Step-3: Using Accumulator, data from source memory location transferred to destination
memory location .

Procedure:
1. Reset the system using RES button .
2. To enter the program into memory location, Press NEXT and enter memory location
address of the instruction .
3. Enter hex values of the program .
4. Press NEXT to go to the next memory location .
5. Enter Hex value .
6. Enter hex values into memory location by pressing NEXT button till the end of the
program .
7. Press RES button .
8. For the execution of the program , Make use of GO command, give starting address of the
program. Press EXEC button with the help of EXAM REGISTER button and SUBSTITUTE(SUB)
button, the content of memory location in which result is stored can be examined .

PROGRAM:
LXI H 4200
LXI D 4300
MVI C, 04
MOV A,M
INX H
STAX D
INX D
DCR C
JNZ L2
RST 1

Result: Program to transfer block of data has been executed successfully .


Input: 4200 : 02 4300 : 02
4201 : 36 4301 : 36
4202 : 46 4302 : 46
4203 : DC 4303 : DC
--------------------------------------------------------------------------------------------------------------------------------------

EX.NO: 3 ADDING AN ARRAY OF UNSIGNED NUMBERS


--------------------------------------------------------------------------------------------------------------------------------------

Aim: Write an assembly language code to add an memory carry of numbers .


Algorithm:
Step-1: Make a register pair point to initial memory location .
Step-2: Load accumulator with data pointed by register .
Step-3: Increment register pair & add the accumulator content to data pointed by register
pair & process continues .

Procedure:
1. Reset the system using RES button .
2. To enter the program into memory location, Press NEXT and enter memory location
address of the instruction .
3. Enter hex values of the program .
4. Press NEXT to go to the next memory location .
5. Enter Hex value .
6. Enter hex values into memory location by pressing NEXT button till the end of the
program .
7. Press RES button .
8. For the execution of the program , Make use of GO command, give starting address of the
program. Press EXEC button with the help of EXAM REGISTER button and SUBSTITUTE(SUB)
button, the content of memory location in which result is stored can be examined .

PROGRAM:
LXI H, 4200
MVI C,05
MOV A,M
INX H
ADD M
DCR C
JNZ L1
STA 4300
RST 1

Result: The program to add an array of unsigned numbers, executed successfully .


Input: 4200 : 02
4201 : 12
4202 : 02
4203 : 47
4204 : 56
4205 : 39
Output : 4300 : DC
--------------------------------------------------------------------------------------------------------------------------------------

EX.NO:4 ADDING AN ARRAY OF UNSIGNED NUMBERS WITH CARRY


--------------------------------------------------------------------------------------------------------------------------------------

Aim: Write an assembly language code to add an array of unsigned numbers


Algorithm:
Step-1: Make a register pair point to an initial memory location .
Step-2: Load accumulator with data pointed by register pair .
Step-3: Increment register pair & add the accumulator content to data pointed by register
pair & process continues .

Procedure:
1. Reset the system using RES button .
2. To enter the program into memory location, Press NEXT and enter memory location
address of the instruction .
3. Enter hex values of the program .
4. Press NEXT to go to the next memory location .
5. Enter Hex value .
6. Enter hex values into memory location by pressing NEXT button till the end of the
program .
7. Press RES button .
8. For the execution of the program , Make use of GO command, give starting address of the
program. Press EXEC button with the help of EXAM REGISTER button and SUBSTITUTE(SUB)
button, the content of memory location in which result is stored can be examined .

PROGRAM:
LXI H, 4200
MVI C, 05
MVI B, 00
MOV A,M
INX H
ADD M
JZC L2
JNR B
DCR C
JNZ L1
STA 4300
RST 1

Result: The program to add an array of unsigned numbers with carry has been executed
successfully .
Input: 4200 : 02
4201 : FA
4202 : 31
4203 : 05
4204 : 20
4205 : 01
Output : 4300 : 53
Reg B : 1
--------------------------------------------------------------------------------------------------------------------------------------

EX.NO:5 FINDING COUNT OF EVEN AND ODD NUMBERS


--------------------------------------------------------------------------------------------------------------------------------------

Aim: Write an assembly language code to find count of even & odd numbers in a block of
data

Algorithm:
Step-1: Make a register pair point to initial memory location .
Step-2: Initialize contents of two general purpose register to 00 & count the no. of even &
odd numbers .

Step-3: Load accumulator with data pointed by register pair & perform rotate right with
carry operation

Step-4: Depending on carry flag , Increment B & D register to count the no. of even & odd
numbers respectively.

Procedure:
1. Reset the system using RES button .
2. To enter the program into memory location, Press NEXT and enter memory location
address of the instruction .
3. Enter hex values of the program .
4. Press NEXT to go to the next memory location .
5. Enter Hex value .
6. Enter hex values into memory location by pressing NEXT button till the end of the
program .
7. Press RES button .
8. For the execution of the program , Make use of GO command, give starting address of the
program. Press EXEC button with the help of EXAM REGISTER button and SUBSTITUTE(SUB)
button, the content of memory location in which result is stored can be examined .

PROGRAM:
LXI H, 4200
MVI C,05
MVI B,00
MVI D,00
MOV A,M(L2)
RRC
JC L1
INR B
JMP L3
INR D
INX H
DCR C
JNZ L2
RST 1

Result: Program to count no. of even & odd numbers has been executed successfully .
Input: 4200 : 02
4201 : 67
4202 : 31
4203 : 22
4204 : 33
4205 : 58
Output : Reg B : 03
Reg D : 03
--------------------------------------------------------------------------------------------------------------------------------------

EX.NO:6 FINDING COUNT OF POSITIVE AND NEGATIVE NUMBERS


--------------------------------------------------------------------------------------------------------------------------------------

Aim: Write an assembly language code to find count of positive & negative numbers in a
block of data

Algorithm:
Step-1: Make a register pair point to initial memory location .
Step-2: Initialize contents of two general purpose register to 00 & count the no. of positive
& negative numbers .

Step-3: Load accumulator with data pointed by register pair & perform rotate right with
carry operation

Step-4: Depending on carry flag , Increment B & D register to count the no. of positive &
negative numbers respectively.

Procedure:
1. Reset the system using RES button .
2. To enter the program into memory location, Press NEXT and enter memory location
address of the instruction .
3. Enter hex values of the program .
4. Press NEXT to go to the next memory location .
5. Enter Hex value .
6. Enter hex values into memory location by pressing NEXT button till the end of the
program .
7. Press RES button .
8. For the execution of the program , Make use of GO command, give starting address of the
program. Press EXEC button with the help of EXAM REGISTER button and SUBSTITUTE(SUB)
button, the content of memory location in which result is stored can be examined .

PROGRAM:
LXI H, 4200
MVI C,06
MVI B,00
MVI D,00
MOV A,M(L2)
RLC
JC L1
INR B
JMP L3
INR D
INX H (L3)
DCR C
JNZ L2
RST 1

Result: Program to count no. of positive & negative numbers has been executed
successfully .
Input: 4200 : FF
4201 : 02
4202 : 31
4203 : 22
4204 : 58
4205 : 12
Output : Reg B : 05
Reg D : 01
--------------------------------------------------------------------------------------------------------------------------------------

EX.NO:7 FINDING LARGEST NUMBER IN THE SERIES


--------------------------------------------------------------------------------------------------------------------------------------

Aim: Write an assembly language code to find largest number in series .


Algorithm:
Step-1: Make a register pair point to initial memory location .
Step-2: Load accumulator with data pointed by HL pair .
Step-3: Compare contents of accumulator & memory location .
Step-4: Depending on carry flag , swap contents of accumulator & memory location &
largest number is stored in accumulator .

Procedure:
1. Reset the system using RES button .
2. To enter the program into memory location, Press NEXT and enter memory location
address of the instruction .
3. Enter hex values of the program .
4. Press NEXT to go to the next memory location .
5. Enter Hex value .
6. Enter hex values into memory location by pressing NEXT button till the end of the
program .
7. Press RES button .
8. For the execution of the program , Make use of GO command, give starting address of the
program. Press EXEC button with the help of EXAM REGISTER button and SUBSTITUTE(SUB)
button, the content of memory location in which result is stored can be examined .

PROGRAM:
LXI H, 4200
MVI C,05
MOV A,M
INX H
CMP M(L1)
JC L1
MOV A,M
INX H (L2)
DCR C
JNZ L2
RST 1

Result: Program to find largest number in series has been executed successfully .
Input: 4200 : 23
4201 : 56
4202 : 02
4203 : 37
4204 : 43
Output : Reg A : 56
--------------------------------------------------------------------------------------------------------------------------------------

EX.NO:7 FINDING SMALLEST NUMBER IN THE SERIES


--------------------------------------------------------------------------------------------------------------------------------------

Aim: Write an assembly language code to find smallest number in series .


Algorithm:
Step-1: Make a register pair point to initial memory location .
Step-2: Load accumulator with data pointed by HL pair .
Step-3: Compare contents of accumulator & memory location .
Step-4: Depending on carry flag , swap contents of accumulator & memory location &
smallest number is stored in accumulator .

Procedure:
1. Reset the system using RES button .
2. To enter the program into memory location, Press NEXT and enter memory location
address of the instruction .
3. Enter hex values of the program .
4. Press NEXT to go to the next memory location .
5. Enter Hex value .
6. Enter hex values into memory location by pressing NEXT button till the end of the
program .
7. Press RES button .
8. For the execution of the program , Make use of GO command, give starting address of the
program. Press EXEC button with the help of EXAM REGISTER button and SUBSTITUTE(SUB)
button, the content of memory location in which result is stored can be examined .

PROGRAM:
LXI H, 4200
MVI C,05
MOV A,M
INX H
CMP M(L1)
JC L1
MOV A,M
INX H (L2)
DCR C
JNZ L2
RST 1

Result: Program to find smallest number in series has been executed successfully .
Input: 4200 : 01
4201 : 12
4202 : 20
4203 : 32
4204 : 02
Output : Reg A : 01
--------------------------------------------------------------------------------------------------------------------------------------

EX.NO:7 FINDING LENGTH OF THE SERIES


--------------------------------------------------------------------------------------------------------------------------------------

Aim: Write an assembly language code to find length of the series .


Algorithm:
Step-1: Make a register pair point to initial memory location .
Step-2: Load accumulator with data pointed by HL pair .
Step-3: Compare contents of accumulator with FF .
Step-4: Depending on zero flag , count is incremented and result is stored in C register .
Procedure:
1. Reset the system using RES button .
2. To enter the program into memory location, Press NEXT and enter memory location
address of the instruction .
3. Enter hex values of the program .
4. Press NEXT to go to the next memory location .
5. Enter Hex value .
6. Enter hex values into memory location by pressing NEXT button till the end of the
program .
7. Press RES button .
8. For the execution of the program , Make use of GO command, give starting address of the
program. Press EXEC button with the help of EXAM REGISTER button and SUBSTITUTE(SUB)
button, the content of memory location in which result is stored can be examined .

PROGRAM:
LXI H, 4200
MVI C,00
MOV A,M(L2)
CPI FF
JZ L1
INR C
INX H
JMP L2
RST 1(L1)

Result: Program to find length of the series has been executed successfully .
Input: 4200 : 01
4201 : 08
4202 : 12
4203 : 53
4204 : 62
4205 : FF
Output : Reg A : 05
CONVERSION OF ASCII VALUE TO
HEXADECIMAL NUMBER
AIM:
To write an assembly language code that finds hexadecimal number
for a given ASCII value.

ALGORITHM:
Step 1: Make a register pair to point to initial memory location.
Step 2: Load the accumulator with data pointed by HL.
Step 3: Load ‘39’ into B register and compare content of register with
accumulator.
Step 4: If carry flag is not set goto step 6 else goto step 5
Step 5: Load 30 into C and subtract content of C register with
accumulator content.
Step 6: Load 37 into D register and perform subtraction between
content of D and accumulator content.
Step 7: Stop the program.

Procedure:
1. Reset the system using RES button.
2. To enter program into memory location, press NEXT and enter
memory location address of instruction.
3. Enter hex value of the program.
4. Press NEXT to go to the next memory location.
5. Enter next hex value.
6. Enter hex values into memory location by pressing NEXT button
till the end of the program.
7. Press RES button.
8. For execution of the program, make use of GO command. Give
starting address of program. Press EXEC button with the help of
EXAM REGISTER & SUB button, the content of memory location
in which result stored in examined.

Program:
LXI H,4200
MOV A,M
MVI B,39
CMP B
JNC L1
MVI C,30
SUB C
RST1
L1 MVI D,37
SUB D
RESULT:
The program to convert ASCII value to hexadecimal number has been
executed successfully.

CONVERSION OF HEXADECIMAL NUMBER


TO ASCII VALUE

AIM:
To write an assembly language code that finds ASCII value for a given
hexadecimal number.

ALGORITHM:
Step 1: Load given hexadecimal number to 4200 memory location
and load HL pair pointed memory location into the accumulator.
Step 2: Load ‘09’ into B register and compare content of register with
accumulator.
Step 3: When carry flag sets goto step 5 else goto step 4
Step 4: Load 30 into C and add content of C register with
accumulator content.
Step 5: Load 37 into D register and perform addition between
content of D and accumulator content.
Step 6: Stop the program.

Procedure:
1. Reset the system using RES button.
2. To enter program into memory location, press NEXT and enter
memory location address of instruction.
3. Enter hex value of the program.
4. Press NEXT to go to the next memory location.
5. Enter next hex value.
6. Enter hex values into memory location by pressing NEXT button
till the end of the program.
7. Press RES button.
8. For execution of the program, make use of GO command. Give
starting address of program. Press EXEC button with the help of
EXAM REGISTER & SUB button, the content of memory location
in which result stored in examined.

Program:
LXI H,4200
MOV A,M
MVI B,09
CMP B
JNC L1
MVI C,30
ADD C
L2 RST1
L1 MVI D,37
ADD D
JMP L2

RESULT:
The program to convert hexadecimal number to ASCII value has been
executed successfully.

ADDING TWO 16 BIT NUMBERS

AIM:
To write an assembly language code to add two 16-bit numbers.

ALGORITHM:
Step 1: Make one register pair point to one memory location and
another register point to another memory location.
Step 2: Make content of c as ‘02’ and accumulator content loaded
with data pointed by HL pair.
Step 3: Move accumulator content to B and load accumulator with
data pointed by DE register pair.
Step 4: Add accumulator content, ’B’ register content & carry and
store in accumulator .Result is moved to memory location depending
on status of zero flag.

Procedure:
1. Reset the system using RES button.
2. To enter program into memory location, press NEXT and enter
memory location address of instruction.
3. Enter hex value of the program.
4. Press NEXT to go to the next memory location.
5. Enter next hex value.
6. Enter hex values into memory location by pressing NEXT button
till the end of the program.
7. Press RES button.
8. For execution of the program, make use of GO command. Give
starting address of program. Press EXEC button with the help of
EXAM REGISTER & SUB button, the content of memory location
in which result stored in examined.

Program:
LXI H,4200
LXI D,4300
XRA A
MVI C,02
L1 MOV A,M
MOV B,A
LDAX D
ADC B
MOV M,A
INX H
INX D
DCR C
JNZ L1
RST1

RESULT:
The program to add two 16-bit numbers has been executed
successfully.

SUBTRACTING TWO 16 BIT NUMBERS

AIM:
To write an assembly language code to subtract two 16-bit numbers.

ALGORITHM:
Step 1: Make one register pair point to one memory location and
another register point to another memory location.
Step 2: Make content of c as ‘02’ and accumulator content loaded
with data pointed by HL pair.
Step 3: Move accumulator content to B and load accumulator with
data pointed by DE register pair.
Step 4: Subtract accumulator content, ’B’ register content & carry
and store in accumulator .Result is moved to memory location
depending on status of zero flag.

Procedure:
1. Reset the system using RES button.
2. To enter program into memory location, press NEXT and enter
memory location address of instruction.
3. Enter hex value of the program.
4. Press NEXT to go to the next memory location.
5. Enter next hex value.
6. Enter hex values into memory location by pressing NEXT button
till the end of the program.
7. Press RES button.
8. For execution of the program, make use of GO command. Give
starting address of program. Press EXEC button with the help of
EXAM REGISTER & SUB button, the content of memory location
in which result stored in examined.

Program:
LXI H,4200
LXI D,4300
XRA A
MVI C,02
L1 MOV A,M
MOV B,A
LDAX D
SBB B
MOV M,A
INX H
INX D
DCR C
JNZ L1
RST1

RESULT:
The program to subtract two 16-bit numbers has been executed
successfully.
CONVERTING GIVEN HEXADECIMAL
NUMBER INTO BCD VALUE

AIM:
To write an assembly language program to convert a given
hexadecimal number into BCD value.

ALGORITHM:
Step 1: Make SP point to one memory location and make DE pair as
a pointer to another location.
Step 2: Make HL pair point to memory location in which result should
be stored.
Step 3: The hex value is moved to accumulator and is moved to
register ‘B’.
Step 4: Performs subtractions between accumulator and register ‘B’
until carry flag sets by calling CALL instruction.

Procedure:
1. Reset the system using RES button.
2. To enter program into memory location, press NEXT and enter
memory location address of instruction.
3. Enter hex value of the program.
4. Press NEXT to go to the next memory location.
5. Enter next hex value.
6. Enter hex values into memory location by pressing NEXT button till
the end of the program.
7. Press RES button.
8. For execution of the program, make use of GO command. Give
starting address of program. Press EXEC button with the help of
EXAM REGISTER & SUB button, the content of memory location
in which result stored in examined.

Program:
LXI SP,4500
LXI H,4200
MOV A,M
MVI B,64
CALL BINBCD
MVI B,0A
CALL BINBCD
MOV M,A
RST1
BINBCD:
MVI M,FF
L1 INR M
SUB B
INC L1
ADD B
INX H
RET
RESULT:
The program to find BCD value for given hexadecimal number was
completed successfully.

CONVERTING GIVEN BCD VALUE INTO


HEXADECIMAL NUMBER

AIM:
To write an assembly language program to convert a given BCD value
into hexadecimal number

ALGORITHM:
Step 1: Make SP point to one memory location and make HL pair as
a pointer to another location.
Step 2: Move contents from memory location to accumulator.
Step 3: Now by executing “call” instruction. AND, rotate right with
carry operations are performed.
Step 4: Now contents of A and another registers are added and
stored in memory location pointed by HL.

Procedure:
1. Reset the system using RES button.
2. To enter program into memory location, press NEXT and enter
memory location address of instruction.
3. Enter hex value of the program.
4. Press NEXT to go to the next memory location.
5. Enter next hex value.
6. Enter hex values into memory location by pressing NEXT button till
the end of the program.
7. Press RES button.
8. For execution of the program, make use of GO command. Give
starting address of program. Press EXEC button with the help of
EXAM REGISTER & SUB button, the content of memory location
in which result stored in examined.

Program:
LXI SP,4500
LXI H,4200
MOV A,M
CALL BCDBIN
MOV M,A
RST1
BCDBIN:
MOV B,A
ANI 0F
MOV C,A
MOV A,B
ANI F0
RAR
RAR
RAR
RAR
MOV E,A
XRA A
MVI D,0A
L1 ADD D
DCR E
JNZ L1
ADD C
RET

RESULT:
The program to find hexadecimal number for given BCD value was
completed successfully.
Arithmetic Operations using MASM

Exp no : 1
Aim: To write an assembly language program to add two 16-bit
numbers
using MASM assembler .

Algorithm:
Step-1 : Assume code segment as CODE and data segment as DATA.
Step-2 : In DATA SEGMENT , declare op1 and op2 of type word and
result is also of type word and end it.
Step-3 : In CODE SEGMENT , load base value of data segment into
DS register using AX and load offset value of op1 into SI
register.
Step-4 : Load the content of SI into AX and content of SI is
incremented two times and load content of SI into BX and
increment SI
Step-5 : Add the content of AX and BX , and result is stored in BX
and b move content of BX into memory location .

Procedure :
1. Open the command prompt by typing ‘run’ in the windows prompt
.
2. Type edit filename and then enter the program code into editor .
3. Save the code and exit from the window , which returns to
command
prompt .
4. Compile and run the program using the command : masm
filename.asm
5. Then link the program using the command : link filename.obj
6. Debug the program using : debug filename.exe
7. Then program is executed .
8. Press ‘U’ to visualize the hex code , ‘G’ to see the register contents
and
‘Q’ to exit .

Program :
ASSUME CS : CODE , DS : DATA
DATA SEGMENT
op1 dw 3239H
op2 dw 1243H
result dw 1 dup(0)
DATA ENDS
CODE SEGMENT
START : MOV AX , DATA
MOV DS , AX
MOV SI , OFFSET op1
MOV AX , [SI]
INC SI
INC SI
MOV BX , [SI]
ADD BX , AX
INC SI
INC SI
MOV [SI] , BX
INT 03
CODE ENDS
END START

Output :
-G AX : 3239 BX : 447C CX : 0025 DX : 0000 SP : 0000
BP : 0000 SI : 0004 DI : 0000 DS : 0BBB ES : 0BAB
SS : 0BBB CS : 0BBC IP : 0014
-D 0000 0006
0BBB : 0000 39 32 43 12 7C 44

Result : The assmebly language program to add two 16-bit numbers


using MASM assembler is executed successfully .
Exp no : 2
Aim : To write an assembly language program to subtract two 16-bit
numbers using MASM assembler .

Algorithm :
Step-1 : Assume code segment as CODE and data segment as DATA .
Step-2 : In DATA SEGMENT , declare the operands as op1 and op2
of type word and result is also of type word and end it .
Step-3 : In CODE SEGMENT , load base value of data segment into
DS register using AX and load offset value of op1 into SI
register .
Step-4 : Load the content of SI into BX and increment SI two times
and load the content of SI into BX .
Step-5 : Subtract the content of BX and AX , and result is stored in
BX and move the content of BX into memory location .

Procedure :
1. Open the command prompt by typing ‘run’ in the windows prompt
.
2. Type edit filename.asm and then enter the program into editor .
3. Save the code and exit from window on editor , which returns to
command prompt .
4. Then compile the program using the command : masm
filename.asm
5. Then link the program using : link filename.obj
6. After , debug the program using the command : debug filename.exe
7. Then program is executed .
8. Press ‘U’ to visualize the hex code , ‘G’ to see the register contents
and
‘Q’ to exit .

Program :
ASSUME CS : CODE , DS : DATA
DATA SEGMENT
op1 dw 4963H
op2 dw 2365H
result dw 1 dup(0)
DATA ENDS
CODE SEGMENT
START : MOV AX , DATA
MOV DS , AX
MOV SI , OFFSET op1
MOV AX , [SI]
INC SI
INC SI
MOV BX , [SI]
SUB BX , AX
INC SI
INC SI
MOV [SI] , BX
INT 03
CODE ENDS
END START

Output :
-G AX : 4963 BX : DA02 CX : 0025 DX : 0000 SP : 0000
BP : 0000 SI : 0004 DI : 0000 DS : 0BBB ES :
0BAB
SS : 0BBB CS : 0BBC IP : 0014
-D 0000 0006
0BBB : 0000 63 49 65 23 02 DA

Result : The assembly language program to subtract two 16-bit


numbers using MASM assembler is executed successfully .
Exp no : 3
Aim : To write an assembly language program to perform
multiplication between two 16-bit numbers using MASM
assembler .

Algorithm :
Step-1 : Assume code segment as CODE , data segment as DATA .
Step-2 : In DATA SEGMENT , declare op1 and op2 of type word and
result is type double word and end it .
Step-3 : In CODE SEGMENT , load base value of data segment into
DS register using AX and load offset value of op1 into SI
register .
Step-4 : Load the content of SI into AX and content of SI is
incremented two times and load content of BX into memory
location .
Step-5 : Multiply the content of AX and BX , and result is stored in
AX , DX ; move the contents of AX , DX into memory locations .

Procedure :
1. Open the command prompt by typing ‘run’ in the windows prompt
.
2. Type edit filename and then enter the program code into editor .
3. Save the code and exit from the window , which returns to
command
prompt .
4. Compile and run the program using the command : masm
filename.asm
5. Then link the program using the command : link filename.obj
6. Debug the program using : debug filename.exe
7. Then program is executed .
8. Press ‘U’ to visualize the hex code , ‘G’ to see the register contents
and
‘Q’ to exit .

Program :
ASSUME DS : DATA , CS : CODE
DATA SEGMENT
op1 dw 0065H
op2 dw 0016H
result dd 1 dup(0)
DATA ENDS
CODE SEGMENT
START : MOV AX , DATA
MOV DS , AX
MOV SI , OFFSET [SI]
MOV AX , [SI]
INC SI
INC SI
MOV BX , [SI]
MUL BX
INC SI
INC SI
MOV [SI] , AX
INC SI
INC SI
MOV [SI] , DX
INT 03
CODE ENDS
END START

Output :
-G AX : 08AE BX : 0016 CX : 0029 DX : 0000 SP : 0000
BP : 0000 SI : 0007 DI : 0000 DS : 0BBB ES : 0BAB
CS : 0BBC IP : 0018
-D 0000 0007
0BBB : 0000 65 00 16 00 AE 08 00 00

Result : The program to multiply two 16-bit numbers using MASM


assembler is executed successfully .
Exp no : 4

Aim : To write an assembly language program to divide a 32-bit


number with a 16-bit number .

Algorithm :
Step-1 : Assume code segment as CODE , data segment as DATA .
Step-2 : In DATA SEGMENT , declare op1 of type double word and
op2 of type word , and result of type word and end it .
Step-3 : In CODE SEGMENT , load base value of data segment into
DS register using AX and load offset value of op1 into SI
register .
Step-4 : Load the content of SI into AX and content of SI is
incremented two times and load content of SI into DX .
Step-5 : Content of SI is incremented two times and load the content
of
SI into BX .
Step-6 : Divide the content of AX , DX with BX , and result is stored
in AX , move the content of AX into memory location .

Procedure :
1. Open the command prompt by typing ‘run’ in the windows prompt
.
2. Type edit filename and then enter the program code into editor .
3. Save the code and exit from the window , which returns to
command
prompt .
4. Compile and run the program using the command : masm
filename.asm
5. Then link the program using the command : link filename.obj
6. Debug the program using : debug filename.exe
7. Then program is executed .
8. Press ‘U’ to visualize the hex code , ‘G’ to see the register contents
and
‘Q’ to exit .

Program :
ASSUME CS : CODE , DS : DATA
DATA SEGMENT
op1 dd 0000 0008H
op2 dw 0002H
result dw 1 dup(0)
DATA ENDS
CODE SEGMENT
START MOV AX , DATA
MOV DS , AX
MOV SI , OFFSET op1
MOV AX , [SI]
INC SI
INC SI
MOV DX , [SI]
INC SI
INC SI
MOV BX , [SI]
DIV BX
INC SI
INC SI
MOV [SI] , AX
INT 03
CODE ENDS
END START

Output :
-G AX : 0004 BX : 0002 CX : 0029 DX : 0000 SP : 0000
BP : 0000 SI : 0008 DI : 0000 DS : 0BBB ES : 08AB
CS : 0BBC SS : 0BBA IP : 0018
-D 0000 0008
0BBB : 0000 08 00 00 00 02 00 04 00

Result : The assembly program to divide a 32-bit number with a 16-


bit number using MASM assembler is executed
successfully .
SUM OF THE SERIES
Aim:
To write an assembly language program to find sum of the series using MASM
assembler
Algorithm:
Step 1:Assume code segment as code and data segment as data.
Step 2:In Data segment, declare an NUMLIST with data byte and also result of type
dataword,load CX registers with number of databytes.
Step 3:In Code segment load the data segment into DS and offset of NUMLIST into SI. Move
first number into the AX register.
Step 4:Increment the value of SI and add simultaneously until CX register becomes
zero.Then load offset of the result into SI register.
Step 5:Then transfer AX content into the SI pointed memory location.
Procedure:
1.Open the command prompt by typing ‘cmd’ in the run.
2.Type edit filename and then enter the program code into editor.
3.Save the code and exit from the window which returns to
Command prompt.
4.Then Compile and run the program using the command
MASM:filename.asm
5.Then link the program using the command.
link filename.obj
6. Debug the program using debug filename.exe
7.Then program is executed.
8. Press U to visualize the hexcode,G to see the register contents and Q to exit.
Program:
ASSUME CS:CODE ,DS:DATA
DATA SEGMENT
NUMLIST DB 91H,22H,05H,04H,05H
COUNT EQU 5
RESULT DW 2dup(0)
DATA ENDS
CODE SEGMENT
START:MOV AX,DATA
MOV DS,AX
MOV SI,OFFSET NUMLIST
XOR AX,AX
XOR BX,BX
MOV CX,COUNT
L1:MOV BL,[SI]
ADD AX,BX
INC SI
DEC CX
JNZ L1
MOV SI,OFFSET RESULT
MOV [SI],AX
INT 03
CODE ENDS
END START
Output:
AX:00BF BX:0005 CX:0000 DX:0002 SP:0000 BP:0000 SI:0005
DI:0000 DS:0BBB CS:0BBC ES:0BAB SS:0BBB IP:0010
-D 0000 000A
0BBB:0000 91 22 05 04 05 BF 00 00
Result:
The assembly language program to find sum of the series using MASM assembler executed
successfully.
COUNT OF EVEN & ODD NUMBERS
Aim:
To write an assembly language program to count number of even and odd numbers,using
MASM assembler.
Algorithm:
Step 1:Assume code segment as code and data segment as data.
Step 2:In data segment,declare an array of number of bytes a word,co unt and result of type
word.
Step 3:In Code segment,load the base value of the data segment in’DS’
Using AX and offset value of Numlist into SI and count into CX.
Step 4: Move SI content of AX and perform Shift Right Operation by ‘02’ bit of carry
occurs,increment DX,then otherwise increment BX and continue same until CX becomes
zero.
Procedure:
1.Open the command prompt by typing ‘cmd’ in the run.
2.Type edit filename and then enter the program code into editor.
3.Save the code and exit from the window which returns to
Command prompt.
4.Then Compile and run the program using the command
MASM:filename.asm
5.Then link the program using command.
link filename.obj
6. Debug the program using debug filename.exe
7.Then program is executed.
8. Press U to visualize the hexcode,G to see the register contents and Q
to exit.
Program:
ASSUME CS:CODE , DS:DATA
DATA SEGMENT
NUMLIST DB 09H,08H,06H,01H,00H
COUNT EQU 05H
DATA ENDS
CODE SEGMENT
START: MOV AX ,DATA
MOV DS,AX
XOR BX,BX
XOR DX,DX
MOV CX,COUNT
MOV SI,OFFSET NUMLIST
L1: MOV AX,[SI]
SHR AX,01
JC L2
INC BX
JMP L3
L2:JNZ DX
L3:ADD SI,02
DEC CX
JNZ L1
INT 03
CODE ENDS
END START
Output:
AX:0030 BX:0002 CX:0000 DX:0003 SP:0000 BP:0000 SI:000A
DI:0000 DS:0BBB SS:0BBB ES:0BAB CS:0BBC IP:0020
-d 0000 000A
0BBB:0000 09 00 08 00 06 00 01 00 00 00
Result:
The assembly language program to count even and odd numbers using MASM assembler
executed successfully.
COUNT OF POSITIVE AND NEGATIVE NUMBERS
Aim:
To write an assembly language program to count the number of positive and negative
numbers using MASM assembler.
Algorithm
Step 1:Assume code segment as code and data segment as data.
Step 2:In data segment,declare an array of number of type byte or word,
Count of type byte.
Step 3:In code segment,load the base value of data segment into DS register using AX,and
the offset of NUMLIST into SI and CX with count.
Step 4:Move SI content into AX register and perform shift left by 03 bit,if carry occurs
increment DX,otherwise BX and repeat same until CX becomes zero.
Procedure:
1.Open the command prompt by typing ‘cmd’ in the run.
2.Type edit filename and then enter the program code into editor.
3.Save the code and exit from the window which returns to
Command prompt.
4.Then Compile and run the program using the command
MASM:filename.asm
5.Then link the program using command.
link filename.obj
6. Debug the program using debug filename.exe
7.Then program is executed.
8. Press U to visualize the hexcode,G to see the register contents and Q
to exit.
Program:
ASSUME CS:CODE ,DS:DATA
DATA SEGMENT
NUMLIST DB FAH,02H,09H,10H,FBH
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
XOR BX,BX
XOR DX,DX
MOV CX,05H
MOV SI, OFFSET NUMLIST
L1: MOV AX,[SI]
SHL AX,01
JC L2
INC BX
JMP L3
L2:INC DX
L3: ADD SI,02
DEC CX
JNZ L1
INT 03
CODE ENDS
END START
Output:
AX:00F8 BX:0003 CX:0000 DX:0002 SP:0000 BP:0000
SI:000A DI:0000 DS:0BBB SS:0BBB ES:0BAB CS:0BBC
IP:0020
-d 0000 000a
0BBB:0000 FA 00 02 00 09 00 10 00 FB 00
Result:
The assembly language program to count positive and negative numbers using MASM
assembler executed successfully.
LENGTH OF THE SERIES
Aim:

To write an assembly language program to find length of the series using MASM
assembler.
Algorithm:
Step-1:Assume code segment as CODE and data segment as DATA.
Step-2:In DATA SEGMENT,declare the array of numbers of tyoe bytes,count of type byte.
Step-3:In CODE SEGMENT,load the base value of the data segment into ‘DS’ using AX and
the
Offset value of NUMLIST into SI.
Step-4:MOVE the content of SI into AX,increment SI and compare it with 78H until it sees
78H
Repeat the procedure and increment CX.
Procedure:
1.Open the command prompt by typing ‘run’ in the windows prompt.
2.Enter edit filename.asm to enter the program and the editor .
3.Save the program and exit the editor which returns to the command prompt.
4.Compile and run the program using the command : masm filename.asm.
5.Link the program using the command: link filename.obj.
6.Debug the program using the command:debug filename.exe.
7.Then the program is executed successfully.
8.Press ‘U’ to visualize the hexcode,and ‘G’ to see the register contents and ‘Q’ to quit the
program.
Program:
ASSUME CS:CODE , DS:DATA
DATA SEGMENT
NUMLIST DB 02H,09H,98H,76H,78H
RESULT DB=dup(0)
DATA ENDS
CODE SEGMENT
START:
MOV AX,DATA
MOV DS,AX
MOV CX,0000H
MOV SI,OFFSET NUMLIST
L2:
MOV AL,[SI]
CMP AL,78H
JNZ L1
JNC CX
JMP L2
L1:
MOV SI,OFFSET RESULT
MOV [SI],CX
INT 03
CODE ENDS
END START
Result:
The assembly language program to find length of the series was executed successfully
LARGEST NUMBER IN THE SERIES
Aim:

To write an assembly language program to find largest number in the series using MASM
assembler.
Algorithm:
Step-1:Assume CODE segment as CODE and DATA segment as DATA.
Step-2:In DATA segment,declare array of numbers of type byte,count and result of type
word.
Step-3:In CODE segment,load the base value of the DATA segment into ’DS’ using
AX.Load
offset
Of NUMLIST into SI and CX with count.
Step-4:Move content of SI into AX and increment SI.Then move content of SI into
BX.Compare
With AX increment BI and decrement CX,repeat the step until CX becomes zero then
Load offset of result in SI.move content of AX into [SI].
Procedure:
1.Open the prompt by typing ‘run’ in the windows prompt.
2.Type edit filename.asm and then enter program into the editor.
3.Save the code and exit from window which returns to command prompt.
4.Compile and run the program using command:masm filename.asm.
5.Link the program using the command:link filename.obj.
6.Debug the program using the command:debug filename.exe.
7.Then the program is executed.
8.Press ‘U’ to visualize the hexcode, ‘G’ to see the contents of the register and ‘Q’ to quit.
Program:
ASSUME CS:CODE , DS:DATA
DATA SEGMENT
NUMLIST DB O2H,69H,98H,76H,78H
RESULT DB ?
DATA ENDS
CODE SEGMENT
START:
MOV AX,DATA
MOV DS,AX
MOV CL,O5H
XOR AX,AX
XOR BX,BX
MOV SI,OFFSET NUMLIST
MOV AL,[SI]
INC SI
L1:
MOV BL,[SI]
CMP AL,BL
JNC L1
MOV AL,BL
L2:
INC SI
DEC CL
JNZ L2
MOV SI,OFFSET RESULT
MOV [SI],AL
INT 03
CODE ENDS
END START
Result:

The assembly language program to find largest number in the series was executed
successfully.
INTERFACE STEPPER MOTOR TO 8086 PROCESSOR
A stepper motor is a brushless synchronous detective motor that converts digital pulses into
mechanical shaft rotation
Stepper motor operate differently from DC brush motors, which rotate when voltage is
applied to
their terminals stepper motors, in the other hand, effectively have multiple ‘boothed’
electromagnetic arranged around a central gear shaped piece of iron.The electromagnets are
engaged by an motor shaft turn,first one electromagnet is given power, which makes the gear
teeth magnetically attracted to the electromagnet;teeth.Then the gear’s teeth are thus aligned
to
the first electromagnet,they are slightly effected from the next electromagnet.So,when the
next
electromagnet is turned on and the first is named of the gear rotates slightly to align with the
next
one. And from there the process is operated.each of these slight rotation is called ‘step’,with
an
integer number of steps making a full rotation.In that way,the motor can be tuned by a precise
angle.
STEPPER MOTOR IN CONTINOUS CLOCKWISE
DIRECTION
Aim:
To write an assembly language program to rotate the stepper motor in continous
clockwise
direction.
Algorithm:
Step-1:To function port-A as output port in mode0.Load the control word with 80.
Step-2:Load the 80 into the control word register by using it address of 8255.
Step-3:Now load the port-A with the (11)H so that Wa is excited.
Step-4:Output the control word to the port-A address of 8255.
Step-5:Create the delay.
Step-6:Rotate the contents of AC to leftside by 1 so that Wb,Wc,Wd are excited.
Step-7:By using the unconditional jump the process is repeated for infinite times.
Program:

MOV AL,80
MOV DX,FFE6
OUT DX,AL
MOV AL,11
MOV DX,FFE0
L2: OUT DX,AL
MOV CX,03FF
L1: DEC CX
JNZ L1
ROL AL,1
JMP L2
INT 03
Result:

The assembly language program to rotate stepper motor continously in clockwise


direction was executed successfully.
STEPPER MOTOR IN CONTINOUS ANTICLOCKWISE
DIRECTION
Aim:
To write an assembly language program to rotate the stepper motor in anticlockwise
direction.
Algorithm:
Step-1:To function port-A as output port in mode0 load the control word as 80.
Step-2:Load the AL with 80 into control word register of 8255.
Step-3:Now load the AL with (88)H.so that Wd is excited.
Step-4:Output the control word to the port-A address of 8255.
Step-5:Create the delay.
Step-6:Rotate the contents of AL to right side by 1, so that Wc,Wb,Wa are excited.
Step-7:By using the unconditional jump the process is repeated for infinite times.
Program:
MOV AL,80
MOV DX,FFE6
OUT DX,AL
MOV AL,88
MOV DX,FFE0
L2:
OUT DX,AL
MOV CX,03FF
L1:
DEC CX
JNZ L1
ROR AL,1
JMP L2
INT 03
Result:

The assembly language program to rotate the stepper motor continously in anticlockwise
direction was executed successfully.
STEPPER MOTOR IN 180* CLOCKWISE DIRECTION
AND 180* ANTICLOCKWISE DIRECTION
Aim:
To write an assembly language program to rotate the stepper motor in 180* clockwise
and anticlockwise direction.
Algorithm:
Step-1:To function port-A as output port in mode 0. Load the controlt word with 80.
Step-2:Load 80 in AL and load the address of control word register in DY.
Step-3:Output the control word into control word register of 8255.
Step-4:Now load the AL with (11)H so that Wa is excited.
Step-5:Load BL with 0064(100).
Step-6:Output the control word into port-A of 8255.
Step-7:Create the delay.
Step-8:Rotate the contents of AL by 1 to left side. And output into port-A. So that
Wb,Wd,Wc
are excited.
Step-9:Decrement BL.
Step-10:Again load BL with (64)H.
Step-11:Output the control word into the port-A of 8255.
Step-12:Create the delay.
Step-13:Rotate the contents of AL to right side by 1. So that Wb,Wc,Wd are excited
continously.
Program:
MOV AL,80
MOV DX,FFE6
L1:
MOV BX,0064
OUT DX,AL
MOV AL,88
MOV DX,FFE0
L2:
OUT DI,AL
MOV CX,0500
L3:
DEC CX
JNZ L3
ROR AL,1
DEC CX
JNZ L2
MOV BX,0064
L4:
OUT DX,AL
MOV CX,0500
L5:
DEC CX
JNZ L5
ROL AL,1
DEC BX
JNZ L4
JMP L1
INT 03
Result:

The assembly language program to rotate the stepper motor continously in 180*
clockwise and 180* anticlockwise direction was executed successfully.
SQUARE WAVE GENERATOR

Aim:
To write an assembly language code to generate a square wave
continuously

Algorithm:
Step-1:Load 80 into AC and output it to the codeword register of
8255
Step-2:Load 00 to AC and load DX with FFEO and output control
word to 8255
Step-3:Create delay
Step-4:Increment the content of AC upto FF or not the contents of
AL using NOT operation
Step-5:Jump to step-2 and output to 8255
Step-6:The square wave is observed at the port -A with the help of
CRO connected to 8255

Procedure:
1. Connect all connections accordingly
2. Enter the program using keyboard,reset 8255.Enter A with
standing address of the program then enter the instruction
into 8255
3. For execution enter Shift+1 in 8255,type G write starting
address of the program
4. As a result square wave is generated at output
PROGRAM:
MOV AL,80
MOV DX,FFE6
OUT DX,AL
MOV AL, 00H
MOV DX, FFEO
L2:OUT DX,AL
MOV CX,03FFH
L1:DEC CX
JNZ L1
NOT AL
JMP L2
JNT 03
RESULT: The assembly language code to generate
square wave continuously is executed
successfully.

TRIANGULAR WAVE GENERATOR


---------------------------------------------

Aim:
To write an assembly language code to generate a triangular
wave continuously.
Algorithm:
Step-1:Load so into AL and output it to the port A of 8255
Step-2:Load AC with 00 and output it to the port A of 8255
Step-3:Increment the content and compare with FF and cut the
content to 8255
Step-4:If the contents equal to FF decrement the contents and
compare with 00 and out the content to 8255
Step-5:Jump to step-2 for continuous wave genertation

Procedure:
1. Connect all connections accordingly
2. Enter the program using keyboard,reset 8255.Enter A with
standing address of the program then enter the instruction
into 8255
3. For execution reset 8255,type G write starting address of the
program
4. As a result triangular wave is generated continuously
PROGRAM:
MOV AL,80
MOV DX,FFE6
OUT DX,AL
MOV AL, 00H
MOV DX, FFEO
L2:OUT DX,AL
MOV CX,03FFH
L1:DEC CX
JNZ L1
NOT AL
JMP L2
JNT 03
RESULT: The assembly language code to generate
square wave continuously is executed
successfully.
SAWTOOTH WAVE GENERATOR
AIM: To write an assembly language program to
generate sawtooth wave continuously
ALGORITHM :
Step1: Load AL content with 80 and output to the
CWR of 8255
Step2: Load AL with 00 and output it to the port A
of 8255
Step3: Increment contents of AC by 1 and
compare with FF and out to the port A of 8255
Step4: Load AL with 00 if AC matches FF then go
to step3
Step5: The sawtooth wave is generated
continuously
PROCEDURE:
1.Connect all connections accordingly
connect all connections accordingly
2. Enter the program using key board, reset the
8255 .enter A with starting address of the
program, then enter the instruction into 8255
3. For execution reset the 8255, type G with
starting address of program
4. As a result triangular wave is generated
continuously
PROGRAM:
MOV AL,80
MOV DX,FEE6
L2: MOV AL,00
MOV DX,FFE0
L1: OUT DX,AL
INC AL
CMP AL,FF
JNE L1
JMP L2
INT 03
RESULT: The program to generate sawtooth wave
continuously executed successfully.
SQUARE WAVE AT BOTH PORTS
AIM: To write an assembly language program to
generate square wave at both ports .
ALGORITHM:
Step1: Load AL content with 80 and output it to
the CWR of 8255
Step2: Load AL with contents of 00 and output it
to the port A and port B simultaneously
Step3: Create a delay
Step4:Compliment the contents of AL and output
to the port A and port B
Step5: Repeat the step2 for continuous
generation of port A , port B
PROCEDURE:
1.Connect all connections accordingly
connect all connections accordingly
2. Enter the program using key board, reset the
8255 .enter A with starting address of the
program, then enter the instruction into 8255
3. For execution reset the 8255, type G with
starting address of program
4. As a result triangular wave is generated
continuously
PROGRAM:
MOV AL,80
MOV DX,FEE6
OUT DX,AL
L2: MOV DX, FFE0
OUT DX, AL
MOV DX,FFE2
OUT DX,AL
MOV CX, 03FFH
L1:DEC CX
JNZ L1
NOT AL
JMP L2
INT 03
RESULT: The program to generate the square
wave at two ports executed successfully.
SQUARE AND TRIANGULAR WAVE AT DIFFERENT
PORTS
AIM: To write an assembly language code to
generate a square and triangular wave at port A
and B
ALGORITHM:
Step1: Load AL with 80 and output it to the
control word register of 8255
Step2: Load AL with 00 and output it to the port A
of 8255
Step3: Load DX with port B address and output AL
to the port B of 8255
Step4: Increment AL by comparing with FFCH and
output H to port B of 8255
Step5: When contents of AL is equal to FF output
it to port A of 8255
Step6: Decrement AL by using compare with 00(H)
and output it to the port B of 8255
Step7: Repeat from step2
Step8: Square wave at port A and triangular wave
at port B is generated
PROCEDURE:
1.Connect all connections accordingly
connect all connections accordingly
2. Enter the program using key board, reset the
8255 .enter A with starting address of the
program, then enter the instruction into 8255
3. For execution reset the 8255, type G with
starting address of program
4. As a result triangular wave is generated
continuously
PROGRAM:
MOV AL,80
MOV DX, FFE6
OUT DX, AL
MOV AL,00
L3:MOV DX,FFEO
OUT DX,AL
MOV DX,FFE2
L1:OUT DX,AL
INC AL
CMP AL,FF
JNE L1
MOV DX,OFFEO
OUT DX,AL
MOV DX,FFE2
L2:OUT DX,AL
DEC AL
CMP AL,00
JNE L2
JMP L3
INT 03
RESULT: The assembly language to generate
square and triangular wave to port A and port B
executed successfully .
TRANSFER BLOCK USING MOVSB
AIM: To write an assembly language code to
transfer block using movsb instruction
ALGORITHM:
Step1: Assume code segment as cs, data segment
as ds , extra segment as es
Step2: In data segment declare series of number
of type data
Step3: In extra segment declare series of numbers
of type data
Step4: Move base value of data segment into ds
using AX and base address of extra segment to es
using AX, OFFSET of NUMLIST into si and OFFSET
of dest into di
Step5: Load CL with 05(H) ,enter movsb and
decrement CL until CL equal to 00(H) repeat the
instruction
PROCEDURE:
1.Open command prompt by trying “run” in
windows prompt
2.Type edit filename.asm to enter the code
3.Save the code and exit
4.Compile and run the program using masm
filename.asm
5.Link using link filename.obj
6.Debug using debug filename.exe
7.Then program is executed
8. Press U to view hex code ,G to see reg.
contents, q to quit
PROGRAM:
ASSUME CS:CODE,DS:DATA, ES:EXTRA
DATA SEGMENT
SRC DB 23,45,69,83
COUNT EQU 05
DATA ENDS;
EXTRA SEGMENT
DEST DB ?
EXTRA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AX,EXTRA
MOV ES,AX
CCD
MOV CL,COUNT
MOV SI,OFFSET SRC
MOV DI,OFFSET DEST
L1:MOV SB
DEC CL
JNZ L1
INT 03
CODE ENDS
END START
OUTPUT:
AX:OBCE BX:0000 CX:0000 DX:0000 SP:0000
SI:0005 DI:0005 DS:OBCE ES:OBCC SS:OBCE
CS:OBDO IP:0018
-d DS:0000 0005 23 45 69 73 83
-d ES:0000 0005 23 45 69 73 83
RESULT: The assembly language to mov block of
string using movsb executed successfully.

ANALOG TO DIGITAL
AIM: To write an assembly language program to
convert analog to digital
ALGORITHM:
Step1: Move 8B to accumulator and output to
CWR of 8255
Step2: Move 00 to accumulator and output it to
the port A of 8255
Step3: Move 20 to accumulator for start of
conversion and output it to the port A of 8255
Step4:Perform exchange operation and move 00
to accumulator and output it to port A
Step5: Check the end of conversion by reading
port C status. Port C status is read into AL, if it is
equal conversion is completed otherwise it again
reads the status
Step6: Move 40 into accumulator for output
buffer enable and output it to port A of 8255
Step7: Read port B status for reading the digital
output data and output it to the accumulator
PROCEDURE:
1.Make all the required connections
2.Enter the code into ADC kit using key board
3.For execution give G 8000 and vary analog input
from +0v to +5v
4.The result i.e digital output data is stored in
accumulator
PROGRAM:
MOV AL,8B
MOV DX,OFFE6
OUT DX,AL
MOV AL,00
MOV DX,OFFEO
OUT DX,AL
MOV AL,20
OUT DX,AL
XCHG AX,DX
MOV AL,00
OUT DX,AL
MOV DX,FFEF
L1:IN AL,DX
AND AL,01
JNE L1
L2:IN AL,DX
AND AL,01
JNE L2
MOV AL,40
MOV DX,OFFEO
OUT DX,AL
MOV DX,FFE2
IN AL,DX
INT 03
OUTPUT:
Voltage digital
0v AX:0000
5v AX:00FF
RESULT: The assembly language code to convert
analog to digital executed successfully.

SEVEN SEGMENT DISPLAY


AIM: To write an assembly language code to
implement seven segment display
ALGORITHM:
Step1: Initialize the data segment and 8255 port
as output mode by loading 80
Step2:Initialize cx with the no. of digits to be
displayed ,SI with starting address of the input
and BL with no. of segments
Step3:Load AL the content of SI and output one
bit through the port by rotating the content of the
AL towards left
Step4:Thus send all the 8 bits through which one
digit is displayed
Step5:Decrement CH and follow the some
instructions till CH decremented to zero, then
create a delay m order to display another set of
two digits by calling delay functions
PROCEDURE:
1.Make sure all the connections are fixed properly
2.Then enter the starting address of the program
following which enter the instructions
3.In the end, press then enter button and shift+s
later press G for the executed
4.The digits appear simultaneously as a result
PROGRAM:
MOV DX,OFFE6
MOV AL,80
OUT DX,AL
LOOP4:MOV SI,400
MOV CL,05
LOOP3:MOV CH,04
LOOP2:MOV BL,[08]
MOV AL,[SI]
INC SI
LOOP1:ROL AL,I
MOV DX,FFE2
OUT DX,AL
MOV AH,AL
MOV AL,01
MOV DX,OFFE4
OUT DX,AL
DEC AL
OUT DX,AL
MOV AL,AH
DEC BL
JNE LOOP1
DEC CH
JNE LOOP2
CALL DELAY
DEC CL
JNZ LOOP3
JMP LOOP4
DELAY:PUSH CX
MOV CX,0000
L1:LOOP L1
L2:LOOP L2
POP CX
RET
OUTPUT:
2100-80
2101-A4
2102-CO
2103-CO
RESULT: The assembly language code to display
seven digit segment executed successfully.

SMALLEST NUMBER IN SERIES


AIM: To write an assembly language code to find
smallest number in a series.
ALGORITHM:
Step1: Assume Code Segment as CS and Data
segment as DS.
Step2: In Data segment declares series of
numbers and result as type DataByte.
Step3: Move Base value of Data segment into DS
using AX and offset value of NUMLIST into
SI,move CL with 0502.
Step4: Move SI content into AL & increment
SI,Move SI content into BL, decrement CL&
compare BL,AC. If carry occurs increment SI &
repeat else move AC content into result.

PROCEDURE:
1. Open command prompt by typing “run” in
window prompt.
2. Type edit filename.asm to enter code.
3. Save the code and then exit.
4. Compile & run the program using MASM
filename.asm
5. Link using link filename.obj
6. Debug using Debug filename.exe
7. Then program is executed.
8. Press U to view hexcode. G to see register
contents and q to quit.

PROGRAM:
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
NUMLIST DB 02H,69H,98H,76H,78H
RESULT DB &dup(0)
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AX,AX
MOV BX,BX
MOV SI,OFFSET NUMLIST
MOV AC,[SI]
INC SI
L2: MOV BL,[SI]
CMP AC,BL
JC L1
MOV AC,BL
L1: INC SI
DEC CL
JNZ L2
MOV SI,OFFSET RESULT
MOV [SI],AC
INT 03
CODE ENDS
END START

OUTPUT:
AX:0002 BX:0000 CX:0000 DX:0000 SP:0000
SI:0000 DI:0000 DS:OBDB ES:OBAB SS:OBBB
CS:OBBC IP:0023
-d -0000 0006 :02 69 98 76 78 02 00

RESULT:
The assembly language code to find smallest
number in a series executed successfully.
SORT NUMBERS IN ASCENDING ORDER
AIM: To write an assembly language code to sort
numbers in ascending order.

ALGORITHM:
Step1: Assume Code Segment as CS and Data
segment as DS.
Step2: In Data segment declares array of databyte
and segment .
Step3: In code segment load base value of Data
segment into DS using AX.
Step4: Move SI content into AX & next memory
content into BL,compare BL,AC.
Step5: If carry occurs increment 57,decrement CL
until carry becomes zero otherwise decrement CL
and CL becomes zero.

PROCEDURE:
1. Open command prompt by typing “run” in
window prompt.
2. Type edit filename.asm to enter code.
3. Save the code and then exit.
4. Compile & run the program using MASM
filename.asm
5. Link using link filename.obj
6. Debug using Debug filename.exe
7. Then program is executed.
8. Press U to view hexcode. G to see register
contents and q to quit.

PROGRAM:
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
STRINGS DB 99H,32H,58H,55H
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV CH,04H
UP1:MOV CL,04H
LEA SI,STRING1
UP2:MOV AC,[SI]
MOV BL,[SI+1]
CMP AC,BL
JC DOWN
MOV DL,[SI+1]
XCHG[SI],DL
MOV [SI+1],DL
DOWN:INC SI
DEC CL
JNZ UP1
DEC CH
JNZ UP2
INT 03
CODE ENDS
END START

OUTPUT:
AX:0B58 BX:0000 CX:0000 DX:0000 SP:0000
BP:0000 SI:000A DS:OBB2 ES:OBC2 SS:OBD2
CS:OBB3 IP:0013
-d DS: 0000 0004
0000 :32 55 58 99
RESULT:
The assembly language code to sort numbers in
ascending order executed successfully.
SORT NUMBERS IN DESCENDING ORDER
AIM: To write an assembly language code to sort
numbers in descending order.

ALGORITHM:
Step1: Assume Code Segment as CS and Data
segment as DS.
Step2: In Data segment declares array of databyte
and segment .
Step3: In code segment load base value of Data
segment into DS using AX,offset of NUMLIST into
SI and count into CX
Step4: Move SI content into AX & next memory
content into AC, compare BL,AC.
Step5: If carry occurs increment SI, decrement CL
until carry becomes zero otherwise decrement CL
till AC contents become zero.
PROCEDURE:
1. Open command prompt by typing “run” in
window prompt.
2. Type edit filename.asm to enter code.
3. Save the code and then exit.
4. Compile & run the program using MASM
filename.asm
5. Link using link filename.obj
6. Debug using Debug filename.exe
7. Then program is executed.
8. Press U to view hexcode. G to see register
contents and q to quit.

PROGRAM:
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
STRINGS DB 12H,48H,93H,04H
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV CH,04H
UP1:MOV CL,04H
LEA SI,STRING1
UP2:MOV AC,[SI]
MOV BL,[SI+1]
CMP AC,BL
JNC DOWN
MOV DL,[SI+1]
XCHG[SI],AL
MOV [SI+1],DL
DOWN:INC SI
DEC CL
JNZ UP1
DEC CH
JNZ UP2
INT 03
CODE ENDS
END START
OUTPUT:
AX:0B9F BX:0000 CX:0000 DX:0000 SP:0000
BP:0000 SI:0004 DS:OBAB ES:OBBC SS:OBAB
CS:OBBB IP:0022
-d DS: 0000 0004
0000 :93 48 12 04
RESULT:
The assembly language code to sort numbers in
descending order executed successfully.

S-ar putea să vă placă și