-2
LXI H, 2200H
LXI D, 2300H
MVI C, 32H

BACK:    MOV A, M
               ANI 01H
              JNZ SKIP
              MOV A, M
              STAX D
              INX D
SKIP:    INX H
              DCR C
              JNZ BACK
               HLT

with these I only can find even number, not the odd number can anyone help to fix my code?

Michael
  • 57,169
  • 9
  • 80
  • 125

1 Answers1

1

Just Change the JNZ to JZ in 7th line. Here is the modified code:

LXI H, 2200H
LXI D, 2300H
MVI C, 32H

BACK: MOV A, M
    ANI 01H
    JZ SKIP #JNZ changed to JZ
    MOV A, M
    STAX D
    INX D

SKIP: INX H
    DCR C
    JNZ BACK

HLT