Hi all,
I'm writing a simple program to test my ram memory of the my z80 small computer. I write this assembly code:

Code:
        LD HL,5000H
        LD (HL),04H
        LD A,(HL)
loop:   OUT (02H),A
         jr loop


On 02H IO address I have connected a simple LED display.
But when I run this program the display show 7EH that is the opcode of the instruction: LD A,(HL) instead of 04H.
Why this???


Code:
DISASSEMBLER LISTING:

0001   0000 21 00 50          LD HL,5000H
0002   0003 36 04              LD (HL),04H
0003   0005 7E                   LD A,(HL)
0004   0006 D3 02              L0001:  OUT (02H),A
0005   0008 18 FC               JR L0001


please let me know.

thanks rohs
That's rather strange, could you inform us of how this is hooked up (or if it's not a custom hookup, but rather part of a commercial computer, could you give us the name/model)? I assume you're writing to that RAM address to make sure that RAM is hooked up correctly? I am far from being able to help a lot in this situation, but I can suggest for you to tell how you hooked up your RAM module here so someone more experienced can help with more given information.
My guess is that you somehow got the address lines between the Z80 and RAM swapped. The LD A,(HL) instruction is at 0005 and HL is 5000, so perhaps the top nibble is being used as the lower nibble. We would need more information about how the RAM is connected, such as a schematic and picture of your circuit, before we can provide more help.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement