0

https://encrypted.google.com/books?id=FIYGSv3-C6IC&pg=PA59&lpg=PA59&dq=mov+r,+M+8085&source=bl&ots=aX-essc34w&sig=vyGYCHeeJP_Dv_iE8ZjggI2Zh1k&hl=en&sa=X&ei=iZd8U6uJNNWhugSNoILADg&ved=0CF8Q6AEwCQ#v=onepage&q=mov%20r%2C%20M%208085&f=false

From the above link: Content of the memory location whose address is available in H,L pair is transferred to the destination register r.

What I don't understand is how does the address go into the H,L pair? I have a memory address and want the value present in it to be transferred to a register. How do I do this using MOV r,M instruction?

aste123
  • 1,223
  • 4
  • 20
  • 40

2 Answers2

2

You first have to load the required address into HL, then you can get the contents of the address pointed at by HL, e.g.

LXI HL,1000h          ; load 16 bit address 0x1000 into HL register pair
MOV B,(HL)            ; read contents of address 0x1000 into register B
Paul R
  • 208,748
  • 37
  • 389
  • 560
  • so basically it is register to register transfer? – aste123 May 21 '14 at 13:40
  • No - it's a load from memory, using indirect addressing, where the address is held in a register pair (HL). – Paul R May 21 '14 at 14:11
  • Yes, sorry. I get it. Can I use any register pair to hold the address of the memory location? Like `LXI BC,1000h` and then `MOV D,(BC)`. Is there any reason why most texts use HL pair for this purpose? – aste123 May 21 '14 at 14:50
  • 1
    No, HL is special, so although you can load an address into BC or DE you can only use HL for register indirect addressing like this. – Paul R May 21 '14 at 15:47
  • ok, thank you. This shows why HL is used everywhere. But I can't find any specific reason or anything on why other registers can't be used in register indirect addressing. The only bit I found was on wikipedia (https://en.wikipedia.org/wiki/Intel_8085#Programming_model) : `Some instructions use HL as a (limited) 16-bit accumulator. As in the 8080, the contents of the memory address pointed to by HL could be accessed as pseudo register M.` I still don't get why other registers can't be used for register indirect addressing. – aste123 May 21 '14 at 16:17
  • 1
    Well this chip was developed about 35 years ago, and they had to make every transistor count. Most of the design limitations are due to trade-offs between functionality and how much silicon was available to implement that functionality. If you look at the Z80, which came a little later, it was basically an 8085 on steroids, but it still had its limitations. Even modern CPUs have to make trade-offs between functionality and cache size, etc. – Paul R May 21 '14 at 16:24
1

8085 includes some "undocumented" instructions not found on an 8080 and not implemented by the Z80, so these are rarely used. Here is a include file for the 8085 specific instructions. In my case, these were used for the BIOS and utility programs for an 8085 based CP/M computer. Note that DE can be used as an address to load or store HL as a 16 bit value:

ARHL    MACRO       ;ARITH RIGHT SHIFT HL
    DB  10H
    ENDM
DSUB    MACRO       ;HL=HL-BC
    DB  08H
    ENDM
JNXC    MACRO   X   ;JMP IF NOT X CARRY (INX, DCX)
    DB  0DDH
    DW  X
    ENDM
JXC MACRO   X       ;JMP IF X CARRY
    DB  0FDH
    DW  X
    ENDM
LDHI    MACRO   I   ;DE=HL+I
    DB  28H
    DB  I
    ENDM
LDSI    MACRO   I   ;DE=SP+I
    DB  38H
    DB  I
    ENDM
LHLX    MACRO       ;HL=(DE)
    DB  0EDH
    ENDM
RDEL    MACRO       ;ROTATE DE,CY LEFT
    DB  18H
    ENDM
RIM MACRO           ;RESET INT MASK
    DB  20H
    ENDM
RSTV    MACRO       ;RST IF V SET TO 40H
    DB  0C8H
    ENDM
SHLX    MACRO       ;(DE)=HL
    DB  0D9H
    ENDM
SIM MACRO           ;SET INT MASK
    DB  30H
    ENDM
rcgldr
  • 27,407
  • 3
  • 36
  • 61