DIV AB command in assembly.

Discussion in 'Embedded Systems and Microcontrollers' started by thar07, Mar 21, 2015.

  1. thar07

    Thread Starter Member

    Jan 3, 2015
    71
    0
    Following program was written to display any two digit number given to the Accumulator on the LCD screen ( AES 8051 board ) . I do not understand the process of of the 'div ab' command and why it is used. Can you explain it to me ?


    Code (Text):
    1.  
    2.  
    3. ORG 7000h        ;start
    4. call 4100h          ; clear screen
    5. mov a, #65        ;add 65 to a
    6. mov b, #10        ;add 10 to b
    7. div ab                  ;divid a by b  
    8. mov r1, a            ;mov a to r1  
    9. mov r2, b           ;mov b to r2
    10.  
    11. mov a, r1            ;mov r1 to a
    12. add a, #48        ;add 48 to a
    13. call pro                 ;call pro
    14. clr a                       ;clear accumulator
    15. mov a, r2           ;mov r2 to a
    16. add a, #48         ;add 48 to a
    17.  
    18. pro:        clr 90h                       ; select data write
    19.              mov dptr, #0fff3h    ; lcd address
    20.              movx @dptr, a        ; send data to lcd
    21.              mov r0, #0
    22.              djnz r0, $                    ; delay > 1ms
    23.              djnz r0, $                   ; (1020 machine cycles)
    24.  
    25.                clr 91h
    26.                setb 91h
    27.                ret
    28.    
    29. END
    30.  
     
  2. MrChips

    Moderator

    Oct 2, 2009
    12,421
    3,357
    Firstly, you need to state which microcontroller (MCU) you are using.
    Secondly, that is very poorly written and documented code.
    Thirdly, go to a description of the instruction set of the MCU to learn about a specific instruction.

    The 8051 DIV instruction divides accumulator A by accumulator B. The result is in A and the remainder in B.
    In simple terms, the example attempts to separate a 0-99 binary value into the tens and units coefficients.
     
    thar07 likes this.
  3. thar07

    Thread Starter Member

    Jan 3, 2015
    71
    0
    Micro controller is 8051 and that why I state the development board's name.

    thank you :)
     
Loading...