0% found this document useful (0 votes)
10 views13 pages

12th Computer Sci Practical Paper-2

The document outlines a series of assembly language experiments aimed at performing various operations such as addition, subtraction, comparison, conversion to ASCII, BCD addition, block copying, data reversal, counting occurrences, exchanging data blocks, and division of hexadecimal numbers. Each experiment includes a detailed assembly language program with memory locations, mnemonics, and comments explaining the purpose of each instruction. Results of the operations are also provided, indicating the expected outcomes after the execution of the programs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views13 pages

12th Computer Sci Practical Paper-2

The document outlines a series of assembly language experiments aimed at performing various operations such as addition, subtraction, comparison, conversion to ASCII, BCD addition, block copying, data reversal, counting occurrences, exchanging data blocks, and division of hexadecimal numbers. Each experiment includes a detailed assembly language program with memory locations, mnemonics, and comments explaining the purpose of each instruction. Results of the operations are also provided, indicating the expected outcomes after the execution of the programs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Experiment No.

1
Aim :- Write assembly language program to add two 8-bit (hexadecimal) Numbers. The
numbers are storage at memory location 1000H and 1001H. Store the result at memory
location 1002H.

Example :- i) Numbers are 09H and 01H.


ii) Numbers are 11H and 22H.

Given data :- i) 1000H – 09H / 11H


ii) 1001H – 01H / 22H
iii) 1002H – Result

Assembly Language Program :-

Memory Label Mnemonics Hex Comments


location Opcode Operand Code
1003 LXIH,1000H 21 Get Address of 1st No. in HL-pair
1004 00
1005 10
1006 MOVA,M 7E Get 1st No.in accumulator
1007 INXH 23 Increment HL pair by 1
1008 ADDM 86 Add 1st and 2nd No.
1009 STA1002H 32 Store sum in 1002H
100A 02
100B 10
100C HLT 76 Stop the Program

Result :- After execution of program, Addition of two numbers, result is formed to be


i) 0AH in memory location in 1002H
ii) 33H in memory location in 1002H

- E N D-
Experiment No.2
Aim :- Write assembly language program to Subtract two 8-bit (hexadecimal) Numbers.
The numbers are Store atmemory location 1000H and 1001H. Store the result at
memory location 1002H.

Example :- i) Numbers are 09H and 01H.


ii) Numbers are 22H and 11H.

Given data :- i) 1000H – 09H


ii) 1001H – 01H
iii) 1002H – Result

Assembly Language Program :-


Memory Label Mnemonics Hex Comments
location Opcode Operand Code
1003 LXIH,1000H 21 Get Address of 1st No. in HL-pair
1004 00
1005 10
1006 MOVA,M 7E Get 1st No.in accumulator
1007 INXH 23 Increment HL pair by 1
1008 SUB M 96 Subtract 1st No. from 2nd No.
1009 STA1002H 32 Store Result in 1002H
100A 02
100B 10
100C HLT 76 Stop the program

Result :- After execution of program, subtraction of two numbers, result is formed to be


i) 08H in memory location in 1002H
ii) 11H in memory location in 1002H
Experiment No.3
Aim :- Write assembly language program to find smaller/greater of two Hexadecimal
numbers store at the memory location 1000H and 1001H. Store the result at the
memory location 1002H.

Example :- i) Numbers are 84H and 99H.

Given data :- i) 1000H – 84H


ii) 1001H – 09H
iii) 1002H – Result

Assembly Language Program :-

Memory Label Mnemonics Hex Comments


location Opcode Operand Code
1003 LXIH,1000H 21 Get address of 1st No.in HL-
pair
1004 00
1005 10
1006 MOVA,M 7E Get 1st No.in accumulator
1007 INX H 23 Increment HL pair by 1
1008 CMP M BE Add 1st and 2nd No.
1009 JNC AHEAD D2 Store sum in 1002H
100A 0D
100B 10
100C MOV A,M 7E End program
100D AHEAD: STA 1002H 32
100E 02
100F 10
1010 HLT 76

Result :- After execution of program, greatest number 84H was found at memory location
1002 H

Note:-JCN instruction when replaced with JC instruction gives smallest of two


numbers.

- E N D-
Experiment No.4
Aim :- Write an assembly language program to convert of memory location C000 H to
an ASCII character memory location C000 contains a single hexadecimal digit. Store
result at location C001 H.

Input :- (C000) = 0C

Assembly Language Program :-

Memory Label Mnemonics Hex Comments


location Opcode Operand Code
1000 LDA C000 3A Get DATA
1001 00
1002 C0
1003 CPI 10 FE is DATA 10 OR MORE
1004 0A
1005 JC ASCZ DA Jump if carry
1006 0A
1007 10
1008 ADI ‘A’-‘9’-‘1’ C6 Yes add offset
1009 07
100A ASCZ: ADI ‘O’ C6 Add offset for ASCII
100B 30
100C STA C001 32 Store ASCII result
100D 01
100E C0
100F HLT 76

Result :-If [C000] = 0C then Result = [C001] = 43

-E N D-
Experiment No.5
Aim :- Write ALP to add all the BCD numbers in a block from 1000 H to 8008 H . Store
Sum at memory location 100A H. [Assume sum is 8 bit]

Input : -

1000 H = 01 1003 H = 01 1006 H= 01


1001 H = 01 1004 H = 01 1007 H = 01
1002 H = 01 1005 H = 01 1008 H = 01

100A H= RESULT

Assembly Language Program :-


Memory Label Mnemonics Hex Comments
location Opcode Operand Code
100B LXI H,1000H 21 ; HL pair at starting address
100C 00
100D 10
100E MVI C,09H 0E ; Register C as counter
100F 09
1010 XRA A AF ; Clear Accumulator
1011 UP: ADD M 86 ;[A] + [H][L]  [A]
1012 DAA 27 ; Decimal Addition
1013 INX H 23
1014 DCR C 0D ;Decrement Loop counter by
1
1015 JNZ UP C2 ; Go up until C=0
1016 11
1017 10
1018 STA 100AH 32 ;Store BCD sum at memory
100A H
1019 0A
101A 10
101B HLT 76 ; Halt

Result : - BCD addition was found at location 100A H and was = 09


Experiment No.6
Aim : -Write an ALP to copy block of four consecutive bytes storage from 1000 H to
1003 H. Transfer the entire block to new location from C004 H. .

Input :-1000 = 11H C004 H = result


1001 = 22H C005 H = result
1002 = 33H C006 H = result
1003 = 44H C007 H = result

Assembly Language Program:-


Memory Label Mnemonics Hex Comments
location Opcode Operand Code
1009 LXI H,1000H 21 ;Load HL Register Pair
100A 00
100B 10
100C LXI B,C004H 01 ;Load BC Register Pair
100D 04
100E C0
100F MVI C,04H 0E ; Set Counter as 04
1010 04
1011 BACK: MOV A,M ; Get first number in
7E
Accumulator
1012 STAX B ; Store the content of A to
02
Memory
1013 INX H 23 ; Increment the register pair
1014 INX B 03 ; Increment the register pair
1015 DCR C 0D ; Decrement Counter by 1
1016 JNZ BACK C2 ; if Z=0 the perform loop
1017 10
1018 10
HLT 76 ;Stop the Program
Result :-
After execution of program the data in memory block 1000H – 1003 H was copied from 1004
H to 1007 H as follows
1000 = 11H 1004 H = 11 H
1001 = 22H 1005 H = 22 H
1002 = 33H 1006 H = 33 H
1003 = 44H 1007 H = 44 H

-E N D -
Experiment No.7

Aim :- A block of data is stored in memory location from 1000H to 1004H. Write an
assembly language Program to shift the data contain of block in reverse order storing
from memory location C005H.
Input :-
1000H = 01H 1003H = 04H C005 = 05 C008= 02
1001H = 02H 1004H = 05H C006 = 04 C009= 01
1002H = 03H C007 = 03

Assembly Language Program:-


Memory Label Mnemonics Hex Comments
location Opcode Operand Code
100AH LXI H, 100AH ;Set up H – L pair as pointer
21
to source
100BH 04
100CH 10
100DH LXI D, C005H ;Set up DE as a pointer to
11
destination
100EH 05
100FH C0
1010H MVI C, 05H 0E ;Set up counter C = 05
1011H 05
1012H TOP: MOV A, M 7E ;Get data from memory
1013H STAX D 12 ;Store it at desetination
1014H DCX H 2B ;Decrement source Pointer
1015H INX D 13 ;Increment D
1016H DCR C 0D ;Decrement count
1017H JNZ TOP C2 ;Jump is count is not zero
1018H 12
1019H 10
101AH HLT 76 ;Stop

Result :- After execution of program number are found 05, 04,03,02,01 in successive
memory location C005H

- E N D -
Experiment No. 8

Aim :-Write an ALP to count total number occurrences of data bytes 9CH in a memory
block of length 10 bytes starting from 1000H. Store the count in register E.
Input :-
1000H = 11H 1003H = 44H 1006H = 9CH 1009H = 77H
1001H = 9CH 1004H = 9CH1007H = 66H
1002H = 33H 1005H = 55H 1008H = 9CH

Assembly Language Program:-


Memory Label Mnemonics Hex Comments
location Opcode Operand Code
100AH LXI H, 1000H ;Set up H – L pair as pointer
21
to source
100BH 00
100CH 10
100DH MVI C,0AH 0E ;Set counter as 10 number
100EH 01
100FH MVI E,00H 1E ; Initialize E reg. as 00H
1010H 00
1011H MVI A,9CH 3E ; Initialize A reg. as 9CH
1012H 9CH
1013H TOP: CMP M ; Compare the content of
BE
memory with content of A.
1014H JNZ DOWN ; if Z= 1 then increment the
C2
content of reg. E
1015H 18
1016H 10
1017H INR E IC
1018H DOWN: INX H 23 ; Increment of HL reg. pair
1019H DCR C 0D ;Decrement the counter
101AH JNZ TOP C2 ;If Z= 0 perform loop
101BH 13
101CH 10
101DH HLT 76 ;Stop the program

Result :- After execution of program count in register E was 04H

- E N D -
Experiment No. 9
Aim :-A block of data is stored in memory location from 1000H to 1002H. Another
block is stored from 1003H to 1005H. Write an ALP to exchange these two block of
data with each other.
Input :-
1000H = 11H 1003H = 44H
1001H = 9CH 1004H = 9CH
1002H = 33H 1005H = 55H

Assembly Language Program:-


Memory Label Mnemonics Hex Comments
location Opcode Operand Code
100AH LXI H, 1000H ;Set up HL pair as pointer to
21
source
100BH 00
100CH 10
100DH LXI D, 1003H ;Set up DE pair as pointer to
11
destination
100EH 03
100FH 10
1010H MVI C,03H 0E ; Set counter
1011H 03
1012H TOP: MOV A,M 7E ; Transfer no. in Acc.
1013H MOV B,A 47 ; Copy Acc into B reg.
1014H LDAX D ; Load Acc from memory
1A
(DE)
1015H MOV M,A 77 ; Copy Acc to memory (HL)
1016H MOV A,B 78 ;Copy Reg. B to reg. A
1017H STAX D ; Store the content of Acc.
12
Into memory
1018H INX H 24 ; Increment the HL
1019H INX D 14 ; Increment the DE
101AH DCR C 0D ; Decrement the C reg.
101BH JNZ TOP C2 ; If Z= 0 perform loop
101CH 12
101DH 10
101EH HLT 76 ; Stop the Program
Result :- After execution of program the content of two block are exchange.
- E N D -
Experiment No. 10
Aim :-Write an ALP the divide one byte Hexadecimal number, when dividend is stored
in memory location 1000H and divisor is stored in memory location 1001H. Store the
quotient and reminder in memory location 1002H and 1003H
Input :-
1000H = 24H Dividend
1001H = 02H Divisor

Assembly Language Program:-


Memory Label Mnemonics Hex Comments
location Opcode Operand Code
100AH LXI H, 1000H ;Set up HL pair as pointer to
21
source
100BH 00
100CH 10
100DH MVI C,00H 0E ; Set C reg. as 00
100EH 00
100FH MOV A,M 7E ; Get dividend in Acc.
1010H INX H 23 ; Increment HL Reg.
1011H UP: CMP M ; Compare the Acc. With
BE
Memory
1012H JC DOWN DA ; If C= 0 the down
1013H 1A
1014H 10
1015H SUB M 12 ; Perform subtraction
1016H INR C 0C ; Increment C Reg.
1017H JMP UP C3 ; jump to the top
1018H 11
1019H 10
101AH DOWN: INX H 23 ; Increment HL Reg.
101BH MOV M,C ; Copy content of C to
71
Memory
101CH INX H 23 ; Increment HL Reg.
101DH MOV M,A ; Copy content of A to
77
Memory
101EH HLT 76 ; Stop the Program
Result :- After execution of program the content of 1002H = 12H and 1003H = 00H.
- E N D -
Experiment No. 11
Aim :-Write an ALP that interchange digits of number stored at location 1000H and
stores the result at 1001H. Also perform the original number and the interchanged
number and store the result at location 1002H
Input :-
1000H = 23H 1002H – 55H
1001H = 32H

Assembly Language Program:-


Memory Label Mnemonics Hex Comments
location Opcode Operand Code
100AH LXI H, 1000H ;Set up HL pair as pointer to
21
source
100BH 00
100CH 10
100DH MOV A,M ; Copy the content of
7E
memory to Acc.
100EH RRC 0F ;Rotate the content
100FH RRC 0F ;of the accumulator
1010H RRC 0F ;4 times
1011H RRC 0F ;Right side
1012H INX H 23 ; Increment the HL
1013H MOV M,A ; Store interchange in
77
memory
1014H DCX H 2B ; Decrement HL
1015H ADD M ; Perform the original
86 number with interchanged
number
1016H STA 1002H 32 ; Store the result at memory
1017H 02
1018H 10
1019H HLT 76 ; Stop the Program
101AH
Result :- After execution of program the content of 1002H = 55H.
- E N D -
Experiment No. 12
Aim :-Write an ALP to count the number of odd data bytes occurring a block of data
stored from location 1001h to 1004H. Store the result at location 1005H
Input :-
1000H = 01H 1002H =03H 1004H = 05
1001H = 04H 1003H = 06H 1005H = result

Assembly Language Program:-


Memory Label Mnemonics Hex Comments
location Opcode Operand Code
100AH LXI H, 1000H ;Set up HL pair as pointer to
21
source
100BH 00
100CH 10
100DH MVI C,05H 0E ; Set Counter as 05
100EH 05
100FH MVI B,00H 06 ; Initialize reg B = 0
1010H 00
1011H TOP: MOV A,M 7E ; Get first number in Acc
1012H RRC ; Rotate the content of Acc
0F
right
1013H JNC DOWN D2 ; if C= 0 then down
1014H 17
1015H 10
1016H INR B ; if C=1 then increment the
04
content of reg B
1017H DOWN: INX H 23 ; Increment the HL reg.pairs
1018H DCR C 0D ; Decrement the reg. C
1019H JNZ TOP C2 ; If Z= 0 then goto TOP
101AH 11
101BH 10
101CH MOV A,B 78 ; Store the result at
101DH STA 1005H 32 ; the memory location
101EH 05 ; 1005 H
101FH 10
1020H HLT 76 ; Stop the Program
Result :- After execution of program the content of 1005H = 03H.
- E N D -
Experiment No. 13
Aim :-Write an ALP to count the number of ONE’S in an 8bit hexadecimal number
stored at 1000H. Store the result at location 1001H
Input :-
1000H = 98H => 10011000
1001H = 03H

Assembly Language Program:-


Memory Label Mnemonics Hex Comments
location Opcode Operand Code
100AH LXI H, 1000H ;Set up HL pair as pointer to
21
source
100BH 00
100CH 10
100DH MVI C,08H 0E ; Set Counter as 05
100EH 08
100FH MVI B,00H 06 ; Initialize reg B = 0
1010H 00
1011H MOV A,M 7E ; Get first number in Acc
1012H TOP: RRC ; Rotate the content of Acc
0F
right
1013H JNC DOWN D2 ; if C= 0 then down
1014H 17
1015H 10
1016H INR B ; if C=1 then increment the
04
content of reg B
1017H DOWN: INX H 23 ; Increment the HL reg.pairs
1018H DCR C 0D ; Decrement the reg. C
1019H JNZ TOP C2 ; If Z= 0 then goto TOP
101AH 12
101BH 10
101CH MOV A,B 78 ; Store the result at
101DH STA 1001H 32 ; the memory location
101EH 01 ; 1005 H
101FH 10
1020H HLT 76 ; Stop the Program
Result :- After execution of program the content of 1001H = 03H.
- E N D -

You might also like