a
And that's how I expected it to be!
Meindert
a
And that's how I expected it to be!
Meindert
What version of C18 are you using and what is your target device?
-- Joe Chisolm Marble Falls, Tx.
When combined with another arithmetic operation, they're free!
IIRC gcc for both msp430 and H300 does byte/word operations instead of shifts as well.
Though it does look a bit odd at first glance. ;)
-- Grant Edwards grant.b.edwards Yow! You can't hurt me!! at I have an ASSUMABLE
In my experience, "yuck!" is what anybody trying to use C on a PIC ought to expect. [IMO, "yuck!" is what you get using asm on a PIC as well, but that's probably a little more subjective.]
-- Grant Edwards grant.b.edwards Yow! Loni Anderson's hair at should be LEGALIZED!!
Yes. It seems that recent versions of GCC do some interesting shift optimizations ... which is revising upward my opinion of GCC (which I've only ever considered an adequate compiler).
I've worked with a number of older versions of GCC and with Intel, Microsoft and Sun compilers over the years. What I would normally expect to see from a good compiler is: - if the source value and the shift count can be statically determined, I expect the compiler to compute the result and inline it, - otherwise I expect to see the shift essentially as coded.
Good compilers can often statically determine the values through value tracking and/or constant propagation, so under high optimization it isn't unusual to see something like
unsigned short get_middle( unsigned long ul ) { return ((ul >> 8) & 0xFFFF); }
: unsigned short bleh; unsigned long blah = 0xBABE; : blah |= (0xCAFE
The lates (V3.35), just downloaded from the Microchip website and the target is an 18F8720.
Meindert
"Yuck" is what you get when using a PIC at all..... Whoever designed this architecture should be crucified!!
Meindert
Yes, and they are laughing all the way to the bank.
Not bad for a "Yuck" design.
hamilton
Here's the assembler that CC8E generates from:
void main(void) { uns32 addr; LATF = addr >> 16; }
; CC8E Version 1.3D, Copyright (c) B Knudsen Data ; C compiler for the PIC18 microcontrollers ; ************ 9. Jun 2010 14:47 *************
; NOTE: demo edition, assembly is NOT complete.
processor PIC18F6310 radix DEC
LATF EQU 0xF8E addr EQU 0x00
GOTO main
; FILE cc8e_test.c ;void main(void) ;{ main ; uns32 addr; ; LATF = addr >> 16; MOVF addr+2,W,0 MOVWF LATF,0 ;} SLEEP RESET
END
; *** KEY INFO ***
; 0x000004 4 word(s) 0 % : main
; RAM usage: 4 bytes (4 local), 764 bytes free ; Maximum call level: 0 ; Total of 6 code words (0 %)
Even simpler, the following generates the same assembler code.
void main(void) { uns32 addr; LATF = addr.midH8; }
With CC8E you can easily address individual bytes and bits within larger variables (see above)
Richard
Had you seen the *original* PICs (General Instruments) *and* compared them to what was available from other vendors at the time, you would have found it amusing: "Is this a joke? You know, one of those April Fool's Day bogus advertisements?" (I had a similar reaction when Motogorilla later introduced their *one* bit "ICU")
I think the original PICs had 1K of CODE and maybe 32 bytes of "RAM" (registers) -- Harvard Architecture. GI was heavy into making cable converter boxes back then. I think you'd be hard pressed to make a four function *calculator* with one of those!! :-/
A shame, actually, that it survived where many other "better" designs slipped by the wayside...
[I think I need to go rummage through old databooks to see what I've culled over the years]
PIC: The Microsoft of the embedded world.
(eg: great marketing, lousy architecture :-))
Even as a hobbyist I rejected it in favour of the HC08 when I started out (I was looking for something with USB device in a PDIP when I started), even though I knew the PIC to be more popular for hobbyist work.
(For the record, I outgrew the HC08 and moved to AVRs which is a move I have not regretted, but it would be nice to have USB device in a AVR PDIP).
Years later, I cannot remember what I disliked most about the PIC; my lasting memory is more of coming away from reviewing it and never wanting to go near it again. :-)
Simon.
-- Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP Microsoft: Bringing you 1980's technology to a 21st century world
-- Rich Webb Norfolk, VA
Great customer support. Microchip has consistently supported their customers. A couple phone calls and even when parts are in short supply they will find some.
w..
I agree, Microchip wasn't my first choice for the architecture, the 18 series and up are better, but you can't deny the availability of tools and I have to say that Microchip has been very responsive when I have a problem. Motorola/Freescale on the other hand was a NIGHTMARE to deal with and we bought a butt load of 6805/68HC05 and HC11 stuff from them. A good cross compiler hides a LOT of the PIC uglies. :)
Jim
It is about great support not great marketing. Engineers doing design aren't long fooled by marketing.
Microsoft worked hard (and illegally, it turned out) to control market channels and sells into what is basically a broad-based, largely ignorant marketplace. Microchip sells to well-informed engineers and so far as I'm aware hasn't acted to force illegal contract terms onto distributers.
Microchip simply supports their customers well and that counts for something with engineers in the end.
You reminded me that I started out with the Hitatchi H8/300 before I even saw a PIC. One thing I really liked about it was the ability to custom wire a socket up so that I could drop the part into a bog standard EPROM writer socket and program the code into it. Besides a great instruction set, it was wonderful that way for me. No specialized hardware that I couldn't afford, that way, so I was able to cheaply program it. Nice. Still.... Microchip supports their customers.
Use what works for you. I have to say that I found the AVR both excellent to work with on the first instrument I ever developed (it used the AT90S2313 (memory serving).) But the instruction set isn't by any means 'wonderful.' (I coded the application entirely in assembly.) There are some design decisions there that I considered 'poor,' even under the circumstances. Extra work to carefully craft around them, but the chip worked extremely well so I really had no complaints at all about the experience. More, I actually wrote quite a glowing report about the project here in this group at the time because the documentation and chip worked as advertised.
The support from Atmel was far, far inferior to what I later received from Microchip, though. Microchip's support is so much better that they aren't even in the same universe. And so long as they field parts meeting needs, I use them. I'm NOT using them in a current project and the part I am using comes from a company that doesn't support it's products nearly as well. But that's because Microchip's parts don't qualify here and the other company's does extremely well for the purpose.
Have you programmed an 8051 core?
Anyway, the business of selecting parts is a lot more than some instruction set. In fact, to me the instruction set counts for roughly zero of my consideration. So long as it includes the basics required for doing computations and conditional code, I don't look much further there. And customer requirements never seem to impose instruction set considerations so that is that.
Jon
On Jun 10, 4:44=A0am, D Yuniskis > Had you seen the *original* PICs (General Instruments) *and*
Does anyone know someone who actually _used_ that one-bit ICU ? [MC14500B]
I remember doing a CPLD version, as a teaching exercise.
I see there is even an opencores page (no code yet)
-jg
Hi Jim,
-jg wrote:
Dunno. I recall the small *red* pamphlet. Looked like someone had invested *just* enough effort to make a good April Fool's Joke out of the thing (like Signetics' WOM... I particularly liked the 2% tolerance on Vdd :> )
(sigh) No more clever hackers. :<
Not bad indeed. 6 billion microcontrollers shipped. The latest financial report says they are close to 950K development systems. They shipped 45,000 this last quarter alone. Record revenues and dividend increased to 34.2c/share. Plus now I can order small qty parts pre-programmed. One time setup fee of $60 and something like
10 or 20 cents per part to program. Just like any other microcontroller the PIC series have a sweet spot for solving particular problems. If your requirements are to run a full blow RTOS or Linux then dont spec a PIC.Frankly I dont worry too much about the compiler. I can spend my time in better ways. If I'm so code size constrained that I'm worried about the compiler using 8 instructions instead of 4, or performance constrained that looping 16 times is a killer, then code the function in asm, spend the big bucks for a different compiler or choose a different microcontroller. Hell, the X86 architecture sucks but it aint going away any time soon.
I've done several projects using a PIC. My current project wont be a PIC, the PIC is not a correct fit for the problem set. The next project on the horizon probably will be a PIC, different set of requirements.
-- Joe Chisolm Marble Falls, Tx.
I'm not sure I agree here. A huge percentage of Microchip's user base are /uninformed/ engineers. People pick Microchip and PICs because that's the microcontroller they've heard of. When you are looking for your first microcontroller, you don't know much about a company's support - you probably don't even /think/ about support until later on when you are having problems.
Microchip have made a very strong commitment to marketing their devices to small users - hobby users, students, small companies, and other first-time microcontroller users. That's how they get their customers - companies pick them because their developers are already familiar with the devices from their hobby days.
Great support is how Microchip /keep/ their customers. Great marketing, especially aimed at small users, is how they get the customers in the first place.
My first commercial product was based on the Z80. After that I did a lot of stuff with 8051's and at a certain point I needed something faster and explored the AVR. The instruction set gave me a dejà vu feeling of the Z80 era and I like it. Part of that project was done in assembly for speed reasons and it worked like a charm. When I now look at the assembly of the PIC, I just can't get my head around it to understand what is happening, the acronyms used are so far off of my 'gut feeling' and that is important to me. Reading AVR assembler to me is so much more 'logical' than PIC assembly. Though my first commercial PIC project was built around a 12C508 and it comprised a whopping 25 words of assemly code. For that project, I loved that PIC! But looking at an 18F8720 capable of addressing 2M of program memory, I simply cannot understand why RAM is stil accessed in 256 byte banks.... Yuck again!!
Meindert
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.