| Author |
Message |
Raju C
Joined: 17 Sep 2009 Posts: 43 Location: Bangalore
|
23 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
|
23 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
|
23 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

|
23 Oct 2009 10:04 Ads |
|
|
|
|
|
|
| Back to top |
|
 |
wp100
Joined: 15 May 2009 Posts: 324 Helped: 45 Location: England
|
23 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
|
23 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
|
23 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
|
26 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
|
26 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
|
26 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
|
26 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
|
27 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
|
01 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 |
|
 |