From: Mith on 16 Jun 2010 17:35 I'm converting assembly code to C and there is a lot of branches/jumps (it is a big state machine). When rewriting the different states would you use the goto keyword or try to rewwrite all with if, if-else?
From: Rob Gaddi on 16 Jun 2010 18:04 On 6/16/2010 2:35 PM, Mith wrote: > I'm converting assembly code to C and there is a lot of branches/jumps (it > is a big state machine). > > When rewriting the different states would you use the goto keyword or try to > rewwrite all with if, if-else? > > That depends, what's the point of the exercise? -- Rob Gaddi, Highland Technology Email address is currently out of order
From: tim.... on 16 Jun 2010 18:08 "Mith" <mith(a)no.no> wrote in message news:4c1943ba$0$286$14726298(a)news.sunsite.dk... > I'm converting assembly code to C and there is a lot of branches/jumps (it > is a big state machine). > > When rewriting the different states would you use the goto keyword or try > to rewwrite all with if, if-else? or even with Switch/case stetments perhaps? tim
From: Grant Edwards on 16 Jun 2010 18:21 On 2010-06-16, Mith <mith(a)no.no> wrote: > I'm converting assembly code to C and there is a lot of branches/jumps (it > is a big state machine). > > When rewriting the different states would you use the goto keyword or try to > rewwrite all with if, if-else? Since you're doing a state machine, it sounds like a "switch" statement (or even nested switch statements) is probably a better option. You're probably better off reverse-engineering the state machine, then coding it from scratch in C. -- Grant Edwards grant.b.edwards Yow! I love ROCK 'N ROLL! at I memorized the all WORDS gmail.com to "WIPE-OUT" in 1965!!
From: Tim Wescott on 16 Jun 2010 18:22 On 06/16/2010 02:35 PM, Mith wrote: > I'm converting assembly code to C and there is a lot of branches/jumps (it > is a big state machine). > > When rewriting the different states would you use the goto keyword or try to > rewwrite all with if, if-else? Would I be in a hurry? Would I be doing this for a once-off prototype or a product that has to work for years? How many other people (including me, later) would have to read and understand the code? With all the time in the world and a need to do it "right", I'd reverse-engineer the assembly back to a detailed specification, then I'd write code to that. -- Tim Wescott Control system and signal processing consulting www.wescottdesign.com
|
Next
|
Last
Pages: 1 2 3 Prev: Display protection/longevity Next: Press Release - Ada-Europe launches Programming Contest |