C
C
Contego2014-12-16 20:52:40
assembler
Contego, 2014-12-16 20:52:40

How to find the difference of two numbers in assembler?

Hello!
Task: find Z = X - Y , where X, Y are double words (4 bytes), on a 16 -bit processor.
So far, I could only come up with such an algorithm: extract byte by byte from the end of X in AL, compare with the corresponding byte Y, if the extracted byte X is less than resp. byte Y, add +1 to register AH, subtract 1 from [Y + 1], subtract and write the result to Z. But such an algorithm, for example, will not get the correct Z if X is less than Y. And, as it seems to me, he is suboptimal.
Maybe there is some more optimal and correct algorithm? Maybe you can somehow use the flag registers?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question