#avr Logs

Oct 11 2019

#avr Calendar

12:01 AM day__ is now known as day
01:00 AM eichiro_ is now known as eichiro
06:38 AM vmt: --
07:06 AM djph: vmt: error: -- : command not found.
07:15 AM polprog: :{:|:&}:
07:25 AM vmt: polprog and rue_mohr that c-snippet on twitter with the switch statement jumping directly into a loop was quite clever
07:25 AM skz81: fork like a smell bomb !
07:27 AM skz81: "stink ball", ok forget my french joke -_-'
07:27 AM polprog: heh, yeah vmt . its crazy
07:31 AM vmt: though the thing rue posted the if(0) is just annoying noise
07:32 AM djph: polprog: error: you're a dick
07:33 AM djph: polprog: also you missed a ';'
07:37 AM cehteh: o/
07:38 AM djph: heyo cehteh
07:38 AM cehteh: hah rue_mohr on twitter? :D ... rue_mohr as you may already thought that drill bit is for tapered holes
07:39 AM cehteh: can be used for wood plugs (likely) or for pilot holes for screws
07:40 AM cehteh: https://www.fine-tools.com/konischebohrer.html the screw ones are smaller
07:41 AM djph: taper-drills suck
07:57 AM cehteh: sometimes you need them
07:58 AM vmt: rue is 10 times more coherent on twitter than on irc
07:58 AM vmt: you can *actually* understand what he's saying
07:58 AM cehteh: lol
07:59 AM cehteh: what c-snippet where you talking about?
07:59 AM cehteh: that made me curious
08:01 AM vmt: well the gist is that a switch statement hops into a loop bypassing the initialization
08:01 AM vmt: as in:
08:02 AM vmt: int i = 10; switch(1) { for(; i>0;i--) { case 1: //whatever; }}
08:03 AM vmt: but you can generalize that to other things too, e.g. you can have: switch(1) { if(0) { case 1: printf("foo\n"); }}
08:04 AM cehteh: ah yes some c oddity that you can do that
08:05 AM cehteh: related to duffs device
08:05 AM vmt: yeah because it jumps to the label
08:05 AM vmt: well, "jumps"
08:05 AM cehteh: many compilers nowadays can at least warn about when you skip an initialization
08:06 AM vmt: yeah at least with -Wall or whatever clang's alternative is
08:06 AM cehteh: once these things where performance hacks when the compilers didnt optimize well
08:06 AM vmt: heh
08:06 AM cehteh: nowadays thats pretty counterproductive
08:07 AM vmt: yeah and very clunky to read
08:07 AM vmt: though well it's really related to how you treat switch statements to... subjective
08:07 AM vmt: so*
08:07 AM cehteh: there is an almost 1:1 relation from C to ASM .. but thats very unoptimized, when you do that with a modern compiler you rather confuse its optimization code/heuristics
08:08 AM polprog: djph: lol right
08:08 AM cehteh: and yes readability sux
08:08 AM polprog: [14:52] vmt: rue is 10 times more coherent on twitter than on irc
08:08 AM vmt: keyword almost
08:08 AM polprog: haha
08:08 AM vmt: well it's true:(
08:11 AM djph: cehteh: yeah, "sometimes". But I can still hate them :)
08:15 AM polprog: cehteh: someone once said " your computer is not a fast pdp11 anymore"
08:15 AM polprog: apropos c 1:1 to asm
08:20 AM polprog: someday that statement will not be true for myself
08:20 AM polprog: or so i hope
08:24 AM cehteh: it isnt true anymore, that was once (in the 70's) the way you used C
08:24 AM cehteh: maybe tcc compiles like that :D
08:27 AM cehteh: ah no even tcc does some more abstraction
08:37 AM rue_bed: polprog, :)
08:38 AM rue_bed: the if(0) is the same trick (ish)
08:38 AM vmt: rue_bed: but in your snippet it does nothing
08:39 AM rue_bed: the case trick can also be used to do trickey iniialization
08:40 AM rue_bed: vmt, the if(0) IN the loop is to keep the loop from running the contents of the if, the case till still jump to it
08:41 AM vmt: yes but in your case it does nothing
08:41 AM rue_bed: the if(0) in the first post does do something if you change... j? I dont remember how I wrote it
08:41 AM vmt: sure
08:42 AM rue_bed: whitequark brought it all up tho
08:42 AM vmt: don't know him
08:42 AM rue_mohr: her
08:42 AM djph: it
08:43 AM Fuchikoma: Why not just use a GOTO for something like that. Seems like it'd be simpler.
08:43 AM vmt: from the looks of it, seems like a weeaboo who's very confused as to what his penis is for
08:43 AM rue_mohr: becasue with case, you can change the initialization in ways that nobody would normally use
08:44 AM vmt: if i was a betting man i'd put $5 on him being a, he
08:44 AM rue_mohr: I know whitequark outputs lots of code
08:44 AM rue_mohr: for a lot of interesting things
08:44 AM rue_mohr: past that, I dont care
08:44 AM Fuchikoma: Can you invert case evaluations though? :D
08:45 AM rue_mohr: do tell, I need a shower and breakfast...
08:45 AM Fuchikoma: switch (true) case (expression to evaluate) case (expression to evaluate) ...
08:47 AM vmt: Fuchikoma: wat
08:48 AM Fuchikoma: A very naughty thing VisualBasic lets you get away with
08:48 AM vmt: yes but i didn't follow what you meant by inversion
08:48 AM cehteh: case labels in C must be constant integer expressions
08:48 AM vmt: ^this
08:49 AM Fuchikoma: Meh :)
09:13 AM polprog: Fuchikoma: because gotos are evil and break code paths
09:13 AM polprog: while that.. lets pretend it doesnt exiat
09:13 AM polprog: its evil, but the black magic kind of evil
09:13 AM polprog: forbidden C
09:13 AM polprog: lol
09:13 AM polprog: :^)
09:16 AM Fuchikoma: It shouldn't break code paths unless you're a dingus who jumps to labels in other files
09:18 AM cehteh: now i know why you code in asm ...
09:19 AM cehteh: bewcause you dont know C :D
09:21 AM polprog: haha
09:21 AM polprog: i dont think i ever had to use goto irl
09:21 AM polprog: also most of my c experience is avr
09:22 AM polprog: and thats like , small c programs
09:22 AM polprog: at work i was writing osdp implementation in c, ill publish it later
09:23 AM cehteh: type foo = initalize_foo(); if (!valid(foo)) goto error_out; .... is pretty ok imo
09:23 AM LeoNerd: Using `goto` in C for things like error/cleanup handling is quite common, and can be done neatly
09:23 AM rue_mohr: back
09:23 AM cehteh: this 'avoid goto on all costs' sux
09:24 AM rue_mohr: I should post the two examples, I think i ahve them
09:24 AM cehteh: whatever reduces one indentation level is often a good idea
09:24 AM rue_mohr: http://paste.debian.net/1105869/
09:25 AM rue_mohr: http://paste.debian.net/1105870/
09:25 AM rue_mohr: the twitter ones were rewritten to fit twitter
09:26 AM cehteh: rue_bed: not everything thats possible is a good idea :D
09:26 AM Kliment: I have used goto in timing-sensitive things
09:26 AM Kliment: to jump to the nop before a loop
09:26 AM rue_mohr: I agree
09:27 AM rue_mohr: those only came up because of a comment by whitequark
09:27 AM polprog: hmm, how does comparing a multichar constant work?
09:27 AM polprog: in switch(c)
09:27 AM Kliment: polprog: badly
09:27 AM rue_mohr: and that little voice in my mind that digs at things it should leave alone
09:27 AM rue_mohr: its valid
09:28 AM rue_mohr: so is unsigned long 'help'
09:28 AM rue_mohr: AND if your comparing, its faster
09:28 AM cehteh: ist just taken as integer .. iirc implementation defined in C better avoid it, non standard c
09:28 AM polprog: that little voice told me today "go make an ascii art colorizing perl script"
09:28 AM rue_mohr: cause its just an integer compare, not a string compare
09:28 AM polprog: right. i was thinking its sth like that
09:28 AM rue_mohr: I used it on that irc controlled bot
09:29 AM rue_mohr: there is the other evil too
09:29 AM rue_mohr: using , in if's
09:30 AM polprog: oh yeah
09:30 AM rue_mohr: if (c=a+b, d!=0) {
09:30 AM polprog: , is a cool operator
09:30 AM rue_mohr: the c=a+b will be executed, but not used for the condition
09:31 AM polprog: hmm i wonder if you coule use it instead of ; in some cases... thinga(), thingb();
09:31 AM polprog: like, not in an if or anything
09:31 AM polprog: also useful for fors iirc
09:32 AM rue_mohr: I'v done...
09:32 AM cehteh: it sux somewhat that you cant switch on pointers
09:32 AM cehteh: char* foo... ; switch(foo) { case "bar": ...
09:33 AM polprog: hmm, you could cast the pointer to an int
09:33 AM polprog: nasty but works
09:33 AM rue_mohr: for(d = 1, b = BITSIZE-1; d < nn; d <<= 1, b-- ) {
09:33 AM rue_mohr: in my fft code
09:33 AM polprog: aahh like that
09:33 AM polprog: nvm
09:33 AM cehteh: yes its pretty sane and you can cast to intptr_t then it works, its just cosmetics
09:33 AM cehteh: would be nicer when it works
09:34 AM Fuchikoma: Just sayin' none of this is really an issue programming in assembly :D
09:34 AM rue_mohr: for(i = (nn-1), j = 0; j != (nn-1); i += (d << 1) ) {
09:34 AM cehteh: of course you need to be aware that it compares pointers not strings
09:34 AM rue_mohr: that fourier code got really intersting
09:34 AM rue_mohr: for ( i = 0; i < nn; printf("%6.2f \n", sqrt((real[i]*real[i])+(imag[i]*imag[i]))), i++);
09:41 AM rue_mohr: totally late to leave for work....
09:42 AM rue_mohr: so I kinda moved to twitter cause irc died
09:42 AM rue_mohr: hello?..... hellloooooo?
09:47 AM Fuchikoma: I think you're okay
09:51 AM cehteh: twitter will die as well
10:47 AM skz81: rue_mohr, the last for with the printf is just ... EPIC ^^
10:49 AM skz81: polprog, works... Till you're comparing pointers to the same string constant, which is totally not ensured
11:40 AM Jessikka: Hi, does anyone know if it's possible to get avr-gdb to display the contents of the flash ROM? When I try to use the x command it adds 0x800000 to the address I specify.
12:03 PM Fuchikoma: You can dump the program rom separately
12:04 PM Fuchikoma: I don't know anything about avr-gdb, maybe you can specify which memory space to access?
12:04 PM cehteh: i never ever used gdb on avr's .. too much trouble
12:05 PM cehteh: build debug code in your app then you even get consistent timing
12:05 PM djph: I use dbl -> debug by led
12:06 PM djph: *dbbl
12:06 PM cehteh: dbbp
12:06 PM Fuchikoma: Just write code that works properly the first time. How hard could it be? :D
12:06 PM cehteh: exactly
12:06 PM cehteh: also gdb isnt so much help for many bugs imo
12:07 PM cehteh: snr is way too low
12:07 PM Jessikka: Oh I'm not debugging, I'm checking the output of the compiler to see if it matches what I expect.
12:07 PM cehteh: huh why dont you just dump the asm then?
12:07 PM Fuchikoma: ^
12:08 PM Fuchikoma: AVRdude dump the rom and optionally disassemble
12:08 PM cehteh: %.asm: %.elf OBJDUMP.d_b
12:08 PM cehteh: $(PRINTFMT) $@ ASM
12:08 PM cehteh: $(OBJDUMP) -S $< >$@
12:08 PM cehteh: from my makefile
12:09 PM Fuchikoma: ...or if it's code you wrote and compiled you can do that too
12:09 PM Jessikka: Yeah that's probably easier. gdb was just the first thing I thought of and then I ran into that issue and I just wanted to see if there was a way around it. By the sounds of it though, there is not. I'll just add a build target to output assembly instead. Thanks.
12:12 PM cehteh: and when you use -lto then the assember output becomes pretty much unreadable :D
08:55 PM rue_bed: I have it in my avr howto
08:57 PM rue_bed: thanks skz81, hope to see you gain
08:57 PM rue_bed: aain
08:57 PM rue_bed: ;lkdsajfl;skdjfl
09:15 PM rue_mohr: well said
11:59 PM day__ is now known as day