#avr | Logs for 2014-04-15

Back
[13:15:22] <megal0maniac_afk> When will AS6.2 beta stop being beta?
[14:09:44] <antto> can i clean flux residue with acetone?
[14:16:56] <Casper> probably, but flux is alcohol based, so alcohol work
[14:18:03] <megal0maniac_afk> Or paint thinners
[14:19:09] <Casper> but acetone is good
[14:26:15] <antto> i ask cuz i don't have alcohol, but i know i have nail polish remover (acetone, right?)
[17:21:14] <clOI> hello, everybody. Can a compiler write optimal code for this function: http://hastebin.com/yuviqusoso.coffee
[17:21:51] <clOI> I am wondering, because AFAIK multiplications/ divisions are executed from left to right.
[17:25:38] <clOI> I would like to the compiler to reduce this for 8MHz to a division by 8. Is the compiler allowed to do that? because if n is 0xFFFF it would first overflow and only then make the division.
[17:45:12] <Jordan_U> clOI: I expect that since all of the variables used are actually constants, known at compile time, that no divisions will be performed at all. I expect that all of that code will just be replaced with the final result, but I'm not sure of that. You can always look at the generated assembly.
[18:08:09] <Lambda_Aurigae> antto, I wouldn't use nail polish remover..that has other things in it beyond acetone..
[18:08:24] <Lambda_Aurigae> unless you get the totally unscented, non colored version.
[18:52:01] <clOI> Jordan_U: I have looked at the compiler output and apparently something like: http://hastebin.com/wequcukolu.coffee is necessary to get optimized code http://hastebin.com/deyedumide.avrasm
[19:00:12] <Jordan_U> clOI: What -o setting were you using?
[19:01:29] <clOI> my compiler flags are http://hastebin.com/jojunoyase.ini I compiled it with avr-g++ but I am very confident, that this is not c++ specific
[19:04:58] <Jordan_U> clOI: Interesting. I certainly hope there is a more readable way to get an optimized result. I'm probably one of the least experienced people in this channel, so you may want to wait for someone else to chime in.
[19:06:35] <clOI> to be honest I would have prefered if there was no loop but 6 shift command, but I can't blame the compiler because I asked it to produce small code.
[19:13:43] <clOI> btw: using #pragma GCC push_options and #pragma GCC optimize ("O3") produces shift-commands
[19:32:28] <clOI> but prevents the function from being inlined :(
[22:39:11] <allgood38> So Arduino has shown me AVR, but their build system is really limiting
[22:39:50] <allgood38> What would you do to transition from Arduino to pure AVR dev using the same boards?
[22:41:26] <kline> allgood38: firstly, work to eliminate all the arduino library calls in your old projects, like digitalWrite() -> working on ports
[22:42:02] <kline> once you have all that cruft cut out, avr-gcc acts just like regular gcc to produce binaries
[22:42:45] <allgood38> Right on, then just use avrdude to upload, yeah?
[22:43:03] <kline> you need to convert the binary to a hex file and then its just avrdude, yes
[22:43:27] <allgood38> Cool, so you still do your development with avr-gcc and avr-libc?
[22:43:41] <kline> as opposed to..?
[22:43:51] <kline> i mainly use atmel studio but it calls the same backend
[22:44:07] <allgood38> Oh! Okay, so atmel studio is using the same libraries?
[22:44:19] <allgood38> and compiler?
[22:45:06] <kline> for C(++), atmel studio comes with a copy of avr-gcc and you can also i think replace it with IARs avr toolchain
[22:46:04] <kline> i think using AS for assembly is different, ive found it uses a different syntax to what id give to avr-gcc
[22:46:41] <allgood38> So I understand why digitalWrite is bad, but what about HardwareSerial.cpp and the such
[22:48:10] <allgood38> Is there any c equivalent that isn't Arduino?
[22:49:22] <kline> just do it directly
[22:49:35] <kline> have you learned how to read the 328 datasheet yet?
[22:50:29] <allgood38> Sort of, I haven't really dug into it, but I've done memory access to uarts before to make them print things
[22:50:47] <allgood38> The atmel atmega328p yeah?
[22:54:46] <kline> yeah
[22:55:31] <kline> do you know C at all already? for pcs etc
[22:56:10] <allgood38> Yeah
[22:56:23] <kline> https://github.com/AbstractBeliefs/bavrf/blob/master/bavrf/bavrf.c
[22:57:27] <kline> all of the hard stuff for getting uarts going is line 114+
[22:58:52] <allgood38> Okay, cool, and symbols like UCSR0B, are they defined in an avr header file?
[22:59:02] <allgood38> Thanks for the link!
[23:01:29] <kline> all the weird symbols come in from avr/io.h which loads in the file appropriate for your targeted device at compile time
[23:12:07] <allgood38> Any idea where io.h would be stored on a linux system? I'm looking at /usr/lib/gcc/...avr/include
[23:13:05] <allgood38> Ah, of course now I find it after asking
[23:16:12] <Casper> of course