[sdiy] Quick C query
cheater cheater
cheater00 at gmail.com
Sun Nov 21 19:38:52 CET 2010
On Sun, Nov 21, 2010 at 19:13, Tom Wiltshire <tom at electricdruid.net> wrote:
>
> On 21 Nov 2010, at 18:05, Steff wrote:
>
>> On 21 November 2010 17:45, cheater cheater <cheater00 at gmail.com> wrote:
>>>
>>>> if(flags == (BLARP | BAR)) { /* do stuff here */ }
>>>
>>> I think you mean:
>>>
>>> if(flags & (A | B) == (A | B)) {
>>> ...
>>> }
>
> I've seen this written as:
>
> if (flags & (A | B)) {
> ...
> }
>
> Which would be the following for a single flag:
>
> if (flags & mask) {
> ...
> }
>
> There's no need for the part with the "==(etc)", since C is just looking for a non-zero result to indicate true (simply processor zero flag clear, I hope).
>
> Or have I got the stick by the sticky end?
if(flags & (A | B))
is different from
if(flags & (A | B) == (A | B))
in that the first will be active when either A or B are set in flags,
whereas the second will trigger only when A and B are set in the
flags. This is what Steff's original post did. So I guess you got the
sticky end this time, but not to worry! ;-)
If you're unhappy about the maintainability of your assembler code,
try using a high level assembler such as something like this:
http://web.mac.com/randyhyde/HighLevelAsm/WinDownload.html
"HLA can operate in one of several modes. In the standard mode (under
Windows) it converts an HLA source file directly into an object file
like most assemblers. In other modes, it has the ability to translate
HLA source code into another source form that is compatible with
several other assemblers, such as MASM, TASM, FASM, and Gas."
Whether or not it will support your architecture I don't know - maybe
- but it's a starting point.
One other option is to use the wealth of Haskell DSL's (domain
specific languages) that put out assembly. Haskell is fairly easy to
learn due to the wealth of very good books around
(learnyouahaskell.com is one you can access for free) and a very
strong community which includes some of the core developers.
Cheers,
D.
> T.
>
> _______________________________________________
> Synth-diy mailing list
> Synth-diy at dropmix.xs4all.nl
> http://dropmix.xs4all.nl/mailman/listinfo/synth-diy
>
More information about the Synth-diy
mailing list