2

I am sorry if the question is too basic but I still cannot understand the code that I found in Google. Basically, I need to make a simple code of MOV r, M instruction in 8085 microprocessor.

Here is the code that I want to make:

LXI H, 1234H
MOV B, M
HLT

My question is the code correct? What is the result of the code after it get executed? Does the B contain 1234H data now? Or the result does not have any content in E because there is no value specified in 1234H memory? Really appreciate for any help or guidance, thanks.

GSerg
  • 76,472
  • 17
  • 159
  • 346
Anonymous
  • 21
  • 2
  • 2
    `LXI H, 1234H` loads the immediate value (an address in this case) to the `HL` register pair. `MOV B, M` moves the byte from memory address pointed to by the `HL` register pair and puts it in the `B` register – Michael Petch Jun 11 '23 at 13:18
  • @MichaelPetch But for the code above, there is no value in B right after it get executed? Because I have not specified any value for memory 1234H, is this correct from my understanding? – Anonymous Jun 11 '23 at 13:31
  • 2
    There will be a value at memory address `1234h` but it is garbage (could be any value) if you haven't put anything there to begin with. – Michael Petch Jun 11 '23 at 13:39
  • @MichaelPetch ah understand. So, for the code above, it should be all correct already? Do I need to initialize the value in adress 1234H? If yes, can I use command MVI H, 38H? – Anonymous Jun 11 '23 at 13:42
  • 1
    `MVI H, 38H` just moves the immediate value `38H` into the 8-bit register `H`. To initialize memory address 1234h with `38H` you could do `LXI H, 1234H` `MVI M, 38H` – Michael Petch Jun 11 '23 at 13:56
  • 2
    Ah now I got it. I just run the code in the 8085 simulator with the MVI M, 38H and now I can see that the register B have the value 38H. Thankyou so much @MichaelPetch for your help. Really appreciated. – Anonymous Jun 11 '23 at 14:15

0 Answers0