0

I am trying to add two 8 bit number and wrote the following code:

MVI D 08h
MVI B 03h
MVI C 00h
MOV A D
LOOP: CMP B
JC DOWN
INR A
SUB B
JNZ LOOP

DOWN: HLT

But I got incorrect output.

James Z
  • 12,209
  • 10
  • 24
  • 44
MC_user
  • 48
  • 3
  • Why not simply use the 'Add' instruction? Example: https://www.geeksforgeeks.org/assembly-language-program-8085-microprocessor-add-two-8-bit-numbers/ – Johan Donne Nov 16 '19 at 12:51

1 Answers1

0

Well assuming my assumption is correct that you are storing answer in C,

then just do a small change on 7th line:

MVI D 08h
MVI B 03h
MVI C 00h
MOV A D
LOOP: CMP B
JC DOWN
INR C
SUB B
JNZ LOOP

DOWN: HLT

It should work now.

Deepak Tatyaji Ahire
  • 4,883
  • 2
  • 13
  • 35