diff --git a/README.markdown b/README.markdown index 0863140..7d3ed32 100644 --- a/README.markdown +++ b/README.markdown @@ -50,7 +50,7 @@ certain ways. For example, these are illegal: ### Abstract Interpretation ### SixtyPical tries to prevent the program from using data that has no meaning. -For example, the following is illegal: +For example, the following: routine do_it { lda #0 @@ -58,7 +58,7 @@ For example, the following is illegal: sta vic_border_colour ; uh... what do we know about reg A here? } -...*unless* one of the following is true: +...is illegal *unless* one of the following is true: * the A register is declared to be a meaningful output of `update_score` * `update_score` was determined to not change the value of the A register @@ -183,4 +183,4 @@ TODO * `jsr (vector)` * `jmp routine` * insist on EOL after each instruction. need spacesWOEOL production -* `copy immediate word` +* asl .a diff --git a/doc/Analyzing.markdown b/doc/Analyzing.markdown new file mode 100644 index 0000000..b3bf2ec --- /dev/null +++ b/doc/Analyzing.markdown @@ -0,0 +1,41 @@ +Anayzling SixtyPical Programs +============================= + + -> Tests for functionality "Analyze SixtyPical program" + + -> Functionality "Analyze SixtyPical program" is implemented by + -> shell command "bin/sixtypical analyze %(test-file)" + +A routine cannot expect registers which a called routine does not +preserve, to be preserved. + + | assign byte border_colour 4000 + | reserve byte score + | routine update_score + | { + | lda #8 + | sta score + | } + | routine main { + | lda #4 + | jsr update_score + | sta border_colour + | } + ? routine does not preserve register + +But if it does it can. + + | assign byte border_colour 4000 + | reserve byte score + | routine update_score + | { + | ldx score + | inx + | stx score + | } + | routine main { + | lda #4 + | jsr update_score + | sta border_colour + | } + = True diff --git a/src/SixtyPical/Analyzer.hs b/src/SixtyPical/Analyzer.hs index 6b427db..fbed1c4 100644 --- a/src/SixtyPical/Analyzer.hs +++ b/src/SixtyPical/Analyzer.hs @@ -84,3 +84,7 @@ checkInstr (REPEAT _ branch blk) progCtx routCtx = routCtx checkInstr NOP progCtx routCtx = routCtx + +checkInstr instr _ _ = error ( + "Internal error: sixtypical doesn't know how to " ++ + "analyze '" ++ (show instr) ++ "'") diff --git a/test.sh b/test.sh index 3bea6ea..c32edf9 100755 --- a/test.sh +++ b/test.sh @@ -1,4 +1,7 @@ #!/bin/sh -FILES="doc/Checking.markdown doc/Emitting.markdown doc/Instruction_Support.markdown" +FILES="doc/Checking.markdown + doc/Emitting.markdown + doc/Instruction_Support.markdown + doc/Analyzing.markdown" ./build.sh && falderal --substring-error ${FILES}