Shouldn't this code set the zero flag with CMP?

Asked by BlackCow on 2010-12-16

Not sure if I found a bug or if its my lack of understanding but shouldn't this code set the zero flag on the CMP command?

mvi a, 0dh
sta 08000h
lxi b, 08000h
cmp b ;Shouldn't zero flag be set here?
hlt

Question information

Language:
English Edit question
Status:
Solved
For:
gnusim8085 Edit question
Assignee:
No assignee Edit question
Solved by:
Debjit Biswas
Solved:
2010-12-16
Last query:
2010-12-16
Last reply:
2010-12-16
Best Debjit Biswas (debjitbis08) said : #1

Hi,

Per my understanding, this what your code does,

;store 0dh in register A
mvi a, 0dh
;store the value stored in A into memory location 8000h
sta 08000h
;Load 8000h into BC
lxi b, 08000h
;compare value of registers A and B
;register A has 0dh and B has 80h so comparison is non-zero
cmp b
hlt

Maybe you wanted to do this

MVI A, 0dh
STA 08000h
LXI H, 08000h
CMP M
HLT

BlackCow (blackcow99) said : #2

Ohh, so you can't use the BC or DE registers to read an 8 bit value out of memory, only the HL registers? So then what is BC and DE for?

BlackCow (blackcow99) said : #3

Thanks Debjit Biswas, that solved my question.

Debjit Biswas (debjitbis08) said : #4

For register pair addressing almost all 8085 instructions use the HL registers except for two, the LDAX and STAX instructions. They use use either B and C or D and E registers to address memory.