0% found this document useful (0 votes)
2 views

CS-2 Pre Board Practical Outputs

The document contains multiple assembly language programs that manipulate blocks of data stored in memory. Each program performs different operations such as transferring data to a new location, reversing data order, swapping data between two blocks, adding data contents, and storing results in BCD format. The programs include detailed memory locations, opcodes, and comments explaining each step of the process.

Uploaded by

Deepali Ahire
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

CS-2 Pre Board Practical Outputs

The document contains multiple assembly language programs that manipulate blocks of data stored in memory. Each program performs different operations such as transferring data to a new location, reversing data order, swapping data between two blocks, adding data contents, and storing results in BCD format. The programs include detailed memory locations, opcodes, and comments explaining each step of the process.

Uploaded by

Deepali Ahire
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Bifocal Computer Science (Paper–II)

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.

Memory Op- Labels Mnemonics Comments


Location Code
C000 H 21 LXI H, C040H ;Initialize the register pair HL to
memory location C040 H
C001 H 40
C002 H C0

C003 H 01 LXI B, C050H ;Initialize the register pair BC to


memory location C050 H
C004 H 50

C005 H C0
C006 H 16 MVI D, 05 H ;Set the counter for 05 numbers in
register D
C007 H 05

C008 H 7E UP: MOV A,M ;Copy the data content of memory


location whose address is in HL pair to
Accumulator
C009 H 02 STAX B ;Store the data content of accumulator
to memory location whose address is in
register pair BC
C00A H 23 INX H ; To get next location ,increment
content of HL register pair by 1
C00B H 03 INX B ;To get next location ,increment the
content of BC register pair by 1
C00C H 15 DCR D ;Decrement the counter by 1
C00D H C2 JNZ UP: ;If counter  0 (reg. D  0)then jump
to memory location C008H
C00E H 08
C00F H C0

C010 H CF RST 1 ;Stop the execution

1. RESET SET C000 press INR key to enter HEX code.(op-codes)


2. Repeat till end of the code.
3. RESET SET C040 press INR key to enter input numbers.
4. RESET GO C000 EXEC REG LOAD (check all register value) (A, B, C, D, E, F, H, L etc.)
5. RESET SET C050 press INR key to check output
OUTPUT:

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.

Memory Op- Labels Mnemonics Comments


Location Code
C000 H 21 LXI H, C040H ;Initialize the register pair HL to
memory location C040 H
C001 H 40
C002 H C0

C003 H 01 LXI B, C054H ;Initialize the register pair BC to


memory location C054 H
C004 H 54

C005 H C0
C006 H 16 MVI D, 05 H ;Set the counter for 05 numbers in
register D
C007 H 05

C008 H 7E UP: MOV A,M ;Copy the data content of memory


location whose address is in HL pair to
Accumulator.
C009 H 02 STAX B ;Store the data content of accumulator
to memory location whose address is in
register pair BC .
C00A H 23 INX H ; To get next location ,increment
content of HL register pair by 1
C00B H 0B DCX B ;Decrement the content of BC register
pair by 1
C00C H 15 DCR D ;Decrement the counter by 1

C00D H C2 JNZ UP: ;If counter  0 (reg.D  0)then jump


to memory location C008H
C00E H 08

C00F H C0

C010 H CF RST 1 ;Stop the execution


OUTPUT:

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

Memory Op- Labels Mnemonics Comments


Location Code
C000 H 21 LXI H, C040H ;Initialize the register pair HL to memory
location C040H
C001 H 40

C002 H C0

C003 H 01 LXI B, C050H ;Initialize the register pair BC to memory


location C050H
C004 H 50

C005 H C0

C006 H 16 MVI D, 05 H ;Set the counter for 05 numbers in


register D
C007 H 05

C008 H 0A LDAX B ;Load the data contents of memory


: UP location whose address is in register
pair BC to accumulator

C009 H 5F MOV E , A ;Copy the data content of accumulator to


register E
C00A H 7E MOV A ,M ; Copy the data content of memory
location whose address is in register
pair HL to accumulator.

C00B H 02 STAX B ;Store the data content of accumulator


to memory location whose address is in
register pair BC

C00C H 73 MOV M , E ;Copy the data content of register E to


memory whose address is in register
pair HL
C00D H 23 INX H ; Increment the content of HL register
pair by 1 to get next location.

C00E H 03 INX B ; Increment the content of BC register


pair by 1 to get next location.

C00F H 15 DCR D ;Decrement the counter by 1

C010 H C2 JNZ UP: ; If counter  0 (reg. D  0) then jump to


memorylocation C008H
C011 H 08

C012 H C0

C013 H CF RST 1 ;Stop the execution


OUTPUT:

Before Execution:

C040H = 01 H C050H= 06H

C041H = 02 H C051H= 07H


C042H = 03 H C052H= 08H
C043H = 04 H C053H= 09H
C044H = 05 H C054H= 0AH

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.

Memory Op- Code Labels Mnemonics Comments


Location
C000 H AF XRA A ;Clear the data content of accumulator
C001 H 0E MVI C , 00 H ; Initialize Reg. C to zero
C002 H 00
C003 H 06 MVI B, 05 H ;Set the counter for 05 numbers in
C004 H 05 register B
C005 H 21 LXI H, C040H ;Initialize the register pair HL to
C006 H 40 memory location C040 H
C007 H C0
C008 H 86 :UP ADD M ;Add the Memory content pointed by
register pair HL to accumulator
C009 H D2 JNC Down: (C00D) ; Check carry flag. Jump if cy=0,store
result and if cy=1 store carry and result

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.

Memory Op- Labels Mnemonics Comments


Location Code
C000 H AF XRA A ;Clear the data content of accumulator
C001 H 0E MVI C , 00 H ; Initialize Reg. C to zero
C002 H 00
C003 H 21 LXI H, C040H ;Initialize the register pair HL to
C004 H 40 memory location C040 H
C005 H C0
C006 H 46 MOV B, M ;Move memory content to set the
counter
C007 H 23 INX H ; Increment HL reg. pair by one.
C008 H 86 :UP ADD M ;Add the Memory content pointed by
register pair HL to accumulator
C009 H 27 DAA ;Convert result into BCD format

C00A H D2 JNC Down: (C00E) ; Check carry flag. Jump if cy=0,store


result and if cy=1 store carry and result

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.

Memory Op- Labels Mnemonics Comments


Location Code
C000 H 21 LXI H, C040H ;Initialize the register pair HL to
memory location C040 H
C001 H 40
C002 H C0

C003 H 7E MOV A , M ;Copy the memory location content


pointed by HL register pair to
accumulator
C004 H 23 INX H ;Increment the memory location of HL
register pair by 1
C005 H 96 SUB M ;Subtract the data content of memory
pointed by register pair HL with the
data content of accumulator
C006 H JP DOWN: ; If the result in accumulator is
positive (S=0) then jump to memory
C007 H 0B location C00BH.
C008 H C0
C009 H 2F CMA ;Compliment the data content of
accumulator
C00A H 3C INR A ;Increment the data content of
accumulator by 1
C00B H 23 DOWN: INX H ; Increment the content of HL register
pair by 1 to get next location.
C00C H 77 MOV M ,A ;Copy the data content of accumulator
to memory location pointed by HL
register pair
C00D H CF RST 1 ;Stop the execution
OUTPUT:
Case I:
Before Execution:

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.

Memory Op- Labels Mnemonics Comments


Location Code
C000 H 21 LXI H, C040H ;Initialize the register pair HL to
memory location C040 H
C001 H 40
C002 H C0

C003 H 3E MVI A, 00 H ;Assign the lowest value of data to


accumulator
C004 H 00

C005 H 06 MVI B, 05 H ;Set the counter for 05 numbers in


register B
C006 H 05
C007 H BE UP: CMP M ;Compare the data content of memory
pointed by HL register pair with the
data content of accumulator
C008 H D2 JNC DOWN: ; If carry flag is not set (CY=0) then jump
to memory location C00CH to get next
C009 H 0C number.
C00A H C0
C00B H 7E MOV A , M ;Copy the data content of memory
location pointed by HL register pair to
accumulator
C00C H 23 DOWN: INX H ;Increment the memory location
pointed HL register pair by 1
C00D H 05 DCR B ;Decrement the counter by 1

C00E H C2 JNZ UP: ;If counter  0 (reg. B  0 )then jump


to memory location C007H.
C00F H 07

C010 H C0

C011 H 77 MOV M , A ;Store the largest number at the end of


memory block
C012 H CF RST 1 ;Stop the execution
OUTPUT:

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.

Memory Op- Labels Mnemonics Comments


Location Code
C000 H 21 LXI H, C040H ;Initialize the register pair HL to
memory location C040 H
C001 H 40
C002 H C0

C003 H 3E MVI A, FF H ;Assign the highest value of data to


accumulator
C004 H FF

C005 H 06 MVI B, 05 H ;Set the counter for 05 numbers in


register B
C006 H 05

C007 H BE UP: CMP M ;Compare the data content of memory


whose address is in register pair HL with
the data content of accumulator
C008 H DA JC DOWN: ;If carry flag is set then jump to
memory location C00C
C009 H 0C

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

C00E H C2 JNZ UP: ;If counter  0 (reg. B  0 )then jump


to memory location C007H.
C00F H 07
C010 H C0

C011 H 77 MOV M , A ;Store the smallest number at the end


of memory block
C012 H CF RST 1 ;Stop the execution
OUTPUT:
Case I:

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.

Memory Op- Labels Mnemonics Comments


Location Code
C000 H 21 LXI H, C040H ;Initialize the register pair HL to
memory location C040 H
C001 H 40

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

C007 H BE UP: CMP M ;Compare content of memory pointed


by HL register pair with the data
content of accumulator
C008 H CA JZ DOWN : ;If Zero flag is set then jump to
memory location C013H.
C009 H 13

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

C00D H C2 JNZ UP : ;If counter  0 (reg. B  0 )then jump


to memory location C007H
C00E H 07

C00F H C0

C010 H 21 LXI H, FFFF H ;Initialize the register pair HL to


memory location FFFF H
C011 H FF

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

You might also like