This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Divide one word by one byte

Hello everyone !!!
Sorry for my english,i speak french !!!

I program with the A51 assembler!

I do not manage to make a division of a word by one byte.
Somebody would have it a solution to come me to assistance (existing function or macros).

Thank you in advance!!!

Parents
  • "I do not manage to make a division of a word by one byte."

    By "word" I assume you mean 16 bits?

    As you must've realised by now, the 8051 is an 8-bit processor, so it doesn't have any instructions for dealing with 16 (or more!) bit numbers.
    If you were to write in 'C', the compiler would take care of all this for you; but, as you're writing in assembler, you have to do it all yourself!

    You need to think about how you would do long-division yourself, if you had no calculator and had to do it by hand:

    You have to start with the most-significant byte of the dividend, and divide by the divisor to give the MS byte of your quotient; then you have to do the LS byte, coping with any "carry",etc

    Now you can see how compiler writers make their money...?

Reply
  • "I do not manage to make a division of a word by one byte."

    By "word" I assume you mean 16 bits?

    As you must've realised by now, the 8051 is an 8-bit processor, so it doesn't have any instructions for dealing with 16 (or more!) bit numbers.
    If you were to write in 'C', the compiler would take care of all this for you; but, as you're writing in assembler, you have to do it all yourself!

    You need to think about how you would do long-division yourself, if you had no calculator and had to do it by hand:

    You have to start with the most-significant byte of the dividend, and divide by the divisor to give the MS byte of your quotient; then you have to do the LS byte, coping with any "carry",etc

    Now you can see how compiler writers make their money...?

Children