electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

PIC18F dividing in assembly language


Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> PIC18F dividing in assembly language
Author Message
Raju C



Joined: 17 Sep 2009
Posts: 43
Location: Bangalore


Post23 Oct 2009 7:15   

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 ?
Back to top
betwixt



Joined: 04 Jul 2009
Posts: 383
Helped: 62
Location: Wales, UK


Post23 Oct 2009 9:08   

Re: PIC18F assembly


1024 = 2^10 so shift it right 10 times. (hint: RRF)

Brian.
Back to top
Raju C



Joined: 17 Sep 2009
Posts: 43
Location: Bangalore


Post23 Oct 2009 10:04   

Re: PIC18F assembly


ya i got .. whether i can use RRf in program directly ? their is no instruction such ?
Back to top
Google
AdSense
Google Adsense




Post23 Oct 2009 10:04   

Ads




Back to top
wp100



Joined: 15 May 2009
Posts: 324
Helped: 45
Location: England


Post23 Oct 2009 10:13   

Re: PIC18F assembly


hi,

RRF on the 16F

RRCF or RRNCF on the 18F
Back to top
Raju C



Joined: 17 Sep 2009
Posts: 43
Location: Bangalore


Post23 Oct 2009 11:39   

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..
Back to top
ravimarcus



Joined: 09 May 2005
Posts: 204
Helped: 19
Location: Bangalore, INDIA


Post23 Oct 2009 13:07   

Re: PIC18F assembly


Raju C wrote:
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
Back to top
Raju C



Joined: 17 Sep 2009
Posts: 43
Location: Bangalore


Post26 Oct 2009 5:19   

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 ??
Back to top
ravimarcus



Joined: 09 May 2005
Posts: 204
Helped: 19
Location: Bangalore, INDIA


Post26 Oct 2009 5:26   

Re: PIC18F assembly


Raju C wrote:
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
Back to top
Raju C



Joined: 17 Sep 2009
Posts: 43
Location: Bangalore


Post26 Oct 2009 7:52   

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 ..
Back to top
sajal1975



Joined: 25 Mar 2005
Posts: 150
Helped: 3


Post26 Oct 2009 11:09   

Re: PIC18F assembly


WRITIN SOFTWARE IS NT A JOKE.
Back to top
Raju C



Joined: 17 Sep 2009
Posts: 43
Location: Bangalore


Post27 Oct 2009 9:28   

Re: PIC18F assembly


sajal1975 wrote:
WRITIN SOFTWARE IS NT A JOKE.

ya its not a joke ??

Added after 2 hours 31 minutes:

ravimarcus wrote:
Raju C wrote:
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??
Back to top
atferrari



Joined: 29 Jun 2004
Posts: 205
Helped: 3
Location: Buenos Aires - Argentina


Post01 Nov 2009 15:27   

PIC18F dividing in assembly language


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

Go slowly and be strict in the checking of what you do.
Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> PIC18F dividing in assembly language
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
c or assembly language (16)
assembly language (2)
assembly language question (5)
8086 Assembly language (6)
Help: Assembly Language (2)
assembly language program (10)
assembly language problem (2)
Assembly language help!! (7)
AVR assembly language tutorial (4)
Assembly Language on PIC 16F872 (2)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS