1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2025-08-15 13:27:36 +00:00

Fixed a few comments. Added kbhit() check at end of eightqueens.

This commit is contained in:
jespergravgaard
2020-11-21 14:17:19 +01:00
parent 5c0618f9e8
commit 6cc6242a54
7 changed files with 2681 additions and 2445 deletions

View File

@@ -99,7 +99,7 @@ public class AsmFormat {
")"; ")";
} }
// Handle non-associative operators - only handle right side since parser is left-associativeA-B-C = (A-B)-C // Handle non-associative operators - only handle right side since parser is left-associative A-B-C = (A-B)-C
boolean rightParenthesis = false; boolean rightParenthesis = false;
if(!operator.isAssociative()) { if(!operator.isAssociative()) {
if(right instanceof ConstantBinary && ((ConstantBinary) right).getOperator().equals(operator)) { if(right instanceof ConstantBinary && ((ConstantBinary) right).getOperator().equals(operator)) {

View File

@@ -4,7 +4,7 @@ import dk.camelot64.kickc.model.types.SymbolType;
import dk.camelot64.kickc.model.types.SymbolTypePointer; import dk.camelot64.kickc.model.types.SymbolTypePointer;
import dk.camelot64.kickc.model.types.SymbolTypeStruct; import dk.camelot64.kickc.model.types.SymbolTypeStruct;
/** Constainer for all the expression operators */ /** Container for all the expression operators */
public class Operators { public class Operators {
public static final OperatorUnary INCREMENT = new OperatorIncrement(1); public static final OperatorUnary INCREMENT = new OperatorIncrement(1);

View File

@@ -4,7 +4,8 @@
// //
// This is an iterative solution. // This is an iterative solution.
#include<stdio.h> #include <stdio.h>
#include <conio.h>
#define QUEENS 8 #define QUEENS 8
#define PRINT_SOLUTIONS #define PRINT_SOLUTIONS
@@ -21,6 +22,7 @@ void main() {
printf("\nnumber of queens:%u",QUEENS); printf("\nnumber of queens:%u",QUEENS);
queens(); queens();
printf("\n\nsolutions: %lu\n",count); printf("\n\nsolutions: %lu\n",count);
while(!kbhit()) ;
} }
// Generates all valid placements of queens on a NxN board without recursion // Generates all valid placements of queens on a NxN board without recursion

View File

@@ -102,6 +102,12 @@ main: {
lda #>s3 lda #>s3
sta.z cputs.s+1 sta.z cputs.s+1
jsr cputs jsr cputs
__b1:
// kbhit()
jsr kbhit
// while(!kbhit())
cmp #0
beq __b1
// } // }
rts rts
s: .text " - n queens problem using backtracking -" s: .text " - n queens problem using backtracking -"
@@ -403,6 +409,21 @@ printf_ulong: {
// } // }
rts rts
} }
// Return true if there's a key waiting, return false if not
kbhit: {
// CIA#1 Port A: keyboard matrix columns and joystick #2
.label CIA1_PORT_A = $dc00
// CIA#1 Port B: keyboard matrix rows and joystick #1.
.label CIA1_PORT_B = $dc01
// *CIA1_PORT_A = 0
lda #0
sta CIA1_PORT_A
// ~*CIA1_PORT_B
lda CIA1_PORT_B
eor #$ff
// }
rts
}
// Output one character at the current cursor position // Output one character at the current cursor position
// Moves the cursor forward. Scrolls the entire screen if needed // Moves the cursor forward. Scrolls the entire screen if needed
// cputc(byte register(A) c) // cputc(byte register(A) c)

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -66,6 +66,12 @@ byte gotoxy::y
byte gotoxy::y#2 reg byte x 22.0 byte gotoxy::y#2 reg byte x 22.0
byte gotoxy::y#4 reg byte x 66671.0 byte gotoxy::y#4 reg byte x 66671.0
byte gotoxy::y#5 reg byte x 66667.33333333333 byte gotoxy::y#5 reg byte x 66667.33333333333
byte kbhit()
const nomodify byte* kbhit::CIA1_PORT_A = (byte*) 56320
const nomodify byte* kbhit::CIA1_PORT_B = (byte*) 56321
byte kbhit::return
byte kbhit::return#0 reg byte a 367.33333333333337
byte kbhit::return#2 reg byte a 202.0
byte legal(byte legal::row , byte legal::column) byte legal(byte legal::row , byte legal::column)
byte~ legal::$0 reg byte x 2000002.0 byte~ legal::$0 reg byte x 2000002.0
byte legal::column byte legal::column
@@ -92,6 +98,7 @@ byte legal::return#4 reg byte a 333.6666666666667
byte legal::row byte legal::row
byte legal::row#0 row zp[1]:10 222278.05555555556 byte legal::row#0 row zp[1]:10 222278.05555555556
void main() void main()
byte~ main::$5 reg byte a 202.0
const byte* main::s[$29] = " - n queens problem using backtracking -" const byte* main::s[$29] = " - n queens problem using backtracking -"
const byte* main::s1[$13] = " const byte* main::s1[$13] = "
number of queens:" number of queens:"
@@ -403,6 +410,8 @@ zp[1]:23 [ conio_cursor_x ]
zp[1]:24 [ conio_cursor_y ] zp[1]:24 [ conio_cursor_y ]
zp[2]:25 [ conio_line_text ] zp[2]:25 [ conio_line_text ]
zp[2]:27 [ conio_line_color ] zp[2]:27 [ conio_line_color ]
reg byte a [ kbhit::return#2 ]
reg byte a [ main::$5 ]
zp[2]:29 [ gotoxy::$7 gotoxy::$9 gotoxy::line_offset#0 gotoxy::$6 ] zp[2]:29 [ gotoxy::$7 gotoxy::$9 gotoxy::line_offset#0 gotoxy::$6 ]
zp[2]:31 [ gotoxy::$8 ] zp[2]:31 [ gotoxy::$8 ]
zp[2]:33 [ gotoxy::$5 ] zp[2]:33 [ gotoxy::$5 ]
@@ -410,6 +419,7 @@ reg byte a [ cputs::c#1 ]
zp[1]:35 [ legal::column#0 print::i#2 print::i#1 ] zp[1]:35 [ legal::column#0 print::i#2 print::i#1 ]
reg byte a [ legal::return#0 ] reg byte a [ legal::return#0 ]
reg byte a [ queens::$2 ] reg byte a [ queens::$2 ]
reg byte a [ kbhit::return#0 ]
reg byte a [ utoa::$11 ] reg byte a [ utoa::$11 ]
reg byte a [ utoa::$10 ] reg byte a [ utoa::$10 ]
zp[2]:36 [ utoa::digit_value#0 utoa_append::sub#0 memcpy::destination#2 memcpy::dst#2 memcpy::dst#4 memcpy::dst#1 ] zp[2]:36 [ utoa::digit_value#0 utoa_append::sub#0 memcpy::destination#2 memcpy::dst#2 memcpy::dst#4 memcpy::dst#1 ]