A problem with coding in 8085 microprocessor

  • Thread starter Thread starter dragonflyv2
  • Start date Start date
  • Tags Tags
    Coding
Click For Summary
The discussion revolves around a coding issue encountered while using the 80085 simulator for basic arithmetic operations. The provided assembly code is intended to load the value 01H into memory location 0002H. However, the code does not perform as expected. The sequence of operations includes storing 00H at address 0001H and 01H at address 0002H, followed by an attempt to transfer the contents of address 0001H to address 0002H. The confusion arises from the logic of the program, as it effectively overwrites the intended value at 0002H with the value from 0001H instead of achieving the desired outcome. The discussion highlights the importance of understanding memory operations and the flow of data in assembly language programming.
dragonflyv2
Messages
1
Reaction score
0
After i had studied and implemented codes to perform basic arithematic operations, factorial of a number, look-up tables, i got stuck at a pretty silly problem, while coding with the 80085 simulator:

MVI A,000H
STA 0001H
MVI A,0001H
STA 0002H
LXI H,0001H
MOV A,M
LXI B,0002H
STAX B
HLT
This piece of code is supposed to load the value 01H in the memory location 0002H. But it doesno't go as i expected. Where is the error with my logic.
 
Technology news on Phys.org
dragonflyv2 said:
MVI A,000H
STA 0001H
MVI A,0001H
STA 0002H
LXI H,0001H
MOV A,M
LXI B,0002H
STAX B
HLT
This piece of code is supposed to load the value 01H in the memory location 0002H. But it doesno't go as i expected. Where is the error with my logic.
Assuming that you have RAM at memory address 0000...?, then that program should store zero at both address 0000 and 0001, though it's a convoluted way of doing it. What are you actually trying to achieve?

Basically your program does the following
- stores 00 at location 0001
- stores 01 at location 0002
- transfers the contents of 0001 to 0002
 
Last edited:
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K