DIV AB command in assembly.

Thread Starter

thar07

Joined Jan 3, 2015
71
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:
ORG 7000h        ;start
call 4100h          ; clear screen
mov a, #65        ;add 65 to a
mov b, #10        ;add 10 to b
div ab                  ;divid a by b   
mov r1, a            ;mov a to r1   
mov r2, b           ;mov b to r2

mov a, r1            ;mov r1 to a
add a, #48        ;add 48 to a
call pro                 ;call pro
clr a                       ;clear accumulator
mov a, r2           ;mov r2 to a
add a, #48         ;add 48 to a

pro:        clr 90h                       ; select data write
             mov dptr, #0fff3h    ; lcd address
             movx @dptr, a        ; send data to lcd
             mov r0, #0
             djnz r0, $                    ; delay > 1ms
             djnz r0, $                   ; (1020 machine cycles)

               clr 91h
               setb 91h
               ret
   
END
 

MrChips

Joined Oct 2, 2009
30,810
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.
 

Thread Starter

thar07

Joined Jan 3, 2015
71
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.
Micro controller is 8051 and that why I state the development board's name.

thank you :)
 
Top