OK, since im not getting very many entries, Ill remove the requirement for it to be in assembly, since I think this is the biggest barrier for most people.
Not like a barrier although, but I was curious why in asm, and that too on a C++ forum?
As interesting as it is, I don't think people are taking this request seriously. That could also be the reason you aren't getting replies. I'm sure some of the grizzly people here still remember assembly, so that isn't the problem.
C++ and C . . . and C#, in a way.Not like a barrier although, but I was curious why in asm, and that too on a C++ forum?
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
My solution can play any rhythm. It can't however, do chords, or rests. (Although rests could easily be added if I am allowed a call to Sleep(), or perhaps one could play a tone outside of human hearing.)
I thought abachler's challenge was a good one, even for cboard. Leave your programming comfort zones, and give it a try.
Personally, I failed at getting nasm to assemble anything Win32 related. I finally gave up on that, and really bit the bullet, and sat down with gcc's assembler. (I greatly prefer Intel-like syntax over AT&T... oh well.) After much crashes, and me finally discovering that a semicolon doesn't actually comment a line (but doesn't give an errors...), I got one working. Although I'm still perplexed by some of the assembler that gcc generates, such as:
Why not just precompute whatever that results in, and stuff it in eax...?Code:movl $0, %eax addl $15, %eax addl $15, %eax shrl $4, %eax sall $4, %eax
My solution is attached. Should compile on Win32/x86.
long time; /* know C? */
Unprecedented performance: Nothing ever ran this slow before.
Any sufficiently advanced bug is indistinguishable from a feature.
Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
The best way to accelerate an IBM is at 9.8 m/s/s.
recursion (re - cur' - zhun) n. 1. (see recursion)
Unfortunately yours is not a solution to the original problem.
That's what makes it difficult.You can't use a table of values. You have to calculate the next
note and duration through some algorithm.
As far as the assembly contortions go, what exactly was the C code
that generated it? I don't see that in my "gcc -S" of simple program.
Generates the assembly that I'm curious about, and posted above.Code:#include <stdio.h> int main() { return 0; }
EDIT: Ok, turning up optimizations to -O2 generates more sane assembly, and precomputes it. I just wondering why gcc is doing eax = ((0 + 15 + 15) >> 4) << 4 in the first place... (other than a call to _alloc and __main, eax is never used. Even then, I'm not sure if _alloc/__main use eax... don't know the calling convention.)
Totally missed the table of values thing, so I guess not. Makes me wonder exactly how we're supposed to play a song, unless there is one specific Christmas tune that follow a mathematical equation...? Such as the one hinted earlier, but that gives values (way) too low to be audible frequencies, and durations too short to be more than a click - I'm obviously 'not getting it'. If it's pitches, relative to some starting pitch... then I need log() to make the conversion to frequency, again, breaking a rule.
Last edited by Cactus_Hugger; 01-13-2008 at 10:09 PM.
long time; /* know C? */
Unprecedented performance: Nothing ever ran this slow before.
Any sufficiently advanced bug is indistinguishable from a feature.
Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
The best way to accelerate an IBM is at 9.8 m/s/s.
recursion (re - cur' - zhun) n. 1. (see recursion)
My algorithm is fgetc()! -- or whatever you use in assembly.You cant use a table of values. You have to calculate the next note and duration through some algorithm.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
So when is this contest ending? (not that i want to participate im just curious as to how this is solved - alos looking forward to see abachlers solution )
My example? It should compile with gcc ... what errors do you get? A simple "gcc -o music.exe music.s" is all that's needed. (Of course, you obviously need Windows.)
Now... if you're using MSVC... well... no idea what its assembler is like.
dwks: My understanding was that all you could use was Beep(), so fgetc() would be against the rules.
I am also interested in abachler's solution.
long time; /* know C? */
Unprecedented performance: Nothing ever ran this slow before.
Any sufficiently advanced bug is indistinguishable from a feature.
Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
The best way to accelerate an IBM is at 9.8 m/s/s.
recursion (re - cur' - zhun) n. 1. (see recursion)