Program 2.19.6 (Q.
5(b), April 2023, 5 Marks)
A block of data is stored in memory location 4500 H. The
length of block is stored in memory location 44FFH. Wite
an Assembly Language Program that searches for the first
OCcurrence of data D9H in given block. Store the address
of this occurrence in H.L. pair. If the number is not found
then HL pair should contain 5000 H.
Program
IXIH. 4500H ; Load the Start block memory
address
: 4500H inHL register pair
LDA 44FFH : Load Accumulator from 44FFH
which
; is the length of the block
MOV C, A ; Transfer A register to C(Length of a
;Block)
LOOP: MOV A, M :Transfer the memory location content
; pointed by HL pair to an A
CPI D9H ; Compare Accumulator with D9H
data
JZ FINISH : IF Accumulator=D9H, then exit
; loop. i.e., go to FINISH
INX H : Increment the Source memory
address
; by one
DCRC : Decrement the length of the series
JNZ LOOP ; Jump back to LOOP if the length
1S
not zero
LXIH,5000H : Load HL pair with 5000H data
HLT
FINISH: HLT ; Halt the program using the
: (Halt) instruction.
Program 2.18.68 (Q. 5(a), April 2023, 5 Marks)
Write an Assembly Language Program to exchange the
nibbles of 8-bit number stored in memory location 4500H.
Store the result at memory location 4501H.
LDA 4500H ; Load Accumulator from 4500H
memory
; location
RLC ; Rotate Left Accumulator left by one
bit
RLC ; Rotate Left Accumulator left byone
bit
RLC Rotate Left Accumulator left by one
bit
RLC ; Rotate Left Accumulator left by one
bit
; to exchange nibbles
STA 4501H :Store Accumulator at 4501H memory
; location
HLT ; Halt the program using the HLT
Program 2.18.56 (Q. 5(c), April 2023, 5 Marks)
memory
Write an Assembly Language Program to fill the numbers
locations4500H to 4504 with the Hexadecimal
09 H to ODH respectively.
Program
LXI H, 4500H :Load the Start block memory address
: 4500H in HL register pair
MVI C.05H ;C=05H (Length of a Blockfrom
; 4500H to 4504H)
MVIA, 09H :A=09H to Store data from 09H to
: 0DH
Accumulator
LOOP: MOV M, A :Transfer the content of
to
;memory location pointed by HL
INR A : Increment Accumulator content by
One
INX H ; Increment the Source memory
address
: by one
DCR C ; Decrement the length of the series
JNZ LOOP ; Jump back to L0OP if the length is
not
; ZerO
HLT ; Halt the program using the HLT
Progranm 2.18.55 (March 18, 5 Marks)
Write an assembly language program to fill in the
locations starting fromn 6900H and onward with memory
the
decimal numbers 0to 99.
Program
LXIH, 6900H : Load the Start block memory address
AB0OH in HL register pair
MVIC, 64H ; C=64H (Length of a Block from 100
; bytes from 00 to 99 i.e., 64 in hex)
MVI A, 00H: A=09H to Store data from
09H to
ODH
LOOP: MØV M, A: Transfer the content of
to
Accumulator
;memory location pointed by HL
ADI01H : Add Accumulator
content by one
DAA ; Convert Hex result into decimal
INX H ; Increnment the Source
address
memory
: by one
DCR C : Deerement the length of the series
JNZ LOOP : Jump back to LOOP if the length is
Iot
: Halt the progrm using the HL.T
Program 2.18.55(March 18, 5 Marks)
Write an assembly language program to fill in the memory
locations starting from 6900H and onward with the
decimal numbers 0to 99.
Program
LXI H, 6900H : Load theStart block memory address
ABOOH in HL register pair
MVI C, 64H : C=64H (Length of aBlock from 100
bytes from 00 to 99 i.e., 64 in hex)
MVI A, 00H: A=09H to Store data from 09H to
ODH
LOOP: MOV M, A : Transfer the content of Accumulator
to
memory location pointed by HL
ADI01H Add Accumulator content by one
DAA ; Convert Hex result into decimal
INX H : Increment the Source memory
address
; by one
DCR C Decrement the length of the series
JNZ LOOP ; Jump back to LOOP if the length is
not
; ZerO
HLT ; Halt the program using the HLT
Program 2.18.21 (Q. 5(a), April2023, 5 Marks)
Write an Assembly Language Program to copy a block of
data having starting address 4500 H to new location
starting from 4600 H. The length of block is stored at
memory location 44FF H.
Program
LXI H,44FFH; Load the Source starting block
memory address C101H in HL
register
pair
MOV C, M : Move Length of a Block in Cregister
; from 44FFH location
INX H : Load the Source starting block
address
: 5000H in HL register pair
LXID. 4600H ; Load the Destination starting block
address 4600H in DE register pair
LOOP: MOV A, M; Transfer the memnory location content
: pointed by HL pair to an A
STAX D : Transfer Accumulator to a memory
; Location pointed by DE Pair
INX H ; Increment the Source memory
address
; by one
INX D ; Increment the Destination memory
address by one
DCRC Decrement the length of the series
JNZ LOOP ; Jump back to L0OP if the length is
not
zero
HLT ; Halt the program using the HLT
(Halt)
instruction.
Program 2.18.22:(Q. 5(c), April2023, 5 Marks)
Ablock of data is stored from memory location 4501H and
onwards. The length of the block is stored at memory
location 4500H. Write an Assembly Language Program to
find the sum of block of data. Store the two byte result
from memory location 4600 H.
Program
LXIH, 4500H ;Load memory location 4500 into HL
;register pair
MOV C, M ;Move the length of the series into the
;Cregister
MVID, 00H ;Initialize D register to 0 for carrying
MVIA,00H :Clear Accumulator
LOOP: INX H ;Increment HL pointer by one
ADD M ; Add the number to the sum in the B
; register
JNCSKIP :Jump to SKIP if no carry (no
overflow)
INR D ; Increment D register if there is a
carry
SKIP:DCRC :Decrement the length of the series
JNZ LOOP ; Jump back to LOOP if the length is
:not zero
LXI H,4600H :Load memory location 4600 into HL
;register pair
MOV M, A :Move the final sum (Lower byte) to
; memory location 4600H
INX H ; Increment HL pointer by one
MOV M, A ;Move the carry (higher byte) to
; memory location 4601H
HLT : Halt the program