diff --git a/HISTORY.md b/HISTORY.md index 34644df..cf902e3 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -7,7 +7,7 @@ History of SixtyPical * Split TODO off into own file. * `sixtypical` no longer writes the compiled binary to standard output. The `--output` command-line argument should be given. -* Many tests pass when `sixtypical` is run with Python 3. +* All tests pass when `sixtypical` is run under Python 3.5.2. 0.16 ---- diff --git a/src/sixtypical/fallthru.py b/src/sixtypical/fallthru.py index 85024bd..995fbcf 100644 --- a/src/sixtypical/fallthru.py +++ b/src/sixtypical/fallthru.py @@ -43,7 +43,7 @@ class FallthruAnalyzer(object): while pending_routines: chains = [self.find_chain(k, pending_routines) for k in pending_routines.keys()] - chains.sort(key=len, reverse=True) + chains.sort(key=lambda x: (len(x), str(x)), reverse=True) c = chains[0] roster.append(c) for k in c: diff --git a/tests/SixtyPical Fallthru.md b/tests/SixtyPical Fallthru.md index 2a0981c..75e3779 100644 --- a/tests/SixtyPical Fallthru.md +++ b/tests/SixtyPical Fallthru.md @@ -174,8 +174,8 @@ fall through to the other. = "main" = ], = [ - = "bar", - = "foo" + = "foo", + = "bar" = ] = ] @@ -206,10 +206,10 @@ routine. = "main" = ], = [ - = "bar" + = "foo" = ], = [ - = "foo" + = "bar" = ] = ] @@ -271,10 +271,10 @@ because we don't necessarily know what actual routine the vector contains. = "main" = ], = [ - = "bar" + = "foo" = ], = [ - = "foo" + = "bar" = ] = ] @@ -416,12 +416,12 @@ in the "true" branch is a `goto`. | { | } = $080D RTS - = $080E LDA #$FF - = $0810 RTS - = $0811 LDA #$00 - = $0813 BNE $081D - = $0815 LDA #$01 - = $0817 JMP $080E - = $081A JMP $0822 - = $081D LDA #$02 - = $081F JMP $080D + = $080E LDA #$00 + = $0810 BNE $081A + = $0812 LDA #$01 + = $0814 JMP $081F + = $0817 JMP $081F + = $081A LDA #$02 + = $081C JMP $080D + = $081F LDA #$FF + = $0821 RTS