Skip to content

Commit

Permalink
Fixing let for mega
Browse files Browse the repository at this point in the history
  • Loading branch information
ryansuchocki committed Feb 27, 2015
1 parent afe43d0 commit 9c47e5f
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -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]
Expand Down
6 changes: 2 additions & 4 deletions ffi_stuff/dump.py
Expand Up @@ -4,7 +4,7 @@
import sys


ser = serial.Serial(sys.argv[1], 1000000)
ser = serial.Serial(sys.argv[1], 9600)
ser.flushInput()
ser.close()

Expand All @@ -18,6 +18,4 @@

while 1:
b1 = ser.read()
b2 = ser.read()
val = (ord(b1) << 8) + ord(b2)
print (str(val))
print (str(b1))
2 changes: 1 addition & 1 deletion src/codegen.c
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/main.c
Expand Up @@ -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"
Expand Down
7 changes: 7 additions & 0 deletions src/models.c
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -77,6 +82,8 @@ model_info models[] = {
".EQU PORT13, 0x08 \n"
".EQU DDR13, 0x07 \n"
".EQU P13, 7 \n"

".EQU _ms_stack, __stack\n"
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/parser.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down
19 changes: 5 additions & 14 deletions src/preamble.s
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/stdlib.ms
Expand Up @@ -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
Expand Down

0 comments on commit 9c47e5f

Please sign in to comment.