From 9c47e5ff49917987f6d5173a32ece4e4bfb2f46c Mon Sep 17 00:00:00 2001 From: ryansuchocki Date: Fri, 27 Feb 2015 16:28:56 +0000 Subject: [PATCH] Fixing let for mega --- README.md | 2 +- ffi_stuff/dump.py | 6 ++---- src/codegen.c | 2 +- src/main.c | 2 +- src/models.c | 7 +++++++ src/parser.c | 4 ++-- src/preamble.s | 19 +++++-------------- src/stdlib.ms | 2 +- 8 files changed, 20 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 2868dda..19e3cfa 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ from other files in this repository. On linux systems, invoke `$ sudo make insta Usage ----- -As of version 0.9.1, the usage is: +As of version 0.9.2, the usage is: ``` Usage: microscheme [-aucvrio] [-m model] [-d device] [-w filename] [-t rounds] program[.ms] diff --git a/ffi_stuff/dump.py b/ffi_stuff/dump.py index ea7ad87..87ab73b 100644 --- a/ffi_stuff/dump.py +++ b/ffi_stuff/dump.py @@ -4,7 +4,7 @@ import sys -ser = serial.Serial(sys.argv[1], 1000000) +ser = serial.Serial(sys.argv[1], 9600) ser.flushInput() ser.close() @@ -18,6 +18,4 @@ while 1: b1 = ser.read() - b2 = ser.read() - val = (ord(b1) << 8) + ord(b2) - print (str(val)) + print (str(b1)) diff --git a/src/codegen.c b/src/codegen.c index 6e9a3ce..b175949 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -437,7 +437,7 @@ void codegen_emit(AST_expr *expr, int parent_numArgs, FILE *outputFile) { } else if (strcmp(expr->primproc, "stacksize") == 0 && expr->numBody == 0) { - fprintf(outputFile, "\tIN GP1, SPl\n\tIN GP2, SPh\n\tLDI CRSl, lo8(RAMEND)\n\tLDI CRSh, hi8(RAMEND)\n\tSUB CRSl, GP1\n\tSBC CRSh, GP2\n"); + fprintf(outputFile, "\tIN GP1, SPl\n\tIN GP2, SPh\n\tLDI CRSl, lo8(__stack)\n\tLDI CRSh, hi8(__stack)\n\tSUB CRSl, GP1\n\tSBC CRSh, GP2\n"); } else if (strcmp(expr->primproc, "heapsize") == 0 && expr->numBody == 0) { diff --git a/src/main.c b/src/main.c index a851ed6..63ef1ff 100644 --- a/src/main.c +++ b/src/main.c @@ -62,7 +62,7 @@ int main(int argc, char *argv[]) { char *inname, *outname, *basename, *shortbase; int c; - fprintf(stdout, "Microscheme 0.9.1, (C) Ryan Suchocki\n"); + fprintf(stdout, "Microscheme 0.9.2, (C) Ryan Suchocki\n"); char *helpmsg = "\nUsage: microscheme [-aucvrio] [-m model] [-d device] [-w filename] [-t rounds] program[.ms]\n\n" "Option flags:\n" diff --git a/src/models.c b/src/models.c index c93fdca..46ce900 100644 --- a/src/models.c +++ b/src/models.c @@ -26,6 +26,9 @@ model_info models[] = { ".EQU DDR13, 0x04 \n" ".EQU P13, 7 \n" + // This is necessary to stay within 13-bit addresses! + ".EQU _ms_stack, 0x2000\n" + ".EQU UDR0, 0xC6 \n" ".EQU UBRR0H, 0xC5 \n" ".EQU UBRR0L, 0xC4 \n" @@ -52,6 +55,8 @@ model_info models[] = { ".EQU DDR13, 0x04 \n" ".EQU P13, 5 \n" + ".EQU _ms_stack, __stack\n" + ".EQU UDR0, 0xC6 \n" ".EQU UBRR0H, 0xC5 \n" ".EQU UBRR0L, 0xC4 \n" @@ -77,6 +82,8 @@ model_info models[] = { ".EQU PORT13, 0x08 \n" ".EQU DDR13, 0x07 \n" ".EQU P13, 7 \n" + + ".EQU _ms_stack, __stack\n" } }; diff --git a/src/parser.c b/src/parser.c index 5181dc6..023a729 100644 --- a/src/parser.c +++ b/src/parser.c @@ -15,7 +15,7 @@ extern bool opt_verbose; extern char **globalIncludeList; extern int globalIncludeListN; -AST_expr *currentLambda = NULL, *tmpLambda = NULL; +AST_expr *currentLambda = NULL; void parser_initExpr(AST_expr *expr) { expr->type = Constant; @@ -144,7 +144,7 @@ AST_expr *parser_parseExpr(lexer_tokenNode **token, int numTokens, bool topLevel exit(EXIT_FAILURE); } - tmpLambda = currentLambda; + AST_expr *tmpLambda = currentLambda; currentLambda = result; result->numBody = innerNumTokens-2; result->body = try_malloc(sizeof(AST_expr*) * (innerNumTokens-2)); diff --git a/src/preamble.s b/src/preamble.s index 7bb676c..403ad00 100644 --- a/src/preamble.s +++ b/src/preamble.s @@ -71,24 +71,15 @@ LDI HFPl, lo8(_end) LDI HFPh, hi8(_end) LDI CCPl, 0 LDI CCPh, 0 -LDI AFPl, lo8(__stack) -LDI AFPh, hi8(__stack) +LDI AFPl, lo8(_ms_stack) +LDI AFPh, hi8(_ms_stack) + +OUT SPl, AFPl +OUT SPh, AFPh SBI DDR13, P13 CBI PORT13, P13 -# ; Set Baud Rate registers -# LDI GP1, hi8(BAUD_9600) -# STS UBRR0H, GP1 ;; ..1H for mega 1 -# LDI GP1, lo8(BAUD_9600) -# STS UBRR0L, GP1 ;; ..1L for mega 1 - -# ; Set control registers -# CLR GP1 -# SBR GP1, TXENm -# SBR GP1, RXENm -# STS UCSR0B, GP1 ;; ..1B for mega 1 - RJMP entry_point proc_call: diff --git a/src/stdlib.ms b/src/stdlib.ms index 595def3..f9801d4 100644 --- a/src/stdlib.ms +++ b/src/stdlib.ms @@ -120,7 +120,7 @@ #x109 #x109 #x23 #x23 #x23 #x23)) (set! arduino-pins (vector 1 2 16 32 32 8 8 16 32 64 16 32 64 128 2 1 2 1 8 4 2 1 1 2 4 8 16 32 64 128 128 64 32 16 8 4 2 1 128 4 2 1 128 64 32 16 8 - 4 2 1 8 4 2 1 1 2 4 8 16 32 64 128 1 2 4 8 16 32 64 128)))) + 4 2 1 8 4 2 1)))) (@if-model "UNO" (begin