0% found this document useful (0 votes)
6 views2 pages

Mpla Bone

The document outlines several assembly language programs for basic arithmetic and data manipulation tasks, including storing data, adding and subtracting numbers, and finding complements. It provides specific memory addresses and instructions for each operation, demonstrating both direct and indirect addressing methods. Each question is followed by example programs that illustrate the required operations and expected results.

Uploaded by

Achyuta Gajurel
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)
6 views2 pages

Mpla Bone

The document outlines several assembly language programs for basic arithmetic and data manipulation tasks, including storing data, adding and subtracting numbers, and finding complements. It provides specific memory addresses and instructions for each operation, demonstrating both direct and indirect addressing methods. Each question is followed by example programs that illustrate the required operations and expected results.

Uploaded by

Achyuta Gajurel
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/ 2

Q.N. 1 Store 8-bit data in memory Q.N.

4 Add two 16-bit numbers

Statement: Store the data byte 40H into memory location Statement: Add the 16-bit number in memory locations
4000H. 4000H and 4001H to the 16-bit number in memory
locations 4002H and 4003H. The most significant eight bits
Program 1: of the two numbers to be added are in memory locations
MVI A, 40H 4001H and 4003H. Store the result in memory locations
STA 4000H 4004H and 4005H with the most significant byte in
HLT memory location 4005H.

Program 2: (4000H) = 15H


LXI H 4000H (4001H) = 1CH
MVI M, 40H (4002H) = B7H
HLT (4003H) = 5AH

Note: The result of both programs will be the same. In Result = 1C15 + 5AB7H = 76CCH
program 1 direct addressing instruction is used, whereas in (4004H) = CCH
program 2 indirect addressing instructions is used. (4005H) = 76H

LHLD 4000H : Get first I6-bit number in HL


Q.N. 2 Exchange the contents of memory locations XCHG : Save first I6-bit number in DE
LHLD 4002H : Get second I6-bit number in HL
Statement: Exchange the contents of memory locations MOV A, E : Get lower byte of the first number
2000H and 4000H. ADD L : Add lower byte of the second number
MOV L, A : Store result in L register
Program1: MOV A, D : Get higher byte of the first number
ADC H : Add higher byte of the second number with
LDA 2000H CARRY
MOV B, A MOV H, A : Store result in H register
LDA 4000H SHLD 4004H : Store I6-bit result in memory
STA 2000H locations 4004H and 4005H.
MOV A, B HLT : Terminate program execution
STA 4000H

Program 2: LHLD 4000H : Get first I6-bit number


XCHG : Save first I6-bit number in DE
LXI H, 2000H LHLD 4002H : Get second I6-bit number in HL
LXI D , 4000H DAD D : Add DE and HL
MOV B, M SHLD 4004H : Store I6-bit result in memory
LDAX D locations 4004H and 4005H.
MOV M, A . HLT : Terminate program execution
MOV A, B
STAX D .
HLT Q.N. 5 Subtract two 8-bit numbers

Note: In Program 1, direct addressing instructions are used, Statement: Subtract the contents of memory location
whereas in Program 2, indirect addressing instructions are 4001H from the memory location 2000H and place the
used. result in memory location 4002H.

Q.N. 3 Add two 8-bit numbers LXI H, 4000H


MOV A, M
Statement: Add the contents of memory locations 4000H INX H
and 4001H and place the result in memory location 4002H. SUB M
INX H
LXI H 4000H : HL points 4000H MOV M, A
MOV A, M : Get first operand HLT
INX H : HL points 4001H
ADD M : Add second operand
INX H : HL points 4002H Q.N. 6 Subtract two 16-bit numbers
MOV M, A : Store result at 4002H
HLT : Terminate program execution Statement: Subtract the 16-bit number in memory locations
4002H and 4003H from the 16-bit number in memory
locations 4000H and 4001H. The most significant eight bits
of the two numbers are in memory locations 4001H and
4003H. Store the result in memory locations 4004H and
4005H with the most significant byte in memory location
4005H.

LHLD 4000H
XCHG
LHLD 4002H
MOV A, E
SUB L
MOV L, A
MOV A, D
SBB H
MOV H, A
SHLD 4004H
HLT

Q.N. 7 finding one's complement of a number

Statement: Find the l's complement of the number stored at


memory location 4400H and store the complemented
number at memory location 4300H.

LDA 4400B : Get the number


CMA : Complement number
STA 4300H : Store the result
HLT : Terminate program execution

Q.N. 7 Finding 2's complement of a number

Statement: Find the 2's complement of the number stored at


memory location 4200H and store the complemented
number at memory location 4300H.

LDA 4200H : Get the number


CMA : Complement the number
ADI, 01 H : Add one in the number
STA 4300H : Store the result
HLT : Terminate program execution

You might also like