0% found this document useful (0 votes)
100 views4 pages

Exchange The Contents of Memory Locations

The document describes programs to: 1) Exchange the contents of two memory locations by copying the first location's contents to a register, writing the second location's contents to the first, and then writing the register contents to the second location. 2) Add two 8-bit numbers stored in consecutive memory locations by loading the operands and storing the result in a third location. 3) Multiply two 8-bit numbers stored in memory locations by initializing a result to 0, repeatedly adding the first number to the result, and storing the final result.

Uploaded by

Vinay Patel
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
100 views4 pages

Exchange The Contents of Memory Locations

The document describes programs to: 1) Exchange the contents of two memory locations by copying the first location's contents to a register, writing the second location's contents to the first, and then writing the register contents to the second location. 2) Add two 8-bit numbers stored in consecutive memory locations by loading the operands and storing the result in a third location. 3) Multiply two 8-bit numbers stored in memory locations by initializing a result to 0, repeatedly adding the first number to the result, and storing the final result.

Uploaded by

Vinay Patel
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Exchange the contents of memory locations

LDA 2000H : Get the contents of memory location 2000H into accumulator

MOV B, A : Save the contents into B register

LDA 4000H : Get the contents of memory location 4000Hinto accumulator

STA 2000H  : Store the contents of accumulator at address 2000H

MOV A, B : Get the saved contents back into A register

STA 4000H : Store the contents of accumulator at address 4000H

OR

LXI H 2000H : Initialize HL register pair as a pointer to memory location 2000H.

LXI D 4000H : Initialize DE register pair as a pointer to memory location 4000H.

MOV B, M  : Get the contents of memory location 2000H into B register.

LDAX D : Get the contents of memory location 4000H into A register.

MOV M, A : Store the contents of A register into memory location 2000H.

MOV A, B : Copy the contents of B register into accumulator.

STAX D : Store the contents of A register into memory location 4000H.

HLT : Terminate program execution.

2}Add two 8-bit numbers


LXI H 4000H : HL points 4000H

MOV A, M : Get first operand

INX H : HL points 4001H

ADD M : Add second operand


INX H : HL points 4002H

MOV M, A : Store result at 4002H

HLT : Terminate program execution

OR

MVI C, 00 Intialize counter s 00

LDA 4150 Load value to accumulator

MOV B,A Move contents of accumulator to register B

LDA 4150 Load the value to accumulator

ADD B Add the value of register B to A

JNC * Loop Jump on no carry

INR C Increment the value of register C

STA 4152 Store the value of Accumulator(SUM)

MOV A,C Move contents of the register c to Accumulator

STA 4153 Store the value of Accumulator(Carry)

RST Restart
Multiply two 8-bit numbers stored in memory locations 2200H and 2201H

 LDA 2200H

 MOV E, A

 MVI D, 00 : Get the first number in DE register pair

 LDA 2201H

 MOV C, A  : Initialize counter

 LX I H, 0000 H  : Result = 0

 BACK: DAD  D  : Result = result + first number

 DCR C  : Decrement count

 JNZ  BACK  : If count   0 repeat

 SHLD 2300H : Store result

 HLT  : Terminate program execution

Or

MVI D,00
MVI A,00

LXI H,4150

MOV B,M

INX H

MOV C,M

ADD B

JNC Next

INR D

DCR C

JNZ Loop

STA 4152

MOV A,D

STA 4153

RST
Write a program to shift an eight bit data four bits right. Assume data is in register C

 MOV A, C

 RAR

 RAR

 RAR

 RAR

 MOV C, A

 HLT

OR

 MOV A, B

 RAR

 MOV B, A

 MOV A, C

 RAR

 MOV C, A

 HLT

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy