Well this is a new twist on the old debate. I've never seen reinforcements brought in from other forums. how exciting!so it's playing out like post #3 after all...
Well this is a new twist on the old debate. I've never seen reinforcements brought in from other forums. how exciting!so it's playing out like post #3 after all...
It is kind of containing the crisis. As long as it does not spread out into other threads?Well this is a new twist on the old debate. I've never seen reinforcements brought in from other forums. how exciting!
Awaken the Troll army! Hmm, or is the Anti-Troll army?Well this is a new twist on the old debate. I've never seen reinforcements brought in from other forums. how exciting!
I'm afraid I did not enjoy a very welcoming experience.I would welcome really replies containing things like "I used assembler for this and that, and my experience was...".
I think Nigel Goodwin from Electro-Tech is disturbing too.I think you behavior is disturbing
unsigned char get_b(const char* a,unsigned char idx)
{
ab=a;
ab0=ab;
ab1=ab>>8;
STATUS=0;
ab2=idx;
#asm
GLOBAL _ab,_ab0,_ab1,_ab2,_x
MOVF (_ab0),W
movwf 0x0a
movf (_ab1),W
MOVWF 0x0b
call 0xf1
movwf (_x)
movf (_x),W
movwf 0x0a
movf (_ab2),W
addwf 0x0a,f
movf (_ab1),w
movwf 0x0b
call 0xf1
movwf _x
#endasm
return(x);
}
That's what I do. I wasn't going to get involved in the discussion but IMHO you nailed it! I use C when I think its appropriate. But I also have a standardized .asm framework for PICs that I can get out and populate with tried and true, compact and fast code using macros and libraries. Its just my thing. I work mostly in 8 bit PIC. While I've done a bunch of C on the 18F and XC8 looks OK, I don't think any of the 8bit PICs are a particularly good C platform.If you build up a library of standard subroutines and macros assembler is as easy as C.
I respect that as your opinion.That's what I do. I wasn't going to get involved in the discussion but IMHO you nailed it! I use C when I think its appropriate. But I also have a standardized .asm framework for PICs that I can get out and populate with tried and true, compact and fast code using macros and libraries. Its just my thing. I work mostly in 8 bit PIC. While I've done a bunch of C on the 18F and XC8 looks OK, I don't think any of the 8bit PICs are a particularly good C platform.
I respect yours as well. We are all products of our training, temperament and experience. Myself, I've had lots of all of it. So in the spirit of exchange, let me pick at some things in your reply. (Apologies to those in the previous 10 pages if its already been pointed out).I respect that as your opinion.
This should be printed on page 1 of every compiler manual! Knowing something about compiler design helps but when starting a new compiler, I ALWAYS run some test code with standard constructs to see how the compiler generates the target code. Off the top of my head, I can tell you that PICC-18 (HiTECH- my version anyway) makes way better code when:C can be "played", for instance in terms of optimization, both for program space, and speed. Normally this is neither difficult, nor takes long time.
The same way you do it in C or any other language, with structured/modular programming. One task, one routine. Small files. I had to visit a project today so did some looking at how I did it. The project had 112 source files. Each file (or small group of files) had code that performed some specific function. Each function was well defined i.e. read the ADC, give me degC and flag if its valid. The project is large with lots of functionality but when I need to change/update something (we recently replaced the external ADC with another) its a few changes in a file and everyone else doesn't know the difference. Easy.You can optimize assembler this is correct, and it might be faster than C code. Depending on the complexity, it will be stretching over 3 to 5 pages, or more. How can you try new ideas on such a source, and change it within a few minutes?
You are kind of making my point here. Properly written .asm code can take advantage of knowing where things are at build-time. The result is that you can set the banks ONCE for each routine, then have at it. Your compiled example has to set RP1/0 then do the bit shift. Once I'm located in the bank, I can run wild until its time to exit without having to take time/space to maintain RPx. (or IRP for that matter).Since I use C code that is geared towards PIC architecture, there won't be so much difference to assembler. If I use a one-bit shift, or by-one increment, and exploit this in the so-called "inner loop" to do things, the C compiler only sets banking bits, and does the shift. Not much else!
I have 16-24-32 bit fixed point libs for the 16xxx stuff. For the 18F, all of the same plus IEEE-754 floating point on the 18F. Since the 18F has lots more memory, I also have macros that do simple math inline. I fully appreciate your position though.. Its a beating and sometimes, I DO envy the C guys. But when I gets that far.. I really envy the ARM guys..What I particulary like about using C on 8-bit PICs is the fact you can use 16bit variables, if you need it, and the resulting lengthy assembler code is hidden...so to say.
One of the many reasons I don't use the 16xxx any more. The 18F is far superior in every way. Its hard to get this point across sometimes. Maybe its the 'simple to learn 33 instructions' thing. Personally, I kind of like advanced computer-science methods like add-with-carry and.. watch out now.. hardware multiply. Multiple FSRs that span addressable RAM, with auto-inc/dec.. please! I can't take it. But, after 150+ 10xx/12xx/15xx/16xx/17xx deliveries, I don't accept any new 8-bit PIC projects that are not 18F based unless there is a VERY compelling reason to do so.If you have the right banking bits set + a FSR available. But that is often not the case when coding some algorithm that needs the FSR + sets banking bits for own purposes. Reloading the same / buffering the FSRs results in lengthy, messy assembler code, can improve speed but is bad to maintain.
Sure. While you (and I) can write C for PIC and deliver projects, none of the 8 bit PICs have a real addressable stack. The RAM is banked. In the 16xx, the ROM is banked with 8 louzy call levels to boot. C is a stack-based language that expects linear address spaces so the compiler authors have to improvise, and do things like adding banking instructions. And banked ROM/RAM means that the compiled code will likely contain unnecessary bank flips because where things are is not known at compile-time and the linker (which DOES know) can't re-jigger the code after compilation. Its not a knock on the compiler guys, they do a good job with what they have to work with. But if you push it, you may get to the point where you are fresh out of PIC. Personally, over the years, I've run out of all of it.. ROM, RAM and Tcycs (in assembler, too). For me, that gets expensive.. fast. But in assembler, I can streamline, localize and optimize far better than any PIC compiler to date, even XC8.I don't think any of the 8bit PICs are a particularly good C platform.
by Jake Hertz
by Aaron Carman