dividing two binary numbers

Thread Starter

jayjay23

Joined Sep 30, 2011
12
can anyone please help me on how to write a code using mplap PIC18F26J11 to divide 2 binary numbers. already started the code but i dont know how to do the rest.

after my initialization
for example [0101,0011]

MOVF PORTB,0 ; move data in port-b to w-reg
MOVWF 0X0; move data in w-reg to address 0x0
MOVWF 0X1; move same data in 0x01
SWAPF 0X0,1; swap data in 0x0 and save it in itself
MOVLW 0X0F; move [0000,1111] into w-reg
ANDWF 0X0,1; and data in oxo with data in w-reg and save it in itself
ANDWF 0X1,1; and data in ox1 with data in w-reg and save it in itself
MOVF 0X0,0; move data in 0x0 into w-reg


this is where i got stuck because i could'nt find a function that says *DIVF* and the answer is will be moved in to PORT-C

help please :confused:
 

ErnieM

Joined Apr 24, 2011
8,415
this is where i got stuck because i could'nt find a function that says *DIVF*
If you mean "instruction" then you are correct, there is no instruction to do division on these devices. You either have to write one yourself or find some code online and copy it.

The simpler you make it the shorter and easier the code (unsigned bytes are the simplest).
 
Top