Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Division of 2 signed integer numbers

arnonyhmarnonyhm Member Posts: 1
hello,

i have to write an assembler code for the 8051 microcontoller.

the division of two signed int numbers (range -32768 to 32767).
can someone post the code?

Comments

  • m34tb34tm34tb34t Member Posts: 25
    The 8051 is used to control the keyboards of many PC's.
    All math operations must use the accumulator register and the opcodes
    are all pretty much the same as the more advanced 8086.
    I don't know the memory layout that you're going to be using but, let us assume your numerator is at offset 10h and your denominator is at offset 12h...
    [code]
    mov a,10h
    mov b,12h
    div ab
    [/code]
    I'm not too familiar with direct programming of the 8051 since most of the time it is only used indirectly (through IN and OUT opcodes to ports) and the code to handle keystrokes is burned into the chip...

    As far as I have read (google.com) there is no IDIV opcode for the 8051 so simply mind your two's compliment notation when printing the value...
Sign In or Register to comment.