Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC18F dividing in assembly language

Status
Not open for further replies.

Raju C

Member level 2
Joined
Sep 17, 2009
Messages
50
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Bangalore
Activity points
1,558
PIC18F assembly

Hi all..
can anybody tell me how to do the program for INT(3E85h/1024) in assembly , i am using PIC18F and here no division operation so pls can any one help .. how to write code ?
 

Re: PIC18F assembly

ya i got .. whether i can use RRf in program directly ? their is no instruction such ?
 

Re: PIC18F assembly

hi,

RRF on the 16F

RRCF or RRNCF on the 18F
 

PIC18F assembly

ya correct .. RRCF in 18F but .. if you use this you wont get the result for all no's .. see 3E85 and 3F4d you check this operation on both output should be 15 but we wont get that..
 

Re: PIC18F assembly

Raju C said:
ya correct .. RRCF in 18F but .. if you use this you wont get the result for all no's .. see 3E85 and 3F4d you check this operation on both output should be 15 but we wont get that..

Thats because you are not clearing the carry while looping back.

Try this code.

movlw 3Fh
movwf msb
movlw 4Dh
movwf lsb

movlw .10
movwf counter

loop bcf status,carry ; carry is cleared while looping back
rrcf msb,same
rrcf lsb,same
decfsz counter,same
goto loop


Cheers

Ravi
 

PIC18F assembly

same means here you are telling two times shift ?after shifting msb i need to clear carry .. and again after shifting lsb also i have to clear carry ??
 

Re: PIC18F assembly

Raju C said:
same means here you are telling two times shift ?after shifting msb i need to clear carry .. and again after shifting lsb also i have to clear carry ??
same = 1, means save it back in the same register. ex:- rrf msb,1.

Before shifting MSB, clear the carry, any carry from MSB has to be shifted into LSB. So for the next looping, clear the carry if any from LSB as we do not need it.

Cheers

Ravi
 

PIC18F assembly

ya 1 means it will store to same reg , i will try this and if i get any prob i will ask you ..
 

Re: PIC18F assembly

WRITIN SOFTWARE IS NT A JOKE.
 

Re: PIC18F assembly

sajal1975 said:
WRITIN SOFTWARE IS NT A JOKE.
ya its not a joke ??

Added after 2 hours 31 minutes:

ravimarcus said:
Raju C said:
same means here you are telling two times shift ?after shifting msb i need to clear carry .. and again after shifting lsb also i have to clear carry ??
same = 1, means save it back in the same register. ex:- rrf msb,1.

Before shifting MSB, clear the carry, any carry from MSB has to be shifted into LSB. So for the next looping, clear the carry if any from LSB as we do not need it.

Cheers

Ravi
i tried it but after shifting 10 times we will get 1F and 26 in MSB and in LSB respectively.. but the result should be F so where it will be??
 

Use the simulator MPSIM and you could see how things develope.

Go slowly and be strict in the checking of what you do.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top