| Home | Products | Prices | Directory | Order | Contact | New | Books | Files | Links | Other |
| Bottom of Page |
Subject: Re: Microchip Code Converted PIC Source Book Anyone?? Date: Fri, 5 Jun 1998 03:50:50 -0500 From: Fred HatfieldOrganization: Bitmap To: PICLIST@MITVMA.MIT.EDU Don McKenzie wrote: > > Fred Hatfield wrote: > > > > Thanks for the help everyone. Once I found out indirect is the same INDF > > I was set > > > Jon > > > I also have the PIC Source Book. Converting the op codes > > to Microchip format is a real nuiscance, but the routines > > listed there are excellent for reference, especially when > > you compare them to the PBASIC commands that they represent. > > Fred. > > fred.hatfield@sstar.com > > If anyone has done it, or has the interest to do it either as an > individual or as a group, I will post a Microchip PIC Source Book > conversion page to complement the original page. > See: http://www.dontronics.com/see.html for the original. > > A worthy project and a boon for beginners? Absolutely a worthy project! Especially for newbies like myself. Scott's book is valuable in more than one way -- it is neat to see how each Stamp PBASIC command is constructed on the PIC. It should be somewhat easy to thread many of those pre- written routines together into a working program. Sort of an assembler representation of a Stamp PBASIC program. Fred. fred.hatfield@sstar.com ================================================ Subject: Re: Parallax format code Date: Sun, 7 Jun 1998 12:56:36 +0200 From: "Stefan M. Ranguelov" ranguelo@INFORMATIK.HU-BERLIN.DE Reply-To: pic microcontroller discussion list PICLIST@MITVMA.MIT.EDU To: PICLIST@MITVMA.MIT.EDU Hi ! I have put on my WEB space under : http://www.informatik.hu-berlin.de/~ranguelo/picstuff/parallax.inc an include file for MPASM. It defines the Parallax-Style assembler istructions as macros in MPASM, so parallax code can be assembled with MPASM. The author of this file is Ivan Cenov, i have inly put it on the WEB. If you have any questions, his e-mail adress is : okto7@botev.ttm.bg
Here is the contents of: http://www.informatik.hu-berlin.de/~ranguelo/picstuff/parallax.inc nolist ; PARALLAX.INC (w) I. M. Cenov ; Assembler: MPASM Microchip ; Macro Definitions Of Parallax Assembler Instruction Set ; Multi-Microchip coded parallax istructions only are "macrosed" here. ; Skippers ; csafl : compare fr to literal and skip if above ; csaff : compare fra to frb and skip if above ; csaefl : compare fr to literal and skip if above or equal ; csaeff : compare fra to frb and skip if above or equal ; csbfl : compare fr to literal abd skip if below ; csbff : compare fra to frb and skip if below ; csbefl : compare fra to literal and skip if below or equal ; csbeff : compare fra to frb and skip if below or equal ; csefl : compare fr to literal and skip if equal ; cseff : compare fra to frb and skip if equal ; csnefl : compare fr to literal and skip if not equal ; csneff : compare fra to frb and skip if not equal ; Comparators (rely on skippers) ; cjafl : compare fr to literal and jump if above ; cjaff : compare fra to frb and jump if above ; cjaefl : compare fr to literal and jump if above or equal ; cjaeff : compare fra to frb and jump if above or equal ; cjbfl : compare fr to literal abd jump if below ; cjbff : compare fra to frb and jump if below ; cjbefl : compare fra to literal and jump if below or equal ; cjbeff : compare fra to frb and jump if below or equal ; cjefl : compare fr to literal and jump if equal ; cjeff : compare fra to frb and jump if equal ; cjnefl : compare fr to literal and jump if not equal ; cjneff : compare fra to frb and jump if not equal ; dec- increment & jump ; djnz : decrement fr and jump if not zero ; ijnz : increment fr and jump if not zero ; Bit compare jumpers ; jb : Jump if bit set ; jc : Jump if Carry ; jnb : Jump if bit clear ; jnc : Jump if not Carry ; jnz : Jump if not zero ; jz : Jump if zero ; Movers ; movfl : Move literal to fr ; movff : Move frb to fra W=frb ; movb : Move frb.bitb to fra.bita ; movnb : Move not frb.bitb to fra.bita ; Arithmetics & logical ; addfl : add literal into fr ; addff : add frb into fra ; addb : add frb.bit into fra (counts 1's) ; andfl : and literal into fr ; andff : and frb into fra ; neg : negate fr ; orfl : or literal into fr ; orff : or frb into fra ; subfl : subtract literal from fr (result in fr) ; subff : subtract frb from fra (result in fra) ; subb : subtracts frb.bit from fr ; xorfl : xor literal into fr ; xorff : xor frb into fra ; Assignments ; asgaddfl : fra = frb + lit ; asgaddff : fra = frb + frc ; asgandfl : fra = frb & lit ; asgandff : fra = frb & frc ; asgiorfl : fra = frb | lit ; asgiorff : fra = frb | frc ; asgsubfl : fra = frb - lit ; asgsubff : fra = frb - frc ; asgxorfl : fra = frb ^ lit ; asgxorff : fra = frb ^ frc ; branches ; nfcall : near/far call ; nfgoto : near/far goto ; jmprw : goto PCL+W ; jmpw : goto W ; Skippers ; CSA fr,lit ; compare fr to literal and skip if above csafl macro fr,lit movlw lit^0xff addwf fr,0 btfss 3,0 endm ; CSA fra,frb ; compare fra to frb and skip if above csaff macro fra,frb movf fra,0 subwf frb,0 btfsc 3,0 endm ; CSAE fr,literal ; compare fr to literal and skip if above or equal csaefl macro fr,lit movlw lit subwf fr,0 btfss 3,0 endm ; CSAE fra,frb ; compare fra to frb and skip if above or equal csaeff macro,fra,frb movf frb,0 subwf fra,0 btfss 3,0 endm ; CSB fr,lit ; compare fr to literal abd skip if below csbfl macro fr,lit movlw lit subwf fr,0 btfsc 3,0 endm ; CSB fra,frb ; compare fra to frb and skip if below csbff macro fra,frb movf frb,0 subwf fra,0 btfsc 3,0 endm ; CSBE fr,literal ; compare fra to literal and skip if below or equal csbefl macro fr,lit movlw -(lit+1) addwf fr,0 btfsc 3,0 endm ; CSBE fra,frb ; compare fra to frb and skip if below or equal csbeff macro fra,frb movf fra,0 subwf frb,0 btfss 3,0 endm ; CSE fr,literal ; compare fr to literal and skip if equal csefl macro fr,lit movlw lit subwf fr,0 btfss 3,2 endm ; CSE fra,frb ; compare fra to frb and skip if equal cseff macro fra,frb movf frb,0 subwf fra,0 btfss 3,2 endm ; CSNE fr,literal ; compare fr to literal and skip if not equal csnefl macro fr,lit movlw lit subwf fr,0 btfsc 3,2 endm ; CSNE fra,frb ; compare fra to frb and skip if not equal csneff macro fra,frb movf frb,0 subwf fra,0 btfsc 3,2 endm ; Comparators (rely on skippers) ; CJA fr,lit,target ; compare fr to literal and jump if above cjafl macro fr,lit,target csbefl fr,lit goto target endm ; CJA fra,frb,target ; compare fra to frb and jump if above cjaff macro fra,frb,target csbeff fra,frb goto target endm ; CJAE fr,literal,target ; compare fr to literal and jump if above or equal cjaefl macro fr,lit,target csbfl fr,lit goto target endm ; CJAE fra,frb,target ; compare fra to frb and jump if above or equal cjaeff macro fra,frb,target csbff fra,frb goto target endm ; CJB fr,lit,target ; compare fr to literal abd jump if below cjbfl macro fr,lit,target csaefl fr,lit goto target endm ; CJB fra,frb,target ; compare fra to frb and jump if below cjbff macro fra,frb,target csaeff fra,frb goto target endm ; CJBE fr,literal,target ; compare fra to literal and jump if below or equal cjbefl macro fr,lit,target csafl fr,lit goto target endm ; CJBE fra,frb,target ; compare fra to frb and jump if below or equal cjbeff macro fra,frb,target csaff fra,frb goto target endm ; CJE fr,literal,target ; compare fr to literal and jump if equal cjefl macro fr,lit,target csnefl fr,lit goto target endm ; CJE fra,frb,target ; compare fra to frb and jump if equal cjeff macro fra,frb,target csneff fra,frb goto target endm ; CJNE fr,literal,target ; compare fr to literal and jump if not equal cjnefl macro fr,lit,target csefl fr,lit goto target endm ; CJNE fra,frb,target ; compare fra to frb and jump if not equal cjneff macro fra,frb,target cseff fra,frb goto target endm ; dec- increment & jump ; DJNZ fr,target ; decrement fr and jump if not zero djnz macro fr,target decfsz fr,1 goto target endm ; IJNZ fr,target ; increment fr and jump if not zero ijnz macro fr,target incfsz fr,1 goto target endm ; Bit compare jumpers ; JB Jump if bit set jb macro fr,bit,target btfsc fr,bit goto target endm ; JC Jump if Carry jc macro target btfsc 3,0 goto target endm ; JNB Jump if bit clear jnb macro fr,bit,target btfss fr,bit goto target endm ; JNC Jump if not Carry jnc macro target btfss 3,0 goto target endm ; JNZ Jump if not zero jnz macro target btfss 3,2 goto target endm ; JZ Jump if zero jz macro target btfsc 3,2 goto target endm ; Movers ; MOV fr,lit ; Move literal to fr ; Side effect: W=lit movfl macro fr,lit if lit == 0 clrf fr else movlw lit movwf fr endif endm ; MOV fra,frb ; Move frb to fra W=frb movff macro fra,frb movf frb,0 movwf fra endm ; MOVB bita,bitb ; Move bitb to bita movb macro fra, bita, frb, bitb btfss frb,bitb bcf fra,bita btfsc frb,bitb bsf fra,bita endm ; MOVB bita,!bitb ; Move not bitb to bita movnb macro fra, bita, frb, bitb btfsc frb,bitb bcf fra,bita btfss frb,bitb bsf fra,bita endm ; Arithmetics & logical ; ADD fr,#literal addfl macro fr,lit movlw lit addwf fr,1 endm ; ADD fra,frb addff macro fra,frb movf frb,0 addwf fra,1 endm ; ADDB fr,bit addb macro fr,frb,bit btfsc frb,bit incf fr,1 endm ; AND fr,literal andfl macro fr,lit movlw lit andwf fr,1 endm ; AND fra,frb andff macro fra,frb movf frb,0 andwf fra,1 endm ; NEG fr ; negate fr neg macro fr comf fr,1 incf fr,1 endm ; OR fr,literal ; or literal into fr orfl macro fr,lit movlw lit iorwf fr,1 endm ; OR fra,frb ; or frb into fra orff macro fra,frb movf frb,0 iorwf fra,1 endm ; SUB fr,literal ; subtract literal from fr subfl macro fr,lit movlw lit subwf fr,1 endm ; SUB fra,frb ; subtract frb from fra subff macro fra,frb movf frb,0 subwf fra,1 endm ; SUBB fr,bit ; subtracts bit from fr subb macro fr,frb,bit btfsc frb,bit decf fr,1 endm ; XOR fr,literal ; xor literal into fr xorfl macro fr,lit movlw lit xorwf fr,1 endm ; XOR fra,frb ; xor frb into fra xorff macro fra,frb movf frb,0 xorwf fra,1 endm ; Assignments ; asgaddfl : fra = frb + lit asgaddfl macro fra,frb,lit movf frb,0 addlw lit movwf fra endm ; asgaddff : fra = frb + frc asgaddff macro fra,frb,frc movf frc,0 addwf frb,0 movwf fra endm ; asgandfl : fra = frb & lit asgandfl macro fra,frb,lit movlw lit andwf frb,0 movwf fra endm ; asgandff : fra = frb & frc asgandff macro fra,frb,frc movf frc,0 andwf frb,0 movwf fra endm ; asgiorfl : fra = frb | lit asgiorfl macro fra,frb,lit movlw lit iorwf frb,0 movwf fra endm ; asgiorff : fra = frb | frc asgiorff macro fra,frb,frc movf frc,0 iorwf frb,0 movwf fra endm ; asgxorfl : fra = frb ^ lit asgxorfl macro fra,frb,lit movlw lit xorwf frb,0 movwf fra endm ; asgxorff : fra = frb ^ frc asgxorff macro fra,frb,frc movf frc,0 xorwf frb,0 movwf fra endm ; asgsubfl : fra = frb - lit asgsubfl macro fra,frb,lit movlw lit subwf frb,0 movwf fra endm ; asgsubff : fra = frb - frc asgsubff macro fra,frb,frc movf frc,0 subwf frb,0 movwf fra endm ; Automatic Long/Short Call ; Automatically set or clear PCLATH.3 nfcall macro target local here = $ if here < 0x800 if target > 0x7ff pclathLoad target endif else if target < 0x800 pclathLoad endif endif call target if here < 0x800 if target > 0x7ff pclathLoad here endif else if target < 0x800 pclathLoad here endif endif endm ; Automatic Long/Short goto nfgoto macro target local here = $ if here < 0x800 if target > 0x7ff bsf PCLATH,3 endif else if target < 0x800 bcf PCLATH,3 endif endif goto target endm ; Relative jump (jump [PCL+W]) jmprw macro addwf PCL,1 endm ; Indirect jump (jump [W]) jmpw macro movwf PCL endm ; End of Parallax.inc list
In message <3.0.5.32.19980916194229.00fc0220@hotmail.com>, Brian
Gracia writes:
>Does anyone have the pic source book? Is it worth getting?
It's also available on the web at:
http://www.dontronics.com/see.html
A big file, but worth its wait in gold. As Bob Blick pointed out in
another
message, the assembler is written in Parallax mnemonics. However,
I have translated it into MPASM style assembly using the following
hack:
1) assemble the code using spasm
2) Obtain the PIC disassembler from Timo Rossi:
http://www.trixatronic.co.jyu.fi/trossi/pic/
3) Compile the 12 bit PIC disassembler pic12dis.c
4) Give it the .obj file from spasm, and it gives you MPASM compatible
output!
spasm serout.src
pic12dis serout.obj > serout.raw
Edit the serout.raw file
to remove oddities and add headers.
For the Unix users out there:
p12dis serout.obj | awk '{print $3,$4;}' > serout.raw
vi serout.raw :-)
I will work on a PERL script to automate this and post it once it's done.
Enjoy!
Mark.
>Brian
--
Mark Crosbie
http://www.best.com/~mcrosbie
Hewlett-Packard MS 47 LA
mcrosbie@cup.hp.com
19447 Pruneridge Avenue
(408) 447-2308
Cupertino, CA 95014
(408) 447-6766 FAX
Subject: Re: Q: Code for simple A/D one pin 16F84? Date: Fri, 24 Jul 1998 22:13:53 +1000 From: "Paul B. Webster VK2BZC" paulb@midcoast.com.au Organization: Webster Medical Pty. Ltd. http://www.midcoast.com.au/~paulb/ To: PICLIST@MITVMA.MIT.EDU Hello James. > I've had a look at the Scott Edwards book, the section on "pot", but I > don't understand the mnemonics there. Oh dear, let me try... Untested code, review before use! ; POT ; This program shows a technique for reading resistance. The pot input ; pin can only be changed during assembly, not once the program is ; running. cblock 8 temp:1 ; Temporary counter for delay. potL:1 ; Low byte of Pot measurement. potH:1 ; High byte of Pot measurement. ; forgot mnemonic for end of cblock... #define pot ra,0 ; Pin assigned to pot. #define out_pot 0 ; Value to set ra.0 to output for pot. #define in_pot 1 ; Value to set ra.0 to input for pot. ; not sure on these: device pic16c55,xt_osc,wdt_off,protect_off reset start mov macro dest,val movlw val movwf dest,f endm djnz macro reg,dest decfsz reg,f goto dest endm org 0 start bsf status,rp0 mov ra,out_pot ; RA.0 to output. mov rb,0 ; All outputs for LEDs. bcf status,rp0 bsf pot ; Start charging cap. mov potL,8 ; Set up for 6-ms delay: 8 trips wait djnz temp,wait ; through outside loop x 256 djnz potL,wait ; x 3 cycles for inside loop = 6.1 ms. clrf potL clrf potH bsf status,rp0 mov ra,in_pot ; Get input from pot. bcf status,rp0 bcf pot ; Clear output latch for pot bit. loop btfss pot ; IF pot = 0 goto done ; THEN done bsf status,rp0 mov ra,out_pot ; Discharge cap a little. mov ra,in_pot ; Change pot pin to input. bcf status,rp0 incfsz potL ; Incerement potL. goto loop ; If zero then potL overfolowed, so incfsz potH ; increment potH. If it overflows, exit. goto loop ; Overflow? No: loop. done mov temp,2 ; Divide 16-bit number represented by div bcf status,carry ; potH and potL by 2^temp (in this case, rrf potH,f ; 2^2 or 4). This scales the pot value rrf potL,f ; to fit within an 8-bit range. djnz temp,div mov rb,potL ; Show the outcome on LEDs. goto start ; Do it again. -- Cheers, Paul B.
| Home | Products | Prices | Directory | Order | Contact | New | Books | Files | Links | Other |
mailto: don@dontronics.com_
Copyright © 1996-99 DonTronics
| Top of Page |