CS-2 Pre Board Practical Outputs
CS-2 Pre Board Practical Outputs
Slip – 1
A Block of data is stored in memory location starting from C040 H. Length of the block is stored in register
D. Write an Assembly language program to transfer the entire block of data to another memory location
starting from memory location C050 H.
C005 H C0
C006 H 16 MVI D, 05 H ;Set the counter for 05 numbers in
register D
C007 H 05
Before Execution:
C040 H = 01 H
C041 H = 02 H
C042 H = 03 H
C043 H = 04 H
C044 H = 05 H
After Execution:
A = 05 H
D = 00 H H= C0 H B= C0
F = 54 H L= 45 H C=54
C040 H = 01 H C050 H = 01 H
C041H = 02 H C051 H = 02 H
C042 H = 03 H C052 H = 03 H
C043 H = 04 H C053 H = 04 H
C044 H = 05 H C054 H = 05 H
D7 D6 D5 D4 D3 D2 D1 D0
F= S Z X AC X P X CY
0 1 0 1 0 1 0 0
Bifocal Computer Science (Paper–II)
Slip – 2
A Block of data is stored in memory location starting from C040 H. Length of the block is stored in register
D. Write an Assembly language program to transfer the entire block of data to another memory location
starting from memory location C050 H in reverse order.
C005 H C0
C006 H 16 MVI D, 05 H ;Set the counter for 05 numbers in
register D
C007 H 05
C00F H C0
Before Execution:
C040 H = 01 H
C041 H = 02 H
C042 H = 03 H
C043 H = 04 H
C044 H = 05 H
After Execution:
A = 05 H H= C0 B= C0
D = 00 H L=45 C=54
F = 54 H
C040 H = 01 H C050 H = 05 H
C041 H = 02 H C051 H = 04 H
C042 H = 03 H C052 H = 03 H
C043 H = 04 H C053 H = 02 H
C044 H = 05 H C054 H = 01 h
D7 D6 D5 D4 D3 D2 D1 D0
F= S Z X AC X P X C
0 1 0 1 0 1 0 0
Bifocal Computer Science (Paper–II)
Slip – 3
A block of data is stored in memory location starting from memory location C040 H. Another block of data
is stored in memory location starting from memory location C050 H. Length of the blocks is stored in register
D. Write a program to exchange / swap the data contents of both these blocks
C002 H C0
C005 H C0
C012 H C0
Before Execution:
After Execution
A = 05 H H= C0 B= C0
D = 00 H L= 45 C= 54
F = 54 H
C040H = 06 H C050H= 01 H
C041H = 07 H C051H= 02 H
C042H = 08 H C052H= 03 H
C043H = 09 H C053H= 04 H
C044H = 0A H C054H = 05 H
D7 D6 D5 D4 D3 D2 D1 D0
F= S Z X AC X P X C
0 1 0 1 0 1 0 0
Bifocal Computer Science (Paper–II)
Slip – 4
A block of data is stored in memory location starting from C040 H. Length of the block is stored in register
B. Write an Assembly language program to add the data content of the memory location and store 16-bit
result at the end of the block.
C00A H 0D
C00B H C0
C00C H 0C INR C ;Increment reg. C for carry
C00D H 23 :Down INX H ; Increment the content of HL register
pair by 1 to get next location.
C00E H 05 DCR B ;Decrement the counter by 1
C00F H C2 JNZ UP : (C008) ;If counter 0 (reg. B 0 )then jump
C010 H 08 to memory location C008H.
C011 H C0
C012 H 77 MOV M ,A ; Copy the data content of accumulator
to Memory Location pointed by HL
register pair.
C013 H 23 INX H ;Increment the memory location HL
register pair by 1
C014 H 71 MOV M,C ; Copy the data content(carry) of reg. C
to Memory pointed by HL register pair.
C015 H CF RST 1 ;Stop the execution
OUTPUT:
Before Execution:
C040 H = 01H
C041 H = 02H
C042 H = 03 H
C043 H = 04 H
C044 H = 05 H
C045 H = ?
C046 H = ?
After Execution:
A = 0F H H= C0 F= 54 H
B= 00 H L= 47
C= 00 H
C040 H = 01 H
C041 H = 02 H
C042 H = 03 H
C043 H = 04 H
C044 H = 05 H
C045 H = 0F H
C046 H = 00 H
D7 D6 D5 D4 D3 D2 D1 D0
F= S Z X AC X P X C
0 1 0 1 0 1 0 0
Bifocal Computer Science (Paper–II)
Slip – 5
A block of data is stored in memory location starting from C041 H. Length of the block is stored in memory
location C040 H. Write an Assembly language program to add the data content of the memory location and
store the BCD result at the end of the block.
C00B H 0E
C00C H C0
C00D H 0C INR C ;Increment reg. C for carry
C00E H 23 :Down INX H ;Increment the memory location of HL
register pair by 1
C00F H 05 DCR B ;Decrement the counter by 1
C010 H C2 JNZ UP : (C008) ;If counter 0 (reg. B 0 )then jump to
C011 H 08 memory location C008 H.
C012 H C0
C013 H 77 MOV M ,A ;Copy the data content of accumulator
to Memory location pointed by HL
register pair.
C014 H 23 INX H ;Increment the memory location HL
register pair by 1
C015 H 71 MOV M,C ;Copy the data content of reg. C
to Memory location pointed by HL
register pair.
C016 H CF RST 1 ;Stop the execution
OUTPUT:
Before Execution:
C040 H = 05H
C041 H = 01 H
C042 H = 02H
C043 H = 03 H
C044 H = 04H
C045 H = 05H
C046 H = ?
C047 H = ?
After Execution:
A = 15 H= C0 F= 54 H
B= 00 H L= 47
C= 00 H
C040 H = 05H
C041 H = 01 H
C042 H = 02H
C043 H = 03 H
C044 H = 04H
C045 H = 05H
C046 H = 15
C047 H = 00 H
D7 D6 D5 D4 D3 D2 D1 D0
F= S Z X AC X P X C
0 1 0 1 0 1 0 0
Bifocal Computer Science (Paper–II)
Slip – 6
Two numbers are stored in consecutive memory location starting from C040 H. Write an Assembly language
program to subtract the numbers and store the absolute difference result in the next memory location.
C040 H = 08 H
C041 H = 02 H
C042 H = ?
After Execution:
A = 05 H H= C0
F = 14 H L= 42
C040 H = 08 H
C041 H = 02 H
C042 H = 00 H
D7 D6 D5 D4 D3 D2 D1 D0
F= S Z X AC X P X C
0 0 0 1 0 1 0 0
Case II:
Before Execution:
C040 H = 02 H
C041 H= 08 H
C042 H = ?
After Execution:
A = 06 H H= C0
F = 06 H L= 42
C040 H = 02 H
C041 H= 08 H
C042 H = 06 H
D7 D6 D5 D4 D3 D2 D1 D0
F= S Z X AC X P X C
0 0 0 0 0 1 0 1
1 0
Bifocal Computer Science (Paper–II)
Slip – 7
A block of data is stored in memory location starting from C040 H. Length of the block is stored in register B.
Write an Assembly language program to find the largest number from the given block of data and store it at
the end of the block.
C010 H C0
Before Execution:
C040 H = 06 H
C041 H = 07 H
C042 H = 0A H
C043 H = 08 H
C044 H = 01 H
C045 H = ?
After Execution:
A= 0A H H= C0
B= 00 H L= 45
F = 54 H
C040 H = 06 H
C041 H = 07 H
C042 H = 0A H
C043 H = 08 H
C044 H = 01 H
C045 H = 0A H
D7 D6 D5 D4 D3 D2 D1 D0
F= S Z X AC X P X C
0 1 0 1 0 1 0 0
Bifocal Computer Science (Paper–II)
Slip – 8
A block of data is stored in memory location starting from C040 H. Length of the block is stored in register
B. Write an Assembly language program to find the smallest number from the given block of data and
store it at the end of the block.
C00A H C0
C00B H 7E MOV A , M ;Copy the data content of memory
whose address is in HL register pair
to the accumulator
C00C H 23 DOWN: INX H ;Increment the memory location of HL
register pair by 1
C00D H 05 DCR B ;Decrement the counter by 1
C040 H = 06 H
C041 H = 07 H
C042 H = 0A H
C043 H = 08 H
C044 H = 01 H
C045 H = ?
After Execution:
A = 01 H H= C0
F = 54 H L= 45
C040 H = 06 H
C041 H = 07 H
C042 H = 0A H
C043 H = 08 H
C044 H = 01 H
C045 H = 01 H
D7 D6 D5 D4 D3 D2 D1 D0
F= S Z X AC X P X C
0 1 0 1 0 1 0 0
Bifocal Computer Science (Paper–II)
Slip – 9
A block of data is stored in memory location starting from C040 H. Length of the block is stored in
register B. Write an Assembly language program to find the first occurrence of the number AB H from
the given block of data and if the number is not found store FFFF H in HL – pair.
C002 H C0
C003 H 3E MVI A, AB H ;Load the data AB H to accumulator
C004 H AB
C005 H 06 MVI B, 05 H ;Set the counter for 05 numbers in
register B
C006 H 05
C00A H C0
C00B H 23 INX H ;Increment the content of HL
register pair by 1
C00C H 05 DCR B ;Decrement the counter by 1
C00F H C0
C012 H FF
C013 H CF DOWN: RST 1 ;Stop the execution
OUTPUT: Before Execution:
After Execution: C040H = 01 H
C041H = 02 H
C042H = AB H
C043H = 04 H
C044H= AB H
After Execution:
A = AB H B = 03 H H = C0 H
L = 42 H F = 54 H
D7 D6 D5 D4 D3 D2 D1 D0
F= S Z X AC X P X C
0 1 0 1 0 1 0 0
Case II:
Before Execution:
C040H= 01 H
C041H = 02 H
C042H = 03 H
C043H = 04 H
C044H = 05 H
After Execution:
A = AB H B = 00 H H = FF H
L = FF H F = 54 H
D7 D6 D5 D4 D3 D2 D1 D0
F= S Z X AC X P X
0 1 0 1 0 1 0 0